Blame view

src/pages/Instalment/components/checkModal/TableCheckModal.tsx 2.78 KB
PurelzMgnead authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { postOrderErpOrderStagesCheckOrderStages } from '@/services';
import { ModalForm, ProFormTextArea } from '@ant-design/pro-components';
import { Button, Form, Space, message } from 'antd';

const waitTime = (time: number = 100) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};

export default ({ id, toReload, isShow }) => {
  const [form] = Form.useForm<{ mark: string }>();

  return (
    <Space>
      <ModalForm<{
        mark: string;
      }>
        title="账单审核"
        width={460}
        form={form}
        trigger={
          <Button type="primary" disabled={isShow}>
            批量审核
          </Button>
        }
        modalProps={{
          okText: '通过',
          cancelText: '驳回',
          destroyOnClose: true,
        }}
        submitter={{
          render: (props, defaultDoms) => {
            let myDoms = [];
            myDoms.push(
              <Button
                key="驳回"
                onClick={async () => {
                  if (id?.length === 0) {
                    message.error('没有可审核的订单');
                    toReload();
                  } else {
                    const res = await postOrderErpOrderStagesCheckOrderStages({
                      data: {
                        ids: id,
                        isPass: false,
                        mark: form.getFieldValue('mark'),
                      },
                    });
                    await waitTime(2000);
                    if (res.message === '成功') {
                      message.success('操作成功');
                    }
                    toReload();
                  }
PurelzMgnead authored
58
59
                  props.submit();
                  return true;
PurelzMgnead authored
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
                }}
              >
                驳回
              </Button>,
            );
            myDoms.push(defaultDoms[1]);
            return myDoms;
          },
        }}
        onFinish={async (values) => {
          if (id?.length === 0) {
            message.error('没有可审核的订单');
            return true;
          } else {
            const res = await postOrderErpOrderStagesCheckOrderStages({
              data: {
                ids: id,
                isPass: true,
                mark: values.mark,
              },
            });
            await waitTime(2000);
            if (res.message === '成功') {
              message.success('操作成功');
            }
            toReload();
            return true;
          }
        }}
      >
        <ProFormTextArea
          width="lg"
          name="mark"
          label="备注"
          tooltip="请特别注意订单总金额与订单金额。"
PurelzMgnead authored
95
          placeholder="如驳回请输入原因"
PurelzMgnead authored
96
97
98
99
100
        />
      </ModalForm>
    </Space>
  );
};