RepairOrderHandle.jsx 4.08 KB
Newer Older
TZW's avatar
TZW committed
1 2 3 4
/* 接单、派单窗口
 * @Author: Li Hanlin
 * @Date: 2022-12-05 11:13:26
 * @Last Modified by: Li Hanlin
TZW's avatar
TZW committed
5
 * @Last Modified time: 2023-01-06 16:28:51
TZW's avatar
TZW committed
6 7 8
 */

import React, { useState, useEffect } from 'react';
TZW's avatar
TZW committed
9
import InitForm from '@/components/InitForm';
TZW's avatar
TZW committed
10
import { doFetch } from '@/utils/doFetch';
TZW's avatar
TZW committed
11
import { message } from 'antd';
TZW's avatar
TZW committed
12
const App = ({ type, id, actionRef, url, setdrawer }) => {
TZW's avatar
TZW committed
13 14
  const columns = {
    wxjd: [
TZW's avatar
TZW committed
15 16 17 18 19 20
      {
        title: '协助维修人员',
        dataIndex: 'repairAssistList',
        key: 'repairAssistList',
        valueType: 'select',
        options: { path: '/repair/umRepairOrder/selection', params: { id } },
TZW's avatar
TZW committed
21 22 23 24 25
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
          mode: 'multiple',
        },
TZW's avatar
TZW committed
26
      },
TZW's avatar
TZW committed
27 28
    ],
    wxpd: [
TZW's avatar
TZW committed
29 30
      {
        title: '维修人员',
TZW's avatar
TZW committed
31 32
        dataIndex: 'repairId',
        key: 'repairId',
TZW's avatar
TZW committed
33 34 35 36 37 38
        valueType: 'select',
        options: { path: '/auth/sysUser/selection' },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
      {
        title: '协助维修人员',
TZW's avatar
TZW committed
39 40
        dataIndex: 'repairAssistList',
        key: 'repairAssistList',
TZW's avatar
TZW committed
41 42
        valueType: 'select',
        options: { path: '/repair/umRepairOrder/selection', params: { id } },
TZW's avatar
TZW committed
43 44 45 46 47 48
        fieldProps: {
          placeholder: '请选择',
          showSearch: true,
          mode: 'multiple',
        },
      },
TZW's avatar
TZW committed
49 50
    ],
    zzpd: [
TZW's avatar
TZW committed
51 52 53 54 55 56 57 58
      {
        title: '追踪人员',
        dataIndex: 'trackAssistList',
        key: 'trackAssistList',
        valueType: 'select',
        options: { path: '/auth/sysUser/selection' },
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
      },
TZW's avatar
TZW committed
59 60
    ],
    wpd: [
TZW's avatar
TZW committed
61 62 63 64 65
      {
        title: '外协人员',
        dataIndex: 'otherUnitsAssistList',
        key: 'otherUnitsAssistList',
        valueType: 'select',
TZW's avatar
TZW committed
66
        options: { path: '/repair/umOtherUnitsOrder/selection', params: { id } },
TZW's avatar
TZW committed
67
        formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
TZW's avatar
TZW committed
68
      },
TZW's avatar
TZW committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    ],
  };
  const finishHandle = {
    wxjd: async (vals) => {
      //console.log(vals);
      vals.repairAssistList = vals?.repairAssistList.map((it) => ({
        assistUserId: it,
      }));
      let params = {
        ...vals,
        id,
      };
      let res = await doFetch({
        url,
        params,
      });
      if (res.code === '0000') {
        message.success('操作成功!');
        setdrawer((s) => ({
          ...s,
          open: false,
        }));
        actionRef.current.reload();
      }
    },
    wxpd: async (vals) => {
      //console.log(vals);
      vals.repairAssistList = vals?.repairAssistList.map((it) => {
        return {
          assistUserId: it,
        };
      });
      let params = {
        ...vals,
        id,
      };
      let res = await doFetch({
        url,
        params,
      });
      if (res.code === '0000') {
        message.success('操作成功!');
        setdrawer((s) => ({
          ...s,
          open: false,
        }));
        actionRef.current.reload();
      }
    },
    zzpd: async (vals) => {
      //console.log(vals);
      let params = {
        trackAssistList: [{ assistUserId: vals?.trackAssistList }],
        id,
      };
      //console.log(params);
      let res = await doFetch({
        url,
        params,
      });
      if (res.code === '0000') {
        message.success('操作成功!');
        setdrawer((s) => ({
          ...s,
          open: false,
        }));
        actionRef.current.reload();
      }
    },
    wpd: async (vals) => {
      let params = {
        otherUnitsAssistList: [{ assistUserId: vals?.otherUnitsAssistList }],
        id,
      };
      let res = await doFetch({
        url,
        params,
      });
      if (res.code === '0000') {
        message.success('操作成功!');
        setdrawer((s) => ({
          ...s,
          open: false,
        }));
        actionRef.current.reload();
      }
    },
  };

TZW's avatar
TZW committed
158 159
  return (
    <>
TZW's avatar
TZW committed
160
      <InitForm fields={columns[type]} onFinish={finishHandle[type]} />
TZW's avatar
TZW committed
161 162 163 164 165
    </>
  );
};

export default App;