Commit 04a315349e69410a53cbabe92ec44336718893ec
1 parent
2ca7483f
feat: update
Showing
1 changed file
with
77 additions
and
0 deletions
src/pages/Order/components/ProcureCheckModal.tsx
0 → 100644
1 | +import { RESPONSE_CODE } from '@/constants/enum'; | |
2 | +import { | |
3 | + postServiceOrderProcureCheckOrder, | |
4 | + postServiceOrderQuerySupplier, | |
5 | +} from '@/services'; | |
6 | +import { ModalForm, ProFormSelect } from '@ant-design/pro-components'; | |
7 | +import { Form, message } from 'antd'; | |
8 | +export default ({ setCheckVisible, data, subOrders, onClose }) => { | |
9 | + const [form] = Form.useForm<{ name: string; company: string }>(); | |
10 | + let subOrderIds: any[] = []; | |
11 | + //是单条子订单审核 | |
12 | + if (subOrders === undefined) { | |
13 | + subOrderIds = [data.id]; | |
14 | + } else { | |
15 | + subOrderIds = subOrders.map((subOrder) => subOrder.id); | |
16 | + } | |
17 | + async function doCheck(body: object) { | |
18 | + const data = await postServiceOrderProcureCheckOrder({ | |
19 | + data: body, | |
20 | + }); | |
21 | + if (data.result === RESPONSE_CODE.SUCCESS) { | |
22 | + message.success(data.message); | |
23 | + onClose(); | |
24 | + } | |
25 | + } | |
26 | + | |
27 | + return ( | |
28 | + <ModalForm<{ | |
29 | + name: string; | |
30 | + company: string; | |
31 | + }> | |
32 | + width={500} | |
33 | + open | |
34 | + title="供应商选择" | |
35 | + form={form} | |
36 | + autoFocusFirstInput | |
37 | + modalProps={{ | |
38 | + okText: '确认', | |
39 | + cancelText: '取消', | |
40 | + destroyOnClose: true, | |
41 | + onCancel: () => { | |
42 | + setCheckVisible(false); | |
43 | + }, | |
44 | + }} | |
45 | + submitter={{ | |
46 | + render: (props, defaultDoms) => { | |
47 | + return defaultDoms; | |
48 | + }, | |
49 | + }} | |
50 | + submitTimeout={2000} | |
51 | + onFinish={async (values) => { | |
52 | + return doCheck({ | |
53 | + ids: subOrderIds, | |
54 | + supplier: values.name, | |
55 | + procureIsPrintAndSend: false, | |
56 | + }); | |
57 | + }} | |
58 | + onOpenChange={setCheckVisible} | |
59 | + > | |
60 | + <ProFormSelect | |
61 | + key="key" | |
62 | + label="供应商名称" | |
63 | + width="lg" | |
64 | + name="name" | |
65 | + // options={options} | |
66 | + placeholder="请选择供应商" | |
67 | + rules={[{ required: true, message: '供应商必填' }]} | |
68 | + request={async () => { | |
69 | + const res = await postServiceOrderQuerySupplier(); | |
70 | + return res.data?.map((item) => { | |
71 | + return { label: item, value: item }; | |
72 | + }); | |
73 | + }} | |
74 | + /> | |
75 | + </ModalForm> | |
76 | + ); | |
77 | +}; | ... | ... |