Parcourir la source

Merge branch 'draft' into develop

Renxy il y a 1 an
Parent
commit
2aed11456b

+ 2 - 2
.umirc.ts

@@ -40,8 +40,8 @@ export default defineConfig({
   proxy: {
     '/api': {
       // target: 'http://47.96.12.136:8888/',
-      // target: 'http://47.96.12.136:8895/',
-      target: 'https://work.greentech.com.cn/',
+      target: 'http://47.96.12.136:8895/',
+      // target: 'https://work.greentech.com.cn/',
       changeOrigin: true,
     },
   },

+ 90 - 0
src/pages/ContractManager/component/DraftModal.jsx

@@ -0,0 +1,90 @@
+import { Modal, Table, Space, Divider, message } from 'antd';
+import { useRequest, useModel } from '@umijs/max';
+import { queryContractDraft } from '@/services/contract';
+import { queryDelDraft } from '../../../services/contract';
+import { useEffect } from 'react';
+import { ExclamationCircleOutlined } from '@ant-design/icons';
+
+const DraftModal = ({ open, onCancel, onOk }) => {
+  const [modal, contextHolder] = Modal.useModal();
+  const columns = [
+    {
+      title: '合同名称',
+      dataIndex: 'name',
+      key: 'name',
+      width: 100,
+    },
+    {
+      title: '操作',
+      width: '40%',
+      align: 'center',
+      render: (record) => {
+        return (
+          <Space>
+            <a onClick={() => handlerOk(record)}>打开</a>
+            <a onClick={() => handleDel(record.id)}>删除</a>
+          </Space>
+        );
+      },
+    },
+  ];
+
+  const handleDel = (id) => {
+    modal.confirm({
+      icon: <ExclamationCircleOutlined />,
+      title: '提示:',
+      content: <div>确定删除草稿!</div>,
+      onOk: () => runDel({ id }),
+    });
+  };
+
+  useEffect(() => {
+    if (open) runList();
+  }, [open]);
+
+  const {
+    data,
+    loading,
+    run: runList,
+  } = useRequest(queryContractDraft, {
+    formatResult: (res) => {
+      if (res?.data) {
+        return res.data?.list;
+      }
+    },
+  });
+
+  const { run: runDel } = useRequest(queryDelDraft, {
+    manual: true,
+    onSuccess: (res) => {
+      message.success('删除成功');
+      runList();
+    },
+  });
+
+  const handlerOk = (record) => {
+    const data = JSON.parse(record.content);
+    onOk(data);
+  };
+
+  return (
+    <Modal
+      title="草稿箱"
+      open={open}
+      footer={null}
+      onCancel={onCancel}
+      onOk={onOk}
+      width={700}
+    >
+      <Table
+        dataSource={data}
+        columns={columns}
+        loading={loading}
+        pagination={false}
+      />
+      {contextHolder}
+    </Modal>
+  );
+};
+
+export default DraftModal;

+ 31 - 22
src/pages/ContractManager/component/Modal.jsx

@@ -38,7 +38,7 @@ export const Type = {
   add: 0, //新增
   detail: 1, //详情
   cancel: 2, //作废
-  check: 3, //审核
+  save: 3, //保存草稿
 };
 
 export const StatusText = [
@@ -147,18 +147,7 @@ const ContractModal = (props) => {
   const advance = {
     flow_id: 47,
     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:[],
   };
 
   //旧审批流兼容
@@ -552,6 +541,25 @@ const ContractModal = (props) => {
     });
   };
 
+  const handleSaveDraft = () => {
+    let values = form.getFieldsValue();
+    Object.keys(values).forEach((key) => {
+      if (Array.isArray(values[key]))
+        values[key].length == 0
+          ? delete values[key]
+          : (values[key] = JSON.stringify(values[key]));
+    });
+    if (values.effect_on)
+      values.effect_on = dayjs(values.effect_on).format(FORMAT);
+    const params = {
+      name: values.name,
+      content: JSON.stringify(values),
+    };
+    if (data?.id) params.id = data?.id;
+    console.log(values, params);
+    handleOk(params, Type.save);
+  };
+
   const getDepItemById = (id) => {
     const fun = (list) => {
       for (let i = 0; i < list.length; i++) {
@@ -600,6 +608,11 @@ const ContractModal = (props) => {
             修改
           </Button>
         )}
+        {type == Type.add && (
+          <Button type="primary" onClick={handleSaveDraft}>
+            保存草稿
+          </Button>
+        )}
         <Button type="primary" onClick={handleSubmit} disabled={!isSuper}>
           提交
         </Button>
@@ -787,7 +800,7 @@ const ContractModal = (props) => {
               <Form.Item
                 name="effect_on"
                 label="合同签订日期:"
-                initialValue={data?.effect_on}
+                initialValue={dayjs(data?.effect_on, FORMAT)}
                 tooltip="合同主体各方签字盖章完成之日,以最后签字盖章的为准"
                 rules={[
                   {
@@ -796,14 +809,10 @@ const ContractModal = (props) => {
                   },
                 ]}
               >
-                {type == Type.add ? (
-                  <DatePicker
-                    style={{ width: '100%' }}
-                    disabled={disableds.contract}
-                  />
-                ) : (
-                  <Input disabled={disableds.contract} />
-                )}
+                <DatePicker
+                  style={{ width: '100%' }}
+                  disabled={disableds.contract}
+                />
               </Form.Item>
               <Form.Item
                 name="project_name"
@@ -947,7 +956,7 @@ const ContractModal = (props) => {
             name="party_c"
             label="丙方(及其他):"
             tooltip="可多选。合同主体可以下拉选择,可选项需要经办人在“主页--供应商管理”中创建。经办人可以维护和更新供应商信息。"
-            initialValue={data?.party_c ? data?.party_c.split(',') : []}
+            initialValue={data?.party_c ? data?.party_c?.split(',') : []}
             labelCol={{ span: 4 }}
           >
             <Select

+ 39 - 2
src/pages/ContractManager/index.jsx

@@ -21,6 +21,7 @@ import {
   queryContractCancelCheck,
   queryContractCheck,
   queryContractDownload,
+  queryContractSaveDraft,
   queryDelById,
   queryGetContractList,
   queryOAReCall,
@@ -33,6 +34,7 @@ import EllipsisText from './component/EllipsisText';
 import { stringify } from 'qs';
 import { audit, createAduit } from '@/services/boom';
 import { ExclamationCircleOutlined } from '@ant-design/icons';
+import DraftModal from './component/DraftModal';
 
 const ConteactManager = (props) => {
   const { dispatch } = props;
@@ -56,6 +58,8 @@ const ConteactManager = (props) => {
   const [fileViewerData, setFileViewerData] = useState();
   const [modal, contextHolder] = Modal.useModal();
 
+  const [draftOpen, setDraftOpen] = useState(false);
+
   const showBtn = (record, type) => {
     let bool = false;
     switch (type) {
@@ -315,6 +319,18 @@ const ConteactManager = (props) => {
     },
   );
 
+  //保存草稿
+  const { run: saveDraftRun } = useRequest(
+    (data) => queryContractSaveDraft(data),
+    {
+      manual: true,
+      onSuccess: (res) => {
+        setVisible(false);
+        message.success('保存成功');
+      },
+    },
+  );
+
   const handleDelete = (id) => {
     modal.confirm({
       icon: <ExclamationCircleOutlined />,
@@ -375,6 +391,14 @@ const ConteactManager = (props) => {
     );
   };
 
+  const handleDraftOpen = (data) => {
+    console.log(data);
+    setDraftOpen(false);
+    typeRef.current = Type.add;
+    setDetail(data);
+    setVisible(true);
+  };
+
   const handleQueryChildren = async (req) => {
     const res = await queryGetContractList(req);
     if (res?.data?.list) {
@@ -414,12 +438,14 @@ const ConteactManager = (props) => {
         extend_code: data.code,
         extend_type: 0, //归档提交
       });
+    } else if (type == Type.save) {
+      saveDraftRun(data);
     }
   };
 
   const handlerReCall = async (id) => {
     modal.confirm({
-      icon: <ExclamationCircleOutlined />,
+      icon: <ExclamationCircleOutlined ined />,
       title: '提示:',
       content: <div>确定撤回合同存档审批!</div>,
       onOk: async () => {
@@ -427,7 +453,9 @@ const ConteactManager = (props) => {
         if (res.code == 200) {
           message.success('撤回成功');
           setVisible(false);
-          run(searchData);
+          setTimeout(() => {
+            run(searchData);
+          }, 1000);
         } else {
           message.success('撤回失败,请重试');
         }
@@ -515,6 +543,7 @@ const ConteactManager = (props) => {
         </Button>
         <Button
           type="primary"
+          className={styles.searchBtnSty}
           onClick={() => {
             typeRef.current = Type.add;
             setDetail({});
@@ -523,6 +552,9 @@ const ConteactManager = (props) => {
         >
           新增
         </Button>
+        <Button type="primary" onClick={() => setDraftOpen(true)}>
+          草稿箱
+        </Button>
         <Button
           type="primary"
           className={styles.exportBtnSty}
@@ -565,6 +597,11 @@ const ConteactManager = (props) => {
           setFileViewerVisible(false);
         }}
       />
+      <DraftModal
+        open={draftOpen}
+        onOk={handleDraftOpen}
+        onCancel={() => setDraftOpen(false)}
+      />
       {contextHolder}
     </PageContent>
   );

+ 21 - 0
src/services/contract.js

@@ -106,3 +106,24 @@ export const queryContractDetail = async (data) => {
     params: data,
   });
 };
+
+//保存草稿
+export const queryContractSaveDraft = async (data) => {
+  return await request('/api/contract/v1/draft', {
+    method: 'POST',
+    data,
+  });
+};
+//删除草稿?id=1
+export const queryDelDraft = async (data) => {
+  return await request(`/api/contract/v1/draft`, {
+    method: 'DELETE',
+    params: data,
+  });
+};
+//草稿列表/api/contract/v1/draft
+export const queryContractDraft = async (data) => {
+  return await request(`/api/contract/v1/draft`, {
+    params: data,
+  });
+};