OrderDrawer.tsx
8.07 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
import { postErpOrderAdd } from '@/services';
import {
DrawerForm,
FormListActionType,
ProCard,
ProFormGroup,
ProFormList,
ProFormText,
} from '@ant-design/pro-components';
import { Form, message } from 'antd';
import { useEffect, useRef } from 'react';
import { useFieldAuth } from '../hooks';
import { OPERATION_TYPE } from '../type.d';
export default ({ onClose, data }) => {
const { authFields } = useFieldAuth({
operation: data?.id ? OPERATION_TYPE.EDIT : OPERATION_TYPE.CREATE,
});
const [form] = Form.useForm<{ name: string; company: string }>();
const actionRef = useRef<
FormListActionType<{
name: string;
}>
>();
//作为商品行号
const rowNumber = useRef(0);
useEffect(() => {
form.setFieldsValue({ ...data });
}, [data]);
return (
<DrawerForm<{
name: string;
company: string;
}>
open
title="新建订单"
resize={{
onResize() {
console.log('resize!');
},
maxWidth: window.innerWidth * 0.8,
minWidth: 400,
}}
// layout="horizontal"
// labelCol={{ span: 8 }}
form={form}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
}}
submitTimeout={2000}
onFinish={async (values) => {
console.log(form);
console.log(values);
await postErpOrderAdd({ values });
console.log(values.name);
message.success('提交成功');
// 不返回不会关闭弹框
// onClose();
return true;
}}
onOpenChange={(val) => {
return !val && onClose();
}}
>
<h2>订单基本信息</h2>
<ProFormText
name="id"
width="lg"
label="订单编号"
placeholder="请输入订单编号"
disabled={authFields.id}
/>
<ProFormText
width="lg"
name="salesCode"
label="销售代号"
placeholder="请输入销售代号"
disabled={authFields.salesCode}
/>
<ProFormText
name="customerName"
width="lg"
label="收货人"
placeholder="请输入收货人"
disabled={authFields.customerName}
/>
<ProFormText
width="lg"
name="customerContactNumber"
label="收货人联系手机号"
placeholder="请输入收货人联系手机号"
/>
<ProFormText
width="lg"
name="customerShippingAddress"
label="收货人地址信息"
placeholder="请输入收货人地址信息"
/>
<ProFormText
width="lg"
name="institutionContactName"
label="单位联系人"
placeholder="请输入单位联系人"
/>
<ProFormText
width="lg"
name="institution"
label="单位"
placeholder="请输入单位"
/>
<h2>商品基本信息</h2>
<ProFormText width="lg" name="totalPayment" label="支付总金额" />
<ProFormText
width="lg"
name="logisticsStatus"
label="物流方式"
placeholder="请输入物流方式"
/>
<ProFormText
width="lg"
name="paymentStatus"
label="支付状态"
placeholder="请输入支付状态"
/>
<ProFormText
width="lg"
name="paymentMethod"
label="支付方式"
placeholder="请输入支付方式"
/>
<ProFormText
width="lg"
name="paymentChannel"
label="支付渠道"
placeholder="请输入支付渠道"
/>
<ProFormText
width="lg"
name="paymentTransactionId"
label="支付流水号"
placeholder="请输入支付流水号"
/>
<ProFormText
width="lg"
name="invoiceInformation"
label="发票信息"
placeholder="请输入发票信息"
/>
<ProFormText
width="lg"
name="invoicingStatus"
label="开票状态"
placeholder="请输入开票状态"
/>
<ProFormText
width="lg"
name="productBelongDepartment"
label="商品所属部门"
placeholder="请输入商品所属部门"
/>
<ProFormText
width="lg"
name="waybillNumber"
label="运单号"
placeholder="请输入运单号"
/>
<ProFormText
width="lg"
name="notes"
label="备注"
placeholder="请输入备注"
/>
<ProFormText
width="lg"
name="examineNotes"
label="审核备注"
placeholder="请输入审核备注"
/>
<ProFormText
width="lg"
name="orderStatus"
label="订单状态"
placeholder="请输入订单状态"
/>
<h2>商品信息</h2>
<ProFormList
name="subOrderInformationLists"
label=""
initialValue={[
{
productCode: '',
productName: '',
quantity: '',
productPrice: '',
parameters: '',
subOrderPayment: '',
},
]}
actionGuard={{
beforeAddRow: async (defaultValue, insertIndex) => {
return new Promise((resolve) => {
console.log(defaultValue, insertIndex);
rowNumber.current = 1;
setTimeout(() => resolve(true), 1000);
});
},
beforeRemoveRow: async (index) => {
return new Promise((resolve) => {
if (index === 0) {
message.error('这行不能删');
resolve(false);
return;
}
rowNumber.current = 1;
setTimeout(() => resolve(true), 1000);
});
},
}}
itemRender={({ listDom, action }) => {
return (
<ProCard
bordered
extra={action}
title={'商品' + rowNumber.current++}
style={{
marginBlockEnd: 8,
}}
>
{listDom}
</ProCard>
);
}}
actionRef={actionRef}
>
<ProFormGroup key="group">
<ProFormText
width="md"
name="productCode"
label="商品编码"
placeholder="请输入商品编码"
/>
<ProFormText
width="md"
name="productName"
label="商品名称"
placeholder="请输入商品名称"
/>
<ProFormText
width="md"
name="quantity"
label="商品数量"
placeholder="请输入商品数量"
/>
<ProFormText
width="md"
name="productPrice"
label="商品单价"
placeholder="请输入商品单价"
/>
<ProFormText
width="md"
name="unit"
label="价格单位"
placeholder="请输入价格单位"
/>
<ProFormText
width="md"
name="parameters"
label="商品参数"
placeholder="请输入商品参数"
/>
<ProFormText
width="md"
name="subOrderPayment"
label="子订单金额"
placeholder="请输入子订单金额"
/>
</ProFormGroup>
</ProFormList>
{/* <ProFormDateRangePicker name="contractTime" label="合同生效时间" /> */}
{/* <ProForm.Group>
<ProFormSelect
options={[
{
value: 'chapter',
label: '盖章后生效',
},
]}
width="xs"
name="useMode"
label="合同约定生效方式"
/>
<ProFormSelect
width="xs"
options={[
{
value: 'time',
label: '履行完终止',
},
]}
formItemProps={{
style: {
margin: 0,
},
}}
name="unusedMode"
label="合同约定失效效方式"
/>
</ProForm.Group>
*/}
</DrawerForm>
);
};