Explorar el Código

Merge branch 'develop'

xjj hace 2 años
padre
commit
44dacaff8c
Se han modificado 4 ficheros con 136 adiciones y 133 borrados
  1. 57 5
      src/pages/Detail/AuditModal.js
  2. 28 10
      src/pages/Detail/FlowModal.js
  3. 30 8
      src/pages/Detail/Index.js
  4. 21 110
      src/pages/Detail/TimeNode.js

+ 57 - 5
src/pages/Detail/AuditModal.js

@@ -1,18 +1,69 @@
-import React, { useEffect } from 'react';
+import React, { useEffect, useMemo } from 'react';
 import { Form } from '@ant-design/compatible';
 import '@ant-design/compatible/assets/index.css';
 import { Modal, Input } from 'antd';
 
 // 审批意见
 function AuditModal(props) {
-  const { visible, onClose, onOk, form, sheetRef, loading } = props;
+  const { flow, version, flowDetail, visible, onClose, onOk, form, sheetRef, loading } = props;
 
   const handleOk = () => {
     form.validateFields((err, fieldsValue) => {
       if (err) return;
-      onOk(fieldsValue);
+      onOk({
+        ...fieldsValue,
+        // 3 通过审批   2 拒绝审批
+        audit_status: visible == 1 ? 3 : 2,
+      });
     });
   };
+
+  const content = useMemo(() => {
+    let content = '';
+    if (visible == 1) {
+      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
+          );
+        }
+      }
+      if (isSingle) {
+        return `节点【${serviceNode.label}】只能拥有一个清单,是否覆盖?`;
+      }
+    }
+    return '';
+  }, [visible]);
+
   useEffect(() => {
     if (visible) {
       try {
@@ -32,12 +83,13 @@ function AuditModal(props) {
     <Modal
       confirmLoading={loading}
       destroyOnClose
-      title="审批意见"
+      title={visible == 1 ? '是否确认通过审批?' : '是否确认拒绝审批?'}
       visible={visible}
       onCancel={onClose}
       onOk={handleOk}
     >
-      <Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="拒绝原因">
+      <p>{content}</p>
+      <Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="审批意见">
         {form.getFieldDecorator('audit_comment')(<Input.TextArea />)}
       </Form.Item>
     </Modal>

+ 28 - 10
src/pages/Detail/FlowModal.js

@@ -15,6 +15,7 @@ import {
   Cascader,
   AutoComplete,
   Spin,
+  Tooltip,
 } from 'antd';
 import Flow from '@/components/Flow/index';
 import { connect } from 'dva';
@@ -287,15 +288,15 @@ function FlowModal(props) {
           if (item.status == 1) txt = '已失效';
 
           // 显示拒绝原因
-          if (item.audit_comment) {
-            dom = (
-              <Popover content={item.audit_comment} title="原因">
-                {txt}
-              </Popover>
-            );
-          } else {
-            dom = txt;
-          }
+          // if (item.audit_comment) {
+          //   dom = (
+          //     <Popover content={item.audit_comment} title="原因">
+          //       {txt}
+          //     </Popover>
+          //   );
+          // } else {
+          dom = txt;
+          // }
           return item.audit_status != 0 ? (
             <Button onClick={() => handleChangeClick(item)}>{dom}</Button>
           ) : (
@@ -382,6 +383,23 @@ function FlowModal(props) {
     setInputValue(null);
   };
 
+  const getDescription = node => {
+    let str = `审批人:${node.AuditorUser?.CName || '-'}`;
+    if (node.desc) {
+      return (
+        <div>
+          {str}
+          <div>
+            <Tooltip title={node.desc}>
+              <span style={{ color: '#1A73E8', textDecoration: 'undeline' }}>审批意见</span>
+            </Tooltip>
+          </div>
+        </div>
+      );
+    }
+    return str;
+  };
+
   const filterState = () => {
     const childrens = data
       .map(item => (!item.flow_id && item.isParent ? item.children : item))
@@ -538,7 +556,7 @@ function FlowModal(props) {
                     <Step
                       key={`${node.id}_${node.node}`}
                       title={node.node}
-                      description={`审批人:${node.AuditorUser?.CName || '-'}`}
+                      description={getDescription(node)}
                     />
                   ))}
                 </Steps>

+ 30 - 8
src/pages/Detail/Index.js

@@ -59,6 +59,7 @@ function Detail(props) {
   const [compareVisible, setCompareVisible] = useState(false);
   const [exportVisible, setExportVisible] = useState(false);
   const [commitVisible, setCommitVisible] = useState(false);
+  // false 关闭  1=审批通过  2=审批拒绝
   const [auditVisible, setAuditVisible] = useState(false);
   const [flowVisible, setFlowVisible] = useState(false);
   const [versionVisible, setVersionVisible] = useState(false);
@@ -262,17 +263,17 @@ function Detail(props) {
     await queryDelSheetRecord(params);
   };
 
-  const onAudit = ({ audit_comment }) => {
+  const onAudit = ({ audit_comment, audit_status }) => {
     const flowNode = flow.currentNode;
     dispatch({
       type: 'detail/approve',
       payload: {
         id: flow.active_id,
         project_id: projectId,
-        audit_status: 2,
         flow_id: flowNode.flow_id,
         node_id: flowNode.seq,
         audit_comment,
+        audit_status,
       },
       callback: newVersion => {
         setAuditVisible(false);
@@ -283,17 +284,35 @@ function Detail(props) {
             id: templateId,
           },
         });
+        if (audit_status == 3) {
+          // 更新审批流
+          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,
+            },
+          });
+        } else {
+          dispatch({
+            type: 'authList/queryAuthList',
+            payloda: { user_id: currentUser.ID },
+          });
+          localStorage.excelId = newVersion.id;
+          setVersion({
+            ...version,
+            flow_id: newVersion.flow_id,
+            id: newVersion.id,
+          });
+        }
         //更新未审批列表
         dispatch({
           type: 'authList/queryAuthList',
           payloda: { user_id: currentUser.ID },
         });
-        localStorage.excelId = newVersion.id;
-        setVersion({
-          ...version,
-          flow_id: newVersion.flow_id,
-          id: newVersion.id,
-        });
       },
     });
   };
@@ -654,6 +673,9 @@ function Detail(props) {
         sheetRef={sheetRef}
         onClose={() => setAuditVisible(false)}
         onOk={onAudit}
+        flow={flow}
+        flowDetail={flowDetail}
+        version={version}
       />
       <VersionModal
         typeOptions={typeOptions}

+ 21 - 110
src/pages/Detail/TimeNode.js

@@ -2,7 +2,7 @@ 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, Modal } from 'antd';
+import { Steps, Button, Modal, Tooltip } from 'antd';
 import styles from './Index.less';
 import { getCurrentUser } from '@/utils/authority';
 
@@ -25,129 +25,40 @@ function TimeNode(props) {
   } = 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
-        );
-      }
+  const getDescription = node => {
+    let str = node?.AuditRoleInfo
+      ? `审批人:${node?.AuditRoleInfo.Name || '-'}`
+      : `审批人:${node?.AuditorUser.CName || '-'}`;
+    if (node.desc) {
+      return (
+        <div>
+          {str}
+          <div>
+            <Tooltip title={node.desc}>
+              <span style={{ color: '#1A73E8', textDecoration: 'undeline' }}>审批意见</span>
+            </Tooltip>
+          </div>
+        </div>
+      );
     }
-    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,
-              },
-            });
-
-            //更新未审核列表
-            dispatch({
-              type: 'authList/queryAuthList',
-              payload: { user_id: currentUser.ID },
-            });
-
-            if (flow.current == flow.list.FlowNodes.length - 1) {
-              // 最后一个审核节点通过后  需要更新version id 不更不更,留在原地
-              // localStorage.excelId = newVersion.id;
-              // setVersion({
-              //   ...version,
-              //   flow_id: newVersion.flow_id,
-              //   id: newVersion.id,
-              // });
-            }
-          },
-        });
-      },
-    });
+    return str;
   };
+
   if (!list || list.FlowNodes?.length != 0) {
     return (
       <div className={styles.top}>
         <Steps current={current} status={active == 0 ? 'error' : 'process'}>
           {list.FlowNodes.map(item => (
-            <Step
-              key={item.id}
-              title={item.node}
-              description={
-                item?.AuditRoleInfo
-                  ? `审批人:${item?.AuditRoleInfo.Name || '-'}`
-                  : `审批人:${item?.AuditorUser.CName || '-'}`
-              }
-            />
+            <Step key={item.id} title={item.node} description={getDescription(item)} />
           ))}
         </Steps>
         <div className={styles.btns} style={{ marginLeft: 80 }}>
           {isAuditor && active != 0 && (
             <>
-              <Button type="primary" onClick={() => onApprove(true)}>
+              <Button type="primary" onClick={() => setAuditVisible(1)}>
                 审批通过
               </Button>
-              <Button onClick={() => onApprove(false)} danger>
+              <Button onClick={() => setAuditVisible(2)} danger>
                 审批拒绝
               </Button>
             </>