Blame view

src/pages/Order/OrderWarning/components/ProcureCheckModal.tsx 3.8 KB
zhongnanhuang authored
1
2
3
import { RESPONSE_CODE } from '@/constants/enum';
import {
  postServiceOrderProcureCheckOrder,
zhongnanhuang authored
4
  postServiceOrderProcureConvertWarehouseKeeper,
zhongnanhuang authored
5
6
  postServiceOrderQuerySupplier,
} from '@/services';
7
8
9
10
11
import {
  ModalForm,
  ProFormSelect,
  ProFormTextArea,
} from '@ant-design/pro-components';
zhongnanhuang authored
12
13
import { Button, Form, Input, Popconfirm, message } from 'antd';
import { useState } from 'react';
zhongnanhuang authored
14
export default ({ setCheckVisible, isMainOrder, orders, onClose }) => {
15
  const [form] = Form.useForm<{ supplier: string }>();
zhongnanhuang authored
16
17
  const [checkNotes, setCheckNotes] = useState<string>('');
18
19
  console.log(isMainOrder);
zhongnanhuang authored
20
  let ids: any[] = orders.map((order: any) => order.id);
zhongnanhuang authored
21
22
23
24
25
26
27
28
29
30
31
32
  async function doCheck(body: object) {
    const data = await postServiceOrderProcureCheckOrder({
      data: body,
    });
    if (data.result === RESPONSE_CODE.SUCCESS) {
      message.success(data.message);
      onClose();
    }
  }

  return (
    <ModalForm<{
33
      supplier: string;
zhongnanhuang authored
34
35
36
    }>
      width={500}
      open
zhongnanhuang authored
37
      title="采购审核"
zhongnanhuang authored
38
39
40
41
42
43
44
45
46
47
48
49
      form={form}
      autoFocusFirstInput
      modalProps={{
        okText: '确认',
        cancelText: '取消',
        destroyOnClose: true,
        onCancel: () => {
          setCheckVisible(false);
        },
      }}
      submitter={{
        render: (props, defaultDoms) => {
zhongnanhuang authored
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
          return [
            defaultDoms[0],
            <>
              <Popconfirm
                title="是否转回仓库"
                description={
                  <div>
                    <div className="py-2">
                      <span>转回仓库后将由仓库管理员进行打印、发货</span>
                    </div>
                    <Input.TextArea
                      placeholder="请填写备注"
                      onChange={(e: any) => {
                        setCheckNotes(e.target.value);
                      }}
                      rows={4}
                    ></Input.TextArea>
                  </div>
                }
                onConfirm={async () => {
zhongnanhuang authored
70
71
                  let res = await postServiceOrderProcureConvertWarehouseKeeper(
                    {
zhongnanhuang authored
72
                      data: {
73
                        subIds: ids,
zhongnanhuang authored
74
75
                        checkNotes: checkNotes,
                      },
zhongnanhuang authored
76
77
                    },
                  );
zhongnanhuang authored
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

                  if (res?.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    onClose();
                    return true;
                  }
                }}
                okText="确定"
                cancelText="取消"
              >
                <Button type="primary">转回仓库</Button>
              </Popconfirm>
            </>,
            defaultDoms[1],
          ];
zhongnanhuang authored
93
94
95
96
        },
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
97
        if (values.supplier === '0') {
98
99
100
          message.error('选择转回仓库请点击转回仓库按钮!');
          return;
        }
zhongnanhuang authored
101
        let procureIsPrintAndSend = true;
zhongnanhuang authored
102
103
104
105
106
        return doCheck({
          ...values,
          subOrderIds: ids,
          procureIsPrintAndSend: procureIsPrintAndSend,
        });
zhongnanhuang authored
107
108
109
110
111
      }}
      onOpenChange={setCheckVisible}
    >
      <ProFormSelect
        key="key"
zhongnanhuang authored
112
        label="采购名称"
zhongnanhuang authored
113
        width="lg"
114
        name="supplier"
zhongnanhuang authored
115
        // options={options}
zhongnanhuang authored
116
117
        placeholder="请选择采购"
        rules={[{ required: true, message: '采购名称必填' }]}
zhongnanhuang authored
118
119
        request={async () => {
          const res = await postServiceOrderQuerySupplier();
120
          let options = res.data?.map((item) => {
zhongnanhuang authored
121
122
            return { label: item, value: item };
          });
123
124
          options.push({ label: '转回仓库', value: '0' });
          return options;
zhongnanhuang authored
125
126
        }}
      />
127
128

      <ProFormTextArea label="备注" name="procureNotes" key="procureNotes" />
zhongnanhuang authored
129
130
131
    </ModalForm>
  );
};