Kaynağa Gözat

审批节点支持选择多人依次审批

Renxy 2 yıl önce
ebeveyn
işleme
f4dc257905

+ 4 - 2
src/components/Flow/node/auditNode/index.tsx

@@ -68,8 +68,10 @@ const CustomRect = (props: any) => {
             return roleList.find((item: any) => item.ID == audits[0].value)
               ?.Name;
           case IDTYPE.USER:
-            return userList.find((item: any) => item.ID == audits[0].value)
-              ?.CName;
+            const nameList = audits.map((item: any) => {
+              return userList.find((user: any) => user.ID == item.value)?.CName;
+            });
+            return nameList.join('、');
           case IDTYPE.LEADER:
             return '部门主管';
         }

+ 15 - 11
src/components/Flow/node/auditNode/mapServe.tsx

@@ -161,19 +161,21 @@ const Component = (props: any) => {
             <label>审批人</label>
             <Select
               showSearch
+              mode="multiple"
               style={{ width: '100%' }}
               value={nodeConfig.audits?.map((item) => item.value)}
               onChange={(value) => {
-                onNodeConfigChange('audits', [
-                  {
+                const list = value.map((id) => {
+                  return {
                     type: IDTYPE.USER,
                     label:
                       nodeConfig.label == '动作节点'
-                        ? '审批人'
+                        ? '抄送人'
                         : nodeConfig.label,
-                    value: Number(value),
-                  },
-                ]);
+                    value: Number(id),
+                  };
+                });
+                onNodeConfigChange('audits', list);
               }}
               filterOption={(input, option) =>
                 option.props.children.indexOf(input) >= 0
@@ -368,20 +370,22 @@ const Component = (props: any) => {
           <label>抄送人:</label>
           <Select
             showSearch
+            mode="multiple"
             style={{ width: '80%' }}
             value={nodeConfig.audits?.map((item) => item.value)}
             onChange={(value) => {
-              onNodeConfigChange('audits', [
-                {
+              const list = value.map((id) => {
+                return {
                   type: IDTYPE.USER,
                   label:
                     nodeConfig.label == '动作节点'
                       ? '抄送人'
                       : nodeConfig.label,
-                  value: Number(value),
+                  value: Number(id),
                   is_cc: 1,
-                },
-              ]);
+                };
+              });
+              onNodeConfigChange('audits', list);
             }}
             filterOption={(input, option) =>
               option?.props?.children.indexOf(input) >= 0

+ 1 - 0
src/pages/Flow/AuditModal.js

@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
 import { Modal, Input, Form, Select } from 'antd';
 
 const flowTypeList = [
+  { value: 0, label: 'BOM审批' },
   { value: 1, label: '文档审批' },
   { value: 2, label: 'OA审批' },
   { value: 3, label: '合同归档审批' },

+ 1 - 1
src/pages/Flow/OaDetail.js

@@ -115,7 +115,7 @@ const OaDetail = () => {
       createRun({
         flow_id: Number(oaId),
         form: JSON.stringify(formData),
-        audit_list,
+        audit_list: audit_list.flat(),
         cc_list,
         files: files.join(','),
       });

+ 37 - 20
src/pages/Flow/components/ApprovalProcess.tsx

@@ -14,8 +14,10 @@ import {
   Spin,
   Steps,
   Timeline,
+  Checkbox,
 } from 'antd';
 import { useModel, useRequest } from '@umijs/max';
+import { CheckboxValueType } from 'antd/es/checkbox/Group';
 
 const { Step } = Steps;
 
@@ -43,7 +45,7 @@ const ApprovalProcess = (props: any) => {
     roleList = [],
   } = props;
   const { userList, run } = useModel('userList');
-  const [checkValue, setCheckValue] = useState<number[]>([]);
+  const [checkValue, setCheckValue] = useState<number[][]>([]);
 
   const { auditList, ccList } = useMemo<{
     auditList: AuditNode[];
@@ -71,7 +73,7 @@ const ApprovalProcess = (props: any) => {
     return { auditList, ccList };
   }, [approvalProcess]);
 
-  const onCheckValue = (value: number, index: number) => {
+  const onCheckValue = (value: number[], index: number) => {
     let values = [...checkValue];
     values[index] = value;
     setCheckValue(values);
@@ -101,7 +103,7 @@ const ApprovalProcess = (props: any) => {
             roleList={roleList}
             userList={userList}
             value={checkValue[item.seq]}
-            onChange={(value: number) => onCheckValue(value, item.seq)}
+            onChange={(value: number[]) => onCheckValue(value, item.seq)}
           />
         ),
       };
@@ -122,8 +124,8 @@ interface AuditNodeStepProps {
   leaderData: any;
   roleList: any;
   userList: any;
-  value: number;
-  onChange: (value: number) => void;
+  value: number[];
+  onChange: (value: number[]) => void;
 }
 
 const AuditNodeStep = (props: AuditNodeStepProps) => {
@@ -158,19 +160,30 @@ const AuditNodeStep = (props: AuditNodeStepProps) => {
     setLoading(false);
   };
 
-  const selectedUserId = ({ target: { value } }: RadioChangeEvent) => {
-    onChange(Number(value));
+  const selectedUserId = (list: CheckboxValueType[]) => {
+    console.log(list as number[]);
+    onChange(list as number[]);
   };
 
   const content = (
     <Spin spinning={loading}>
-      <Radio.Group onChange={selectedUserId} value={value}>
-        {selectUserList.map((item: any) => (
-          <Radio.Button value={Number(item.user_id)}>
-            {item.c_name}
-          </Radio.Button>
-        ))}
-      </Radio.Group>
+      <Checkbox.Group
+        style={{ display: 'block' }}
+        onChange={selectedUserId}
+        value={value as any}
+      >
+        {selectUserList
+          .filter((item: any) => item.c_name)
+          .map((item: any) => (
+            <Checkbox
+              style={{ whiteSpace: 'nowrap' }}
+              key={item.user_id}
+              value={Number(item.user_id)}
+            >
+              {item.c_name}
+            </Checkbox>
+          ))}
+      </Checkbox.Group>
     </Spin>
   );
 
@@ -191,14 +204,16 @@ const AuditNodeStep = (props: AuditNodeStepProps) => {
   }
   if (item.type == TYPE.ROLE) {
     let label = item.label || '';
-    let userName = '';
     const names = item.value.map((id) => {
       const role = roleList.find((cur: any) => cur.ID == id);
       return role?.Name;
     });
     let title = `从${names.join('、')}选择`;
-    if (value) {
-      userName = userList.find((cur: any) => cur.ID == value)?.CName;
+    let userNames = [];
+    if (value?.length > 0) {
+      userNames = value.map(
+        (id: number) => userList.find((cur: any) => cur.ID == id)?.CName,
+      );
     }
     return (
       <div
@@ -220,10 +235,10 @@ const AuditNodeStep = (props: AuditNodeStepProps) => {
           trigger="click"
           overlayStyle={{ width: '300px' }}
           onOpenChange={handleOpen}
-          style={{ marginBottom: 20 }}
+          style={{ marginBottom: 20, overflow: 'auto' }}
         >
           <Space>
-            {userName}
+            {userNames.join('、')}
             <PlusSquareOutlined style={{ fontSize: '36px', color: 'gray' }} />
           </Space>
         </Popover>
@@ -233,7 +248,9 @@ const AuditNodeStep = (props: AuditNodeStepProps) => {
 
   let label = item.label || '';
 
-  let title = item.is_cc ? '抄送1人' : '1人审批';
+  let title = item.is_cc
+    ? `抄送${item.value.length}人`
+    : `${item.value.length}人审批`;
   const names = item.value.map((id) => {
     const user = userList.find((cur: any) => cur.ID == id);
     return user?.CName;

+ 1 - 1
src/pages/Flow/index.js

@@ -140,7 +140,7 @@ function Audit(props) {
     dispatch({
       type: 'flow/queryAuditList',
       payload: {
-        flow_type: 1,
+        flow_type: 'all',
       },
     });
     dispatch({

+ 1 - 2
src/pages/Flow/models/flow.js

@@ -63,11 +63,10 @@ export default {
     *queryAuditList({ payload }, { call, put }) {
       try {
         const response = yield call(queryAuditList, payload);
-        const res = yield call(queryAuditList);
         yield put({
           type: 'save',
           payload: {
-            auditList: [...response.data, ...res.data],
+            auditList: response.data,
           },
         });
       } catch (error) {}