AddDrawer.tsx
3.8 KB
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
58
59
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { RESPONSE_CODE } from '@/constants/enum';
import {
postOrderErpOrderStagesUpload,
postProcureReturnBillAdd,
postServiceConstStores,
} from '@/services';
import { enumToSelect } from '@/utils';
import {
DrawerForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
ProFormUploadDragger,
} from '@ant-design/pro-components';
import { Button, Form, message } from 'antd';
import { RcFile } from 'antd/es/upload';
export default ({ reloadTable }) => {
const [form] = Form.useForm();
return (
<DrawerForm
title="新增采购退货单"
resize={{
onResize() {
console.log('resize!');
},
maxWidth: window.innerWidth * 0.8,
minWidth: 300,
}}
form={form}
trigger={<Button type="primary">新增</Button>}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
}}
submitTimeout={2000}
onFinish={async (values) => {
const res = await postProcureReturnBillAdd({
data: values,
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success('新增成功');
return true;
}
message.success('提交成功');
reloadTable();
// 不返回不会关闭弹框
return true;
}}
>
<ProFormText
name="consignee"
label="收货人"
placeholder="请输入收货人"
rules={[
{
required: true,
message: '请输入收货人',
},
]}
/>
<ProFormText
name="phoneNumber"
label="联系电话"
placeholder="请输入联系电话"
rules={[
{
required: true,
message: '请输入联系电话',
},
]}
/>
<ProFormText
name="address"
label="收货地址"
placeholder="请输入收货地址"
rules={[
{
required: true,
message: '请输入联系电话',
},
]}
/>
<ProFormTextArea
name="productDetail"
label="产品明细"
placeholder="请输入产品明细"
rules={[
{
required: true,
message: '请输入联系电话',
},
]}
></ProFormTextArea>
<ProFormSelect
name="sendStoreCode"
label="发货仓库"
request={async () => {
const res = await postServiceConstStores();
return enumToSelect(res.data);
}}
rules={[
{
required: true,
message: '请输入联系电话',
},
]}
></ProFormSelect>
<ProFormTextArea
name="notes"
label="备注"
placeholder="请输入备注"
></ProFormTextArea>
<ProFormUploadDragger
label="附件"
name="attachmentsFile"
action="upload.do"
onChange={(info) => {
const uploadFile = async ({ fileList: newFileList }) => {
if (newFileList.length > 0) {
const formData = new FormData();
formData.append('file', newFileList[0].originFileObj as RcFile);
const res = await postOrderErpOrderStagesUpload({
data: formData,
headers: {
'Content-Type':
'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
},
});
const url = res.data;
console.log('attachments' + JSON.stringify(url));
form.setFieldValue('attachments', url);
} else {
form.setFieldValue('attachments', null);
}
};
uploadFile(info);
}}
max={1}
/>
<ProFormText name="attachments" hidden></ProFormText>
</DrawerForm>
);
};