Ver código fonte

feat(合同管理): 新增处于[审核拒绝]状态的合同,可编辑后重新提交审核

ZhaoJun 1 ano atrás
pai
commit
458dc599d2

+ 71 - 15
src/pages/ContractManager/component/Modal.jsx

@@ -109,6 +109,9 @@ const ContractModal = (props) => {
   const project_name = Form.useWatch('project_name', form);
   const archives_dep = Form.useWatch('archives_dep', form);
 
+  // 当为审核拒绝状态时,点击编辑按钮可以时为强制修改状态
+  const [forceModify, setForceModify] = useState(false);
+
   //是否补充协议,是的话需要填合同编号
   const is_supplement = Form.useWatch('is_supplement', form);
 
@@ -242,6 +245,7 @@ const ContractModal = (props) => {
       },
     },
   );
+
   //计算合同编号接口
   const { run: runCode } = useRequest((data) => queryContractCode(data), {
     manual: true,
@@ -251,6 +255,7 @@ const ContractModal = (props) => {
       });
     },
   });
+
   //供应商列表
   const { data: supplierList = [], loading } = useRequest(querySupplierList, {
     defaultParams: [
@@ -269,6 +274,7 @@ const ContractModal = (props) => {
         : [];
     },
   });
+
   //获取OA 归档审批列表
   const { data: auditData, run: runAudit } = useRequest(
     (data) => queryAuditByCode({ ...data, extend_type: 0 }),
@@ -286,6 +292,7 @@ const ContractModal = (props) => {
       },
     },
   );
