Renxy 1 ano atrás
pai
commit
765a853c2b

+ 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,
     },
   },

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

@@ -0,0 +1,67 @@
+import { Modal, Table, Space, Divider } from 'antd';
+import { useRequest, useModel } from '@umijs/max';
+import { queryContractDraft } from '@/services/contract';
+import { queryDelDraft } from '../../../services/contract';
+
+const DraftModal = ({ open, onCancel, onOk }) => {
+  const columns = [
+    {
+      title: '合同签订时间',
+      dataIndex: 'effect_on',
+      key: 'effect_on',
+      align: 'center',
+      width: 120,
+    },
+    {
+      title: '合同名称',
+      dataIndex: 'name',
+      key: 'name',
+      align: 'center',
+      width: 100,
+    },
+    {
+      title: '操作',
+      width: '210px',
+      align: 'center',
+      render: (record) => {
+        return (
+          <Space>
+            <a onClick={() => onOk(record)}>打开</a>
+            <a onClick={() => runDel({ id: record.id })}>删除</a>
+          </Space>
+        );
+      },
+    },
+  ];
+
+  const { data, loading } = useRequest(queryContractDraft, {
+    formatResult: (res) => {
+      if (res?.data) {
+        return res.data?.list;
+      }
+    },
+  });
+
+  const { run: runDel } = useRequest(queryDelDraft, {
+    onSuccess: (res) => {},
+  });
+
+  return (
+    <Modal
+      title="草稿箱"
+      open={open}
+      footer={null}
+      onCancel={onCancel}
+      onOk={onOk}
+    >
+      <Table
+        dataSource={data}
+        columns={columns}
+        loading={loading}
+        pagination={false}
+      />
+    </Modal>
+  );
+};
+
+export default DraftModal;

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

@@ -65,10 +65,8 @@ let isInLine = location.host.includes('work.greentech.com');
 
 const ContractModal = (props) => {
   const [form] = Form.useForm();
-  const {
-    initialState,
-  } = useModel('@@initialState');
-  const user = initialState?.user || {}
+  const { initialState } = useModel('@@initialState');
+  const user = initialState?.user || {};
   const { userList, run: userListRun } = useModel('userList');
   const { depList, run: depListRun } = useModel('depList');
   const [auditList, setAuditList] = useState([]);
@@ -178,18 +176,7 @@ const ContractModal = (props) => {
   const advance = {
     flow_id: isInLine ? 47 : 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:[],
   };
 
   //旧审批流兼容
@@ -583,6 +570,10 @@ const ContractModal = (props) => {
     });
   };
 
+  const handleSaveDraft = () => {
+    console.log(form.getFieldsValue());
+  };
+
   const getDepItemById = (id) => {
     const fun = (list) => {
       for (let i = 0; i < list.length; i++) {
@@ -631,6 +622,9 @@ const ContractModal = (props) => {
             修改
           </Button>
         )}
+        <Button type="primary" onClick={handleSaveDraft}>
+          保存草稿
+        </Button>
         <Button type="primary" onClick={handleSubmit} disabled={!isSuper}>
           提交
         </Button>

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

@@ -33,6 +33,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;
@@ -44,10 +45,8 @@ const ConteactManager = (props) => {
     current: 1,
     name: '',
   });
-  const {
-    initialState,
-  } = useModel('@@initialState');
-  const user = initialState?.user || {}
+  const { initialState } = useModel('@@initialState');
+  const user = initialState?.user || {};
   const [visible, setVisible] = useState(false);
   const [detail, setDetail] = useState({});
   const [data, setData] = useState([]);
@@ -58,6 +57,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) {
@@ -377,6 +378,12 @@ const ConteactManager = (props) => {
     );
   };
 
+  const handleDraftOpen = (data) => {
+    setDraftOpen(false);
+    setDetail(data);
+    setVisible(true);
+  };
+
   const handleQueryChildren = async (req) => {
     const res = await queryGetContractList(req);
     if (res?.data?.list) {
@@ -421,7 +428,7 @@ const ConteactManager = (props) => {
 
   const handlerReCall = async (id) => {
     modal.confirm({
-      icon: <ExclamationCircleOutlined />,
+      icon: <ExclamationCircleOutl ined />,
       title: '提示:',
       content: <div>确定撤回合同存档审批!</div>,
       onOk: async () => {
@@ -517,6 +524,7 @@ const ConteactManager = (props) => {
         </Button>
         <Button
           type="primary"
+          className={styles.searchBtnSty}
           onClick={() => {
             typeRef.current = Type.add;
             setDetail({});
@@ -525,6 +533,9 @@ const ConteactManager = (props) => {
         >
           新增
         </Button>
+        <Button type="primary" onClick={() => setDraftOpen(true)}>
+          草稿箱
+        </Button>
         <Button
           type="primary"
           className={styles.exportBtnSty}
@@ -567,6 +578,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,
+  });
+};