xjj преди 2 години
родител
ревизия
3a9b05d141
променени са 8 файла, в които са добавени 191 реда и са изтрити 279 реда
  1. 25 3
      src/pages/Detail/CommitAuditModal.js
  2. 17 4
      src/pages/Detail/FlowModal.js
  3. 11 256
      src/pages/Detail/Index.js
  4. 105 4
      src/pages/Detail/TimeNode.js
  5. 13 4
      src/pages/Detail/VersionModal.js
  6. 12 4
      src/pages/List/List.js
  7. 4 2
      src/services/boom.js
  8. 4 2
      src/utils/request.js

+ 25 - 3
src/pages/Detail/CommitAuditModal.js

@@ -52,7 +52,6 @@ function CommitAuditModal(props) {
     dispatch,
     visible,
     onClose,
-    onOk,
     loading,
     version,
     versionList,
@@ -60,7 +59,7 @@ function CommitAuditModal(props) {
     currentUser,
     luckysheet,
     userList,
-    // uploadProps,
+    templateId,
     OSSData,
   } = props;
   // console.log(loading);
@@ -529,7 +528,23 @@ function CommitAuditModal(props) {
     params.audit_series = uuidv4();
     params.files = uploadList.current.join(',');
     console.log(params);
-    onOk(params);
+    onSubmitNextNode(params);
+  };
+  const onSubmitNextNode = values => {
+    dispatch({
+      type: 'detail/submitNextNode',
+      payload: values,
+      callback: newVersion => {
+        onClose();
+        // 更新flow流程图
+        dispatch({
+          type: 'xflow/queryBoomFlowDetail',
+          payload: {
+            id: templateId,
+          },
+        });
+      },
+    });
   };
   const CascaderNode = index => {
     return (
@@ -579,6 +594,13 @@ function CommitAuditModal(props) {
     },
   ];
 
+  useEffect(() => {
+    if (!visible) {
+      // 清空数据
+      uploadList.current = [];
+    }
+  }, [visible]);
+
   return (
     <Modal
       confirmLoading={loading.global}

+ 17 - 4
src/pages/Detail/FlowModal.js

@@ -37,6 +37,7 @@ const { Step } = Steps;
 const { TextArea } = Input;
 const localData = JSON.parse(localStorage.ggDetaiData || '{}');
 const PAGE_SIZE = 8;
+let controller = new AbortController();
 
 // 提交
 function FlowModal(props) {
@@ -61,6 +62,7 @@ function FlowModal(props) {
     currentUser,
     typeOptions,
     userList,
+    versionList,
     templateId,
   } = props;
   const [data, setData] = useState([]);
@@ -129,11 +131,20 @@ function FlowModal(props) {
   };
 
   const initData = async template_node_id => {
-    setNodeLoading(true);
+    if (controller) {
+      // 中止上一次请求
+      controller.abort();
+    }
     try {
-      const res = await queryVserionByNode({
-        template_node_id: template_node_id,
-      });
+      setNodeLoading(true);
+      controller = new AbortController();
+      const res = await queryVserionByNode(
+        {
+          template_node_id: template_node_id,
+        },
+        controller.signal
+      );
+      controller = null;
       let data = [];
       if (!res.data.excel_version_tree) setData([]);
       res.data.excel_version_tree?.map(arr => {
@@ -488,6 +499,8 @@ function FlowModal(props) {
         typeOptions={typeOptions}
         visible={versionVisible}
         version={version}
+        versionList={versionList}
+        flowDetail={flowDetail}
         onClose={() => setVersionVisible(false)}
         onOk={values => {
           onCommit?.(values, () => {

+ 11 - 256
src/pages/Detail/Index.js

@@ -70,7 +70,6 @@ function Detail(props) {
     diff: 0,
     add: 0,
   });
-  // const [fileVisible, setFileVisible] = useState(false);
   const [exportDate, setExportData] = useState([]);
   const sheetRef = useRef();
   const sheetRef2 = useRef();
@@ -94,32 +93,6 @@ function Detail(props) {
 
   const projectId = parseInt(params.projectId);
   const templateId = parseInt(params.templateId);
-  const auditDetail = useMemo(() => {
-    let data = {
-      processCode: '',
-      deptId: '14169890',
-      tasks: [],
-      // userId: '16569001414345099',
-      // deptId: currentUser.DingDepId || getCurrentUser()?.DingDepId,
-      userId: currentUser.DingUserId || getCurrentUser()?.DingUserId,
-      formComponentValues: [],
-      activityId: '',
-      cc_userids: [],
-      status: version.audit_status,
-    };
-    if (version?.flow_id && instanceDetail?.tasks && instanceDetail.tasks?.length > 0) {
-      let item = flowDetail.nodes.find(item => item.Id == version.template_node_id);
-      if (!item) return data;
-      const { tasks, form_component_values, cc_userids } = instanceDetail;
-      data.processCode = item.process_code;
-      data.activityId = tasks[tasks.length - 1]?.activity_id;
-      data.tasks = tasks || [];
-      data.cc_userids = cc_userids;
-      data.formComponentValues = form_component_values?.filter(item => item.name);
-      if (version.status == 1) data.status = -1;
-    }
-    return data;
-  }, [instanceDetail, version]);
 
   const flow = useMemo(() => {
     let data = {
@@ -145,10 +118,7 @@ function Detail(props) {
   }, [auditList, version]);
   const active_audit = flow.active_audit;
   const isAuditor = useMemo(() => {
-    const getUserRole = () => {
-      return flow.currentNode?.auditor == currentUser.ID;
-    };
-    return active_audit == 1 && getUserRole();
+    return active_audit == 1 && flow.currentNode?.auditor == currentUser.ID;
   }, [active_audit, flow, currentUser]);
 
   const onCompare = async checkSheets => {
@@ -198,7 +168,6 @@ function Detail(props) {
           className={styles.sheet}
           ref={!index ? sheetRef3 : sheetRef2}
           data={item.data || null}
-          // onClickCell={onClickCell}
         />
       </div>
     );
@@ -216,31 +185,12 @@ function Detail(props) {
         type: 'detail/queryComment',
         payload,
       });
-
-      // setCommentVisible(true);
     }
-    // 比对模式下双excl同步选中
-    // if (statusRef.current.compare) {
-    //   sheetRef3.current.selectCell(position.r, position.c, s.order);
-    //   sheetRef2.current.selectCell(position.r, position.c, s.order);
-    // }
   };
 
   const onCommit = params => {
-    let currentNode = flowDetail.nodes.find?.(item => item.Id == version.template_node_id);
     let currentData = sheetRef.current.getSheetJson().data;
     let sheets = JSON.parse(JSON.stringify(currentData));
-    if (!currentNode.muti_version) {
-      // audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
-      let serviceVersion = versionList.find(
-        item => item.audit_status != 4 && item.template_node_id == currentNode.Id
-      );
-      if (serviceVersion) {
-        message.error(`新建清单失败!业务节点【${currentNode.label}】只能有一个清单!`);
-        return;
-      }
-    }
-
     sheets.forEach(item => {
       delete item.data;
     });
@@ -323,102 +273,7 @@ function Detail(props) {
     });
   };
 
-  const onApprove = flag => {
-    if (!flag) {
-      setAuditVisible(true);
-      return;
-    }
-
-    let isSingle = false;
-    let serviceNode;
-    const flowNode = flow.currentNode;
-    const getLastTemplateNodeId = data => {
-      let result;
-      const getFun = item => {
-        if (item.flow_path?.length > 0) {
-          getFun(item.flow_path[0]);
-        } else {
-          result = item.template_node_id;
-        }
-      };
-      if (!data) return version.template_node_id;
-      getFun(data[0]);
-      return result;
-    };
-    let lastTemplateNodeId = version.template_node_id;
-    if (version.flow_path) {
-      //如果多节点审批  获取当前是否审批流程的最后一个审批节点
-      let flowPathList = JSON.parse(version.flow_path);
-      lastTemplateNodeId = getLastTemplateNodeId(flowPathList);
-    }
-
-    // 判断是否为最后一个审批节点
-    if (
-      lastTemplateNodeId == version.template_node_id &&
-      flow.current == flow.list.FlowNodes.length - 1
-    ) {
-      serviceNode = flowDetail.nodes.find?.(item => item.Id == version.next_template_node_id);
-      if (!serviceNode.muti_version) {
-        //audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
-        isSingle = versionList.find(
-          item => item.audit_status != 4 && item.template_node_id == serviceNode.Id
-        );
-      }
-    }
-    Modal.confirm({
-      title: '提示',
-      content: isSingle
-        ? `节点【${serviceNode.label}】只能拥有一个清单,是否覆盖?`
-        : `是否通过审批。`,
-      okText: '确定',
-      cancelText: '取消',
-      onOk: () => {
-        dispatch({
-          type: 'detail/approve',
-          payload: {
-            id: flow.active_id,
-            project_id: projectId,
-            audit_status: 3,
-            flow_id: flowNode.flow_id,
-            node_id: flowNode.seq,
-          },
-          callback: newVersion => {
-            // 更新flow流程图
-            dispatch({
-              type: 'xflow/queryBoomFlowDetail',
-              payload: {
-                id: templateId,
-              },
-            });
-
-            // 更新审批流
-            dispatch({
-              type: 'detail/queryAuditList',
-              payload: {
-                template_id: version.template_id,
-                template_node_id: version.template_node_id,
-                flow_id: version.flow_id,
-                version_id: version.version_id,
-                audit_series: version.audit_series,
-              },
-            });
-            if (flow.current == flow.list.FlowNodes.length - 1) {
-              // 最后一个审核节点通过后  需要更新version id 不更不更,留在原地
-              // localStorage.excelId = newVersion.id;
-              // setVersion({
-              //   ...version,
-              //   flow_id: newVersion.flow_id,
-              //   id: newVersion.id,
-              // });
-            }
-          },
-        });
-      },
-    });
-  };
-
   const onMergeVersion = async sheet2 => {
-    // const [sheet1, sheet2] = checkSheets;
     const sheet1 = version;
     if (!sheet1.data) {
       sheet1.data = (
@@ -437,9 +292,6 @@ function Detail(props) {
 
     setIsMerge(true);
     setCompareList([sheet1, sheet2]);
-    // setTimeout(() => {
-    //   sheetRef3.current.mergeExcl(sheet.data);
-    // }, 400);
   };
 
   const handleMenuClick = e => {
@@ -477,15 +329,6 @@ function Detail(props) {
     });
   };
 
-  const getRowOneList = () => {
-    const obj = sheetRef.current.getSheetJson();
-    const list = [];
-    obj.data.forEach(item => {
-      list.push(item.data[0]);
-    });
-    return list;
-  };
-
   //点击导出弹出选择导出列弹框
   const handleExportClick = () => {
     setExportData(sheetRef.current.getSheetJson());
@@ -497,73 +340,11 @@ function Detail(props) {
     setExportVisible(false);
   };
 
-  const queryHistory = id => {
-    return new Promise(reslove => {
-      dispatch({
-        type: 'detail/queryHistory',
-        payload: {
-          // excel_id: id || excelId,
-          project_id: projectId,
-        },
-        callback: reslove,
-      });
-    });
-  };
-
-  const getUploadProps = () => {
-    const token = getToken() || GetTokenFromUrl();
-    const uploadProps = {
-      name: 'file',
-      // showUploadList: false,
-      action: `/api/v1/purchase/attachment/${projectId}`,
-      headers: {
-        'JWT-TOKEN': token,
-      },
-      data: {
-        type: 'file',
-        file_type: 1, // '0 全局文件  1节点合同文件',
-      },
-      onChange(info) {
-        if (info.file.status !== 'uploading') {
-          console.log(info.file, info.fileList);
-        }
-        if (info.file.status === 'done') {
-          message.success(`${info.file.name} 文件上传成功`);
-          // queryFiles();
-        } else if (info.file.status === 'error') {
-          message.error(`${info.file.name} 文件上传失败`);
-        }
-      },
-    };
-    return uploadProps;
-  };
-
- 
-  const queryHistoryDetail = async item => {
-    return new Promise(resolve => {
-      dispatch({
-        type: 'detail/queryHistoryDetail',
-        payload: {
-          excel_id: item.excel_id,
-          history_id: item.id,
-        },
-        callback: sheet => {
-          resolve(sheet);
-        },
-      });
-    });
-  };
-
   const getLoading = () => {
     let effects = loading.effects;
     return !loading.effects['detail/queryComment'] && loading.models.detail;
   };
 
-  const getFilesLoading = () => {
-    let effects = loading.effects;
-    return loading.effects['detail/queryFiles'];
-  };
-
   const changeVersion = id => {
     let version;
     if (typeof id == 'object') {
@@ -598,23 +379,6 @@ function Detail(props) {
     }
   };
 
-  const onSubmitNextNode = values => {
-    dispatch({
-      type: 'detail/submitNextNode',
-      payload: values,
-      callback: newVersion => {
-        setCommitAuditVisible(false);
-        // 更新flow流程图
-        dispatch({
-          type: 'xflow/queryBoomFlowDetail',
-          payload: {
-            id: templateId,
-          },
-        });
-      },
-    });
-  };
-
   const getUser = newUser => {
     try {
       if (JSON.stringify(newUser) != JSON.stringify(userRef.current)) {
@@ -748,7 +512,15 @@ function Detail(props) {
           onChange={e => exportExcl(e.target.files)}
         />
       </div>
-      <TimeNode flow={flow} isAuditor={isAuditor} onApprove={onApprove}></TimeNode>
+      <TimeNode
+        flow={flow}
+        flowDetail={flowDetail}
+        isAuditor={isAuditor}
+        version={version}
+        templateId={templateId}
+        projectId={projectId}
+        setAuditVisible={setAuditVisible}
+      ></TimeNode>
 
       {/* 判断是否为比对模式 */}
       {compareList.length == 2 ? (
@@ -789,8 +561,6 @@ function Detail(props) {
         excelFileList={excelFileList}
         version={version}
       />
-      {/* <CommentContent title="单元格沟通记录" /> */}
-
       <RightDrawer
         version={version}
         visible={commentVisible}
@@ -829,23 +599,10 @@ function Detail(props) {
         onClose={() => setAuditVisible(false)}
         onOk={onAudit}
       />
-      {/* <FilesModal
-        projectId={projectId}
-        typeOptions={typeOptions}
-        // loading={getFilesLoading()}
-        visible={fileVisible}
-        onClose={() => setFileVisible(false)}
-        queryFiles={queryFiles}
-        // uploadProps={getUploadProps()}
-        DeleteFile={deleteFile}
-        downloadFile={downloadFile}
-        data={fileList}
-      /> */}
       <VersionModal
         typeOptions={typeOptions}
         visible={versionVisible}
         flowDetail={flowDetail}
-        sheetRef={sheetRef}
         versionList={versionList}
         version={version}
         onClose={() => setVersionVisible(false)}
@@ -853,13 +610,11 @@ function Detail(props) {
         loading={getLoading()}
       />
       <CommitAuditModal
-        uploadProps={getUploadProps()}
-        loading={getFilesLoading()}
         visible={commitAuditVisible}
         version={version}
         onClose={() => setCommitAuditVisible(false)}
-        onOk={onSubmitNextNode}
         luckysheet={sheetRef}
+        templateId={templateId}
       />
     </div>
   );

+ 105 - 4
src/pages/Detail/TimeNode.js

@@ -2,18 +2,119 @@ import React, { useEffect, useState, useRef } from 'react';
 import { Form } from '@ant-design/compatible';
 import '@ant-design/compatible/assets/index.css';
 import { connect } from 'dva';
-import { Steps, Button } from 'antd';
+import { Steps, Button, Modal } from 'antd';
 import styles from './Index.less';
 
 const { Step } = Steps;
 // 时间节点
 function TimeNode(props) {
   const {
-    flow: { current, list, active },
     isAuditor,
-    onApprove,
+    flowDetail,
+
+    flow,
+    versionList,
+    version,
+    templateId,
+    setAuditVisible,
+    projectId,
+    dispatch,
   } = props;
+  const { current, list, active } = flow;
+
+  const onApprove = flag => {
+    if (!flag) {
+      setAuditVisible(true);
+      return;
+    }
+
+    let isSingle = false;
+    let serviceNode;
+    const flowNode = flow.currentNode;
+    const getLastTemplateNodeId = data => {
+      let result;
+      const getFun = item => {
+        if (item.flow_path?.length > 0) {
+          getFun(item.flow_path[0]);
+        } else {
+          result = item.template_node_id;
+        }
+      };
+      if (!data) return version.template_node_id;
+      getFun(data[0]);
+      return result;
+    };
+    let lastTemplateNodeId = version.template_node_id;
+    if (version.flow_path) {
+      //如果多节点审批  获取当前是否审批流程的最后一个审批节点
+      let flowPathList = JSON.parse(version.flow_path);
+      lastTemplateNodeId = getLastTemplateNodeId(flowPathList);
+    }
+
+    // 判断是否为最后一个审批节点
+    if (
+      lastTemplateNodeId == version.template_node_id &&
+      flow.current == flow.list.FlowNodes.length - 1
+    ) {
+      serviceNode = flowDetail.nodes.find?.(item => item.Id == version.next_template_node_id);
+      if (!serviceNode.muti_version) {
+        //audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
+        isSingle = versionList.find(
+          item => item.audit_status != 4 && item.template_node_id == serviceNode.Id
+        );
+      }
+    }
+    Modal.confirm({
+      title: '提示',
+      content: isSingle
+        ? `节点【${serviceNode.label}】只能拥有一个清单,是否覆盖?`
+        : `是否通过审批。`,
+      okText: '确定',
+      cancelText: '取消',
+      onOk: () => {
+        dispatch({
+          type: 'detail/approve',
+          payload: {
+            id: flow.active_id,
+            project_id: projectId,
+            audit_status: 3,
+            flow_id: flowNode.flow_id,
+            node_id: flowNode.seq,
+          },
+          callback: newVersion => {
+            // 更新flow流程图
+            dispatch({
+              type: 'xflow/queryBoomFlowDetail',
+              payload: {
+                id: templateId,
+              },
+            });
 
+            // 更新审批流
+            dispatch({
+              type: 'detail/queryAuditList',
+              payload: {
+                template_id: version.template_id,
+                template_node_id: version.template_node_id,
+                flow_id: version.flow_id,
+                version_id: version.version_id,
+                audit_series: version.audit_series,
+              },
+            });
+            if (flow.current == flow.list.FlowNodes.length - 1) {
+              // 最后一个审核节点通过后  需要更新version id 不更不更,留在原地
+              // localStorage.excelId = newVersion.id;
+              // setVersion({
+              //   ...version,
+              //   flow_id: newVersion.flow_id,
+              //   id: newVersion.id,
+              // });
+            }
+          },
+        });
+      },
+    });
+  };
   if (!list || list.FlowNodes?.length != 0) {
     return (
       <div className={styles.top}>
@@ -53,4 +154,4 @@ function TimeNode(props) {
   return null;
 }
 
-export default TimeNode;
+export default connect(({ detail }) => ({ versionList: detail.versionList }))(TimeNode);

+ 13 - 4
src/pages/Detail/VersionModal.js

@@ -11,16 +11,25 @@ function VersionModal(props) {
     data = {},
     loading,
     typeOptions,
-    // flowDetail,
-    // sheetRef,
-    // versionList,
+    flowDetail,
+    versionList,
     version,
   } = props;
   const [form] = Form.useForm();
   const formLayout = { labelCol: { span: 4 }, wrapperCol: { span: 14 } };
-  // console.log(flowDetail)
 
   const handleOk = async () => {
+    let currentNode = flowDetail.nodes.find?.(item => item.Id == version.template_node_id);
+    if (!currentNode.muti_version) {
+      // audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
+      let serviceVersion = versionList.find(
+        item => item.audit_status != 4 && item.template_node_id == currentNode.Id
+      );
+      if (serviceVersion) {
+        message.error(`新建清单失败!业务节点【${currentNode.label}】只能有一个清单!`);
+        return;
+      }
+    }
     let fieldsValue = await form.validateFields();
     if (!fieldsValue.classify_id) fieldsValue.classify_id = 1;
     fieldsValue.new_version = 0;

+ 12 - 4
src/pages/List/List.js

@@ -14,7 +14,7 @@ import { getToken } from '@/utils/utils';
 import ClassifyModal from './ClassifyModal';
 
 function List(props) {
-  const { excel, loading, project, dispatch, typeOptions, userList } = props;
+  const { excel, loading, project, dispatch, typeOptions, userList, versionList } = props;
   const [flowVisible, setFlowVisible] = useState(false);
   const [version, setVersion] = useState({});
   const [versionVisible, setVersionVisible] = useState(false);
@@ -82,6 +82,12 @@ function List(props) {
                 setFlowDetail(data);
                 setVersion(record);
                 setFlowVisible(true);
+                dispatch({
+                  type: 'list/queryVersionsList',
+                  payload: {
+                    project_id: record.project_id,
+                  },
+                });
               } catch (error) {}
               setLoading2(false);
               // router.push(`/home/detail/${record.project_id}/${record.template_id}`);
@@ -140,10 +146,10 @@ function List(props) {
     return !loadingVersion.effects['detail/queryComment'] && loadingVersion.models.detail;
   };
 
-  const onCommit = async (values,  callback) => {
+  const onCommit = async (values, callback) => {
     setCommitLoading(true);
     let sheets = await queryRecordSheet({ gridKey: version.id, 'JWT-TOKEN': token });
-  
+
     let params = {
       ...values,
       data: sheets,
@@ -198,6 +204,7 @@ function List(props) {
         typeOptions={typeOptions}
         isOut={true}
         flowDetail={flowDetail}
+        versionList={versionList}
         visible={flowVisible}
         onClose={() => setFlowVisible(false)}
         version={version}
@@ -218,8 +225,9 @@ function List(props) {
   );
 }
 
-export default connect(({ list, loading, detail, user }) => ({
+export default connect(({ list, loading, user }) => ({
   excel: list.excel,
+  versionList: list.versionList,
   project: list.project,
   loading: loading.models.list,
   loadingVersion: loading,

+ 4 - 2
src/services/boom.js

@@ -27,8 +27,10 @@ export async function queryFlowList(params) {
 }
 
 // 根据节点id查询所有version
-export async function queryVserionByNode(params) {
-  return request(`/purchase/bom/flow/node?${stringify(params)}`);
+export async function queryVserionByNode(params, signal) {
+  return request(`/purchase/bom/flow/node?${stringify(params)}`, {
+    signal,
+  });
 }
 
 export async function commitSheet(params) {

+ 4 - 2
src/utils/request.js

@@ -41,9 +41,9 @@ const checkStatus = response => {
   const error = new Error(response.data);
   error.name = response.status;
   error.response = response;
-  console.error(error)
+  console.error(error);
   // throw error;
-  return Promise.reject()
+  return Promise.reject();
 };
 
 const cachedSave = response => {
@@ -194,6 +194,8 @@ export default function request(url, option, jwt) {
         });
         router.push('/login');
         return;
+      } else if (status == 'AbortError') { // 中止的ajax 不做额外处理
+        return e;
       }
       // if (status <= 504 && status > 500 && status !== 600) {
       //   router.push('/exception/500');