Sfoglia il codice sorgente

修改合同预览/修改合同相关

Renxy 2 anni fa
parent
commit
538958cebf

+ 4 - 0
src/components/FileViewerNew/index.js

@@ -2,6 +2,9 @@ import React, { useState, useEffect } from 'react';
 import FileViewer from 'react-file-viewer';
 import { Modal, Table } from 'antd';
 
+//data 为数组传 [{name:'', type:'传文件类型(jpg/png/xlsx等)' url:''}]
+// data 为单个文件传 [{name:'', type:'传描述信息', url:''}]
+
 const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
   const [img, setImg] = useState();
   useEffect(() => {
@@ -39,6 +42,7 @@ const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
   const renderListContent = () => {
     const columns = [
       { title: '文档名称', dataIndex: 'name' },
+      { title: '文件类型', dataIndex: 'type' },
       {
         title: '操作',
         render: (_, record) => (

+ 115 - 38
src/pages/ContractManager/component/Modal.jsx

@@ -23,11 +23,12 @@ import {
   queryDepList,
   querySupplierList,
 } from '@/services/contract';
-import { useModel, useRequest } from '@umijs/max';
+import { request, useModel, useRequest } from '@umijs/max';
 import { CloudUploadOutlined } from '@ant-design/icons';
 import styles from '../index.less';
 import dayjs from 'dayjs';
 import InputSelect from '../../../components/InputSelect';
+import { advanceSubmitNextNode } from '@/services/boom';
 export const Type = {
   add: 0, //新增
   detail: 1, //详情
@@ -61,6 +62,7 @@ const ContractModal = (props) => {
   } = useModel('@@initialState');
   const { userList, run: userListRun } = useModel('userList');
   const { depList, run: depListRun } = useModel('depList');
+  // const [auditList, setAuditList] = useState([]);
   const FORMAT = 'YYYY-MM-DD';
   const {
     detail: data,
@@ -72,8 +74,69 @@ const ContractModal = (props) => {
     parent_id,
     handlePreView,
   } = props;
+
+  //审批流拼接
+  const audit = {
+    flow_id: 40,
+    form: '[{"name":"是否本部","id":"DDSelectField_4fbddb04-9b4f-4281-991b-5047f835fb9d","type":"DDSelectField","value":["是"]},{"name":"单选框","id":"DDSelectField_1235c6b9-9d74-4856-a62d-6ca1bb9716a6","type":"DDSelectField","value":["财务部"]}]',
+    audit_list: [430, 256],
+    cc_list: [],
+    files: '',
+  };
+  const formData = [
+    {
+      id: 'TextField_1a01000b-4458-4dfb-bd13-74a74e7a33e5',
+      name: '合同id',
+      type: 'TextField',
+      value: ['1'],
+    },
+    {
+      name: '是否本部',
+      id: 'DDSelectField_4fbddb04-9b4f-4281-991b-5047f835fb9d',
+      type: 'DDSelectField',
+      value: ['是'],
+    },
+    {
+      name: '单选框',
+      id: 'DDSelectField_1235c6b9-9d74-4856-a62d-6ca1bb9716a6',
+      type: 'DDSelectField',
+      value: ['财务部'],
+    },
+  ];
+
+  //计算审批流数据
+  const advance = {
+    flow_id: 40,
+    form_list: null,
+    // node_level_id:0,
+    // id:0,
+    // project_id:0,
+    // cur_template_node_id:0,
+    // next_template_node_id:0,
+    // template_node_id:0,
+    // flow_path:null,
+    // template_id:0,
+    // cur_template_id:0,
+    // next_template_id:0,
+    formComponentValues: '',
+    // audit_list:[],
+  };
+
+  const { run } = useRequest((data) => advanceSubmitNextNode(data), {
+    debounceInterval: 500,
+    manual: true,
+    formatResult(res) {
+      setAuditList(
+        res.data[0]?.map((item) => {
+          const name = userList.find((user) => user.ID == item.value)?.CName;
+          return { ...item, name };
+        }),
+      );
+    },
+  });
+
   const title =
-    type == Type.add ? '新增' : type == Type.detail ? '详情' : '作废';
+    type == Type.add ? '新增' : type == Type.cancel ? '作废' : '详情';
   //所属公司为总部时才能选择部门,为子公司时,部门不能操作  所属部门为子公司的需要填经办人
   const company = Form.useWatch('company_id', form);
   const [depDisable, setDepDisable] = useState(false);
@@ -86,12 +149,22 @@ const ContractModal = (props) => {
 
   const [isPass, setIsPass] = useState(1);
 
-  const [fileList, setFileList] = useState([]);
-  const [fileExtendList, setFileExtendList] = useState([]);
-
   const { data: companyData, run: runCompany } = useRequest(queryCompany);
 
-  console.log(user, data, depList);
+  //获取审批流逻辑
+  // const archives_dep = Form.useWatch('archives_dep', form);
+  // useEffect(() => {
+  //   if (!company || !archives_dep) return;
+  //   const param = { ...advance };
+  //   const formValus = JSON.parse(JSON.stringify(formData));
+  //   const item = companyData?.find((item) => item.ID == company);
+  //   formValus[1].value = item?.Flag == 1 ? ['是'] : ['否'];
+  //   formValus[2].value = [archives_dep];
+  //   param.formComponentValues = formValus;
+  //   run(param);
+  // }, [company, archives_dep]);
+
+  // console.log(user, data, depList);
 
   useEffect(() => {
     userListRun();
@@ -139,7 +212,6 @@ const ContractModal = (props) => {
         created_dep: '',
         deal_by: user?.CName,
       });
-      // setDealDisable(false);
     } else {
       setDepDisable(true);
       form.setFieldsValue({
@@ -148,8 +220,6 @@ const ContractModal = (props) => {
         created_dep: '综合管理部',
         deal_by: '',
       });
-      // setDealDisable(true);
-      // form.setFieldsValue({ deal_by: user?.CName });
     }
   }, [company]);
   useEffect(() => {
@@ -162,11 +232,6 @@ const ContractModal = (props) => {
       form.setFieldsValue({ project_code: '' });
     }
   }, [project_name]);
-
-  // useEffect(() => {
-  //   console.log('==================', is_supplement);
-  // }, [is_supplement]);
-
   const supplyList = useMemo(() => {
     return companyData ? [...companyData, ...supplierList] : supplierList;
   }, [companyData, supplierList]);
@@ -199,7 +264,6 @@ const ContractModal = (props) => {
         console.log(file, fileList);
         const list = fileList.map((item) => item.response?.data?.attach);
         form.setFieldsValue({ attach: list });
-        setFileList(fileList.map((item) => item.response?.data?.attach));
       }
     },
   };
@@ -211,7 +275,8 @@ const ContractModal = (props) => {
     onChange({ file, fileList }) {
       if (file.status !== 'uploading') {
         console.log(file, fileList);
-        setFileExtendList(fileList.map((item) => item.response?.data?.attach));
+        const list = fileList.map((item) => item.response?.data?.attach);
+        form.setFieldsValue({ attach_extend: list });
       }
     },
   };
@@ -225,8 +290,8 @@ const ContractModal = (props) => {
         if (values.amount || values.amount == 0)
           values.amount = values.amount + '';
         if (values.attach) values.attach = JSON.stringify(values.attach);
-        if (fileExtendList.length > 0)
-          values.attach_extend = JSON.stringify(fileList);
+        if (values.attach_extend)
+          values.attach_extend = JSON.stringify(values.attach_extend);
 
         // if (values.party_c && values.party_c.length > 0)
         values.party_c = values.party_c?.join(',');
@@ -366,7 +431,7 @@ const ContractModal = (props) => {
             <Form.Item
               name="dep_id"
               label="所属部门:"
-              initialValue={data?.dep_id}
+              initialValue={data?.dep_id || data?.dep_name}
             >
               <TreeSelect
                 style={{ width: '100%' }}
@@ -710,21 +775,14 @@ const ContractModal = (props) => {
                   <Button icon={<CloudUploadOutlined />}>Upload</Button>
                 </Upload>
               ) : (
-                <Space>
-                  <ul>
-                    {data?.attach &&
-                      JSON.parse(data?.attach)?.map((item, idx) => (
-                        <li key={`${idx}_${item.name}`}>{item.name}</li>
-                      ))}
-                  </ul>
-                  <a
-                    onClick={() => {
-                      handlePreView(data);
-                    }}
-                  >
-                    预览
-                  </a>
-                </Space>
+                <ul>
+                  {data?.attach &&
+                    JSON.parse(data?.attach)?.map((item, idx) => (
+                      <li key={`${idx}_${item.name}`}>
+                        <a onClick={() => handlePreView(item)}>{item.name}</a>
+                      </li>
+                    ))}
+                </ul>
               )}
             </Form.Item>
             <Form.Item
@@ -732,6 +790,12 @@ const ContractModal = (props) => {
               initialValue={data?.archives_dep}
               label="合同原件存档部门:"
               tooltip="母公司财务部和采购部门的合同请选择“财务部”,其他部门请选择“行政部”,子公司合同选择“综合管理部”"
+              rules={[
+                {
+                  required: true,
+                  message: '请选择合同原件存档部门',
+                },
+              ]}
             >
               <Select
                 style={{ width: '100%' }}
@@ -751,6 +815,7 @@ const ContractModal = (props) => {
           </Col>
           <Col span={10}>
             <Form.Item
+              name="attach_extend"
               label="合同相关资料上传:"
               tooltip={
                 <div>
@@ -778,10 +843,7 @@ const ContractModal = (props) => {
                   {data?.attach_extend &&
                     JSON.parse(data?.attach_extend)?.map((item, idx) => (
                       <li key={`${idx}_${item.name}`}>
-                        {/* <Space>
-                          {item.name} <span>预览</span>{' '}
-                          <a href={item.url}>下载</a>
-                        </Space> */}
+                        <a onClick={() => handlePreView(item)}>{item.name}</a>
                       </li>
                     ))}
                 </ul>
@@ -1031,6 +1093,21 @@ const ContractModal = (props) => {
             )}
           </>
         )}
+        {/* {auditList.length > 0 && (
+          <>
+            <ModuleTitle title="审批流程" />
+            <div className={styles.modelItem}>
+              <Steps
+                current={1}
+                items={auditList.map((item) => {
+                  return {
+                    title: item.name,
+                  };
+                })}
+              />
+            </div>
+          </>
+        )} */}
       </Form>
       <Divider />
     </Modal>

+ 29 - 5
src/pages/ContractManager/index.jsx

@@ -318,10 +318,34 @@ const ConteactManager = (props) => {
     defaultParams: [{ pageSize: 99999 }],
   });
 
-  const handlePreView = (record) => {
-    if (!record.attach) return;
-    const attach = JSON.parse(record.attach);
-    setFileViewerData(attach);
+  const handlePreView = (data) => {
+    // if (!data) return;
+    // const attach = JSON.parse(data);
+    // setFileViewerData(attach);
+    // setFileViewerVisible(true);
+    if (!data?.attach || !data?.attach_extend) return;
+    const result = [];
+    if (data?.attach) {
+      const attach = JSON.parse(data?.attach);
+      attach.forEach((item) => {
+        result.push({ ...item, type: '合同及合同附件' });
+      });
+    }
+    if (data?.attach_extend) {
+      const attach_extend = JSON.parse(data?.attach_extend);
+      attach_extend.forEach((item) => {
+        result.push({ ...item, type: '合同相关资料' });
+      });
+    }
+    setFileViewerData(result);
+    setFileViewerVisible(true);
+  };
+  const handlePreViewSingle = (data) => {
+    if (!data) return;
+    const arr = data.name.split('.');
+    const type = arr[arr.length - 1];
+    const dataItem = { url: data.url, name: data.name, type };
+    setFileViewerData(dataItem);
     setFileViewerVisible(true);
   };
   //单个合同下载
@@ -488,7 +512,7 @@ const ConteactManager = (props) => {
         projectList={projectData?.list}
         visible={visible}
         handleOk={handleOk}
-        handlePreView={handlePreView}
+        handlePreView={handlePreViewSingle}
         handleCancel={() => setVisible(false)}
       />
       <FileViewerModal