|  | @@ -1,17 +1,13 @@
 | 
	
		
			
				|  |  | -import { Modal, Table, Space, Divider } from 'antd';
 | 
	
		
			
				|  |  | +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: 'effect_on',
 | 
	
		
			
				|  |  | -      key: 'effect_on',
 | 
	
		
			
				|  |  | -      align: 'center',
 | 
	
		
			
				|  |  | -      width: 120,
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '合同名称',
 | 
	
		
			
				|  |  |        dataIndex: 'name',
 | 
	
	
		
			
				|  | @@ -21,20 +17,37 @@ const DraftModal = ({ open, onCancel, onOk }) => {
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        title: '操作',
 | 
	
		
			
				|  |  | -      width: '210px',
 | 
	
		
			
				|  |  | +      width: '40%',
 | 
	
		
			
				|  |  |        align: 'center',
 | 
	
		
			
				|  |  |        render: (record) => {
 | 
	
		
			
				|  |  |          return (
 | 
	
		
			
				|  |  |            <Space>
 | 
	
		
			
				|  |  | -            <a onClick={() => onOk(record)}>打开</a>
 | 
	
		
			
				|  |  | -            <a onClick={() => runDel({ id: record.id })}>删除</a>
 | 
	
		
			
				|  |  | +            <a onClick={() => handlerOk(record)}>打开</a>
 | 
	
		
			
				|  |  | +            <a onClick={() => handleDel(record.id)}>删除</a>
 | 
	
		
			
				|  |  |            </Space>
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const { data, loading } = useRequest(queryContractDraft, {
 | 
	
		
			
				|  |  | +  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;
 | 
	
	
		
			
				|  | @@ -43,9 +56,18 @@ const DraftModal = ({ open, onCancel, onOk }) => {
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const { run: runDel } = useRequest(queryDelDraft, {
 | 
	
		
			
				|  |  | -    onSuccess: (res) => {},
 | 
	
		
			
				|  |  | +    manual: true,
 | 
	
		
			
				|  |  | +    onSuccess: (res) => {
 | 
	
		
			
				|  |  | +      message.success('删除成功');
 | 
	
		
			
				|  |  | +      runList();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  const handlerOk = (record) => {
 | 
	
		
			
				|  |  | +    const data = JSON.parse(record.content);
 | 
	
		
			
				|  |  | +    onOk(data);
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return (
 | 
	
		
			
				|  |  |      <Modal
 | 
	
		
			
				|  |  |        title="草稿箱"
 | 
	
	
		
			
				|  | @@ -53,6 +75,7 @@ const DraftModal = ({ open, onCancel, onOk }) => {
 | 
	
		
			
				|  |  |        footer={null}
 | 
	
		
			
				|  |  |        onCancel={onCancel}
 | 
	
		
			
				|  |  |        onOk={onOk}
 | 
	
		
			
				|  |  | +      width={500}
 | 
	
		
			
				|  |  |      >
 | 
	
		
			
				|  |  |        <Table
 | 
	
		
			
				|  |  |          dataSource={data}
 | 
	
	
		
			
				|  | @@ -60,6 +83,7 @@ const DraftModal = ({ open, onCancel, onOk }) => {
 | 
	
		
			
				|  |  |          loading={loading}
 | 
	
		
			
				|  |  |          pagination={false}
 | 
	
		
			
				|  |  |        />
 | 
	
		
			
				|  |  | +      {contextHolder}
 | 
	
		
			
				|  |  |      </Modal>
 | 
	
		
			
				|  |  |    );
 | 
	
		
			
				|  |  |  };
 |