+
   //获取OA 作废审批列表
   const { data: auditCelData, run: runCalAudit } = useRequest(
     (data) => queryAuditByCode({ ...data, extend_type: 1 }),
@@ -344,7 +351,8 @@ const ContractModal = (props) => {
     if (
       type == Type.add ||
       type == Type.cancel ||
-      data?.status == Status.ReCall
+      data?.status == Status.ReCall ||
+      (data?.status == Status.CheckReject && forceModify)
     )
       return true;
     let currentAuditUserID;
@@ -357,10 +365,15 @@ const ContractModal = (props) => {
     }
     if (user.ID == currentAuditUserID) return true;
     return false;
-  }, [user, data, auditData, auditCelData]);
+  }, [user, data, auditData, auditCelData, forceModify]);
 
   useEffect(() => {
-    if (type !== Type.add && data?.status !== Status.ReCall) return;
+    if (
+      type !== Type.add &&
+      data?.status !== Status.ReCall &&
+      data?.status !== Status.CheckReject
+    )
+      return;
     const newCompony = company || data?.company_id; //recall状态时compony是空, 需要用data?.company_id
     if (!newCompony) {
       setCompanyDepList([]);
@@ -383,7 +396,7 @@ const ContractModal = (props) => {
       setArchivesDepList(deps);
       form.setFieldsValue({ deal_by: '' });
     }
-  }, [company, data]);
+  }, [company, data, forceModify]);
 
   //获取合同编号逻辑 只有新增才请求
   useEffect(() => {
@@ -403,7 +416,12 @@ const ContractModal = (props) => {
 
   //获取审批流逻辑
   useEffect(() => {
-    if (type !== Type.add && data?.status !== Status.ReCall) return;
+    if (
+      type !== Type.add &&
+      data?.status !== Status.ReCall &&
+      data?.status !== Status.CheckReject
+    )
+      return;
     const param = { ...advance };
     let formValues = [];
     const item = companyData?.find((item) => item.ID == company);
@@ -418,7 +436,12 @@ const ContractModal = (props) => {
   }, [company, archives_dep]);
 
   useEffect(() => {
-    if (type !== Type.add && data?.status !== Status.ReCall) return;
+    if (
+      type !== Type.add &&
+      data?.status !== Status.ReCall &&
+      data?.status !== Status.CheckReject
+    )
+      return;
     const project_code = projectList?.find(
       (item) => item.project_name == project_name,
     )?.project_full_code;
@@ -428,15 +451,24 @@ const ContractModal = (props) => {
       form.setFieldsValue({ project_code: '' });
     }
   }, [project_name]);
+
   const supplyList = useMemo(() => {
     return companyData ? [...companyData, ...supplierList] : supplierList;
   }, [companyData, supplierList]);
 
   const disableds = useMemo(() => {
-    if (data?.status == Status.ReCall) return { contract: false, recall: true };
-    if (data?.status > Status.None) return { contract: true, recall: true };
+    // 当合同处于审核拒绝状态时,通过修改按钮可强制修改合同并重新进入审核
+    if (forceModify && data?.status == Status.CheckReject) {
+      return { contract: false, recall: false };
+    }
+    if (data?.status == Status.ReCall) {
+      return { contract: false, recall: true };
+    }
+    if (data?.status > Status.None) {
+      return { contract: true, recall: true };
+    }
     return { contract: false, recall: false };
-  }, [visible]);
+  }, [visible, forceModify]);
 
   const UploadProps = {
     action: `/api/contract/v1/attach`,
@@ -451,6 +483,7 @@ const ContractModal = (props) => {
       }
     },
   };
+
   const UploadPropsExtend = {
     action: `/api/contract/v1/attach`,
     headers: {
@@ -513,7 +546,10 @@ const ContractModal = (props) => {
           code: data?.code,
         };
         handleOk(result, Type.cancel, form, audit_list);
-      } else if (data?.status == Status.ReCall) {
+      } else if (
+        data?.status == Status.ReCall ||
+        data?.status == Status.CheckReject
+      ) {
         const form = getAuditData(values, '1');
         const audit_list = auditList.map((item) => item.value);
         values.effect_on = dayjs(values.effect_on).format(FORMAT);
@@ -583,13 +619,31 @@ const ContractModal = (props) => {
         {data?.status == Status.Checking && type !== Type.check && (
           <Button onClick={() => handlerReCall(auditData?.id)}>撤回</Button>
         )}
-        <Button onClick={handleCancel}>取消</Button>
+        <Button
+          onClick={() => {
+            setForceModify(false);
+            form.resetFields();
+            handleCancel();
+          }}
+        >
+          取消
+        </Button>
+        {data?.status == Status.CheckReject && !forceModify && (
+          <Button
+            onClick={() => {
+              setForceModify(true);
+            }}
+          >
+            修改
+          </Button>
+        )}
         <Button type="primary" onClick={handleSubmit} disabled={!isSuper}>
           提交
         </Button>
       </Space>
     );
   };
+
   return (
     <>
       <Modal
@@ -974,7 +1028,9 @@ const ContractModal = (props) => {
                 }
                 initialValue={attachData.attach}
               >
-                {type == Type.add || data?.status == Status.ReCall ? (
+                {type == Type.add ||
+                data?.status == Status.ReCall ||
+                forceModify ? (
                   <Upload {...UploadProps}>
                     <Button icon={<CloudUploadOutlined />}>Upload</Button>
                   </Upload>
@@ -1034,7 +1090,7 @@ const ContractModal = (props) => {
                   </div>
                 }
               >
-                {type == Type.add ? (
+                {type == Type.add || forceModify ? (
                   <Upload {...UploadPropsExtend}>
                     <Button icon={<CloudUploadOutlined />}>Upload</Button>
                   </Upload>
@@ -1054,7 +1110,7 @@ const ContractModal = (props) => {
             </Col>
           </Row>
 
-          {data?.status >= Status.Checking && (
+          {data?.status >= Status.Checking && !forceModify && (
             <>
               <ModuleTitle title="归档流程" />
               <div className={styles.modelItem}>
@@ -1212,7 +1268,7 @@ const ContractModal = (props) => {
               )}
             </>
           )}
-          {(type == Type.add || data?.status == Status.ReCall) &&
+          {(type == Type.add || data?.status == Status.ReCall || forceModify) &&
             auditList.length > 0 && (
               <>
                 <ModuleTitle title="审批流程" />

+ 13 - 1
src/pages/ContractManager/index.jsx

@@ -442,6 +442,14 @@ const ConteactManager = (props) => {
       });
     } else if (type == Type.check) {
       runOACheck(data);
+    } else if (type == Type.modify) {
+      calRun(data);
+      createRun({
+        form: JSON.stringify(formData),
+        audit_list,
+        extend_code: data.code,
+        extend_type: 0, //归档提交
+      });
     }
   };
 
@@ -569,7 +577,11 @@ const ConteactManager = (props) => {
           console.log(expanded, record);
           if (expanded) handleQueryChildren({ is_parent: record.id });
         }}
-        pagination={{ ...pagination, showSizeChanger: false, onChange: onPageChange }}
+        pagination={{
+          ...pagination,
+          showSizeChanger: false,
+          onChange: onPageChange,
+        }}
       />
       <ContractModal
         detail={detail}