曾国涛
authored
|
1
|
// import { PlusOutlined } from '@ant-design/icons';
|
曾国涛
authored
|
2
|
import InvoiceModal from '@/pages/Invoice/components/InvoiceModal';
|
曾国涛
authored
|
3
|
import {
|
曾国涛
authored
|
4
|
postServiceConstGetPayeeEnum,
|
曾国涛
authored
|
5
6
|
postServiceConstInvoiceType,
postServiceConstInvoicingType,
|
曾国涛
authored
|
7
|
postServiceConstListInvoiceDetailNames,
|
曾国涛
authored
|
8
|
postServiceInvoiceApplyInvoice,
|
曾国涛
authored
|
9
|
postServiceInvoiceQueryCompanyInfo,
|
曾国涛
authored
|
10
11
|
} from '@/services';
import { enumToSelect } from '@/utils';
|
曾国涛
authored
|
12
13
|
import {
DrawerForm,
|
曾国涛
authored
|
14
15
|
ProCard,
ProFormDigit,
|
曾国涛
authored
|
16
|
ProFormGroup,
|
曾国涛
authored
|
17
18
|
ProFormList,
ProFormMoney,
|
曾国涛
authored
|
19
20
|
ProFormSelect,
ProFormText,
|
曾国涛
authored
|
21
|
ProFormTextArea,
|
曾国涛
authored
|
22
|
} from '@ant-design/pro-components';
|
曾国涛
authored
|
23
|
import { Button, Divider, Form } from 'antd';
|
曾国涛
authored
|
24
|
import { useEffect } from 'react';
|
曾国涛
authored
|
25
|
|
曾国涛
authored
|
26
|
export default ({ dataList, setVisible, onClose }) => {
|
曾国涛
authored
|
27
28
29
30
|
// let subOrderIds = dataList?.map((item) => {
// return item.id;
// });
const [form] = Form.useForm();
|
曾国涛
authored
|
31
|
useEffect(() => {}, []);
|
曾国涛
authored
|
32
|
return (
|
曾国涛
authored
|
33
34
35
|
<DrawerForm
open
title="合并开票"
|
曾国涛
authored
|
36
37
38
39
40
|
resize={{
onResize() {
console.log('resize!');
},
maxWidth: window.innerWidth * 0.8,
|
曾国涛
authored
|
41
|
minWidth: 500,
|
曾国涛
authored
|
42
43
44
45
46
47
|
}}
form={form}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
}}
|
曾国涛
authored
|
48
49
50
51
52
53
54
55
56
57
58
59
|
submitter={{
render: (props, defaultDoms) => {
return [
<InvoiceModal
key={'invoicePreview'}
button={<Button type="primary"> 发票预览 </Button>}
getRecord={form.getFieldsValue}
/>,
...defaultDoms,
];
},
}}
|
曾国涛
authored
|
60
61
|
submitTimeout={2000}
onFinish={async (values) => {
|
曾国涛
authored
|
62
63
64
65
66
67
68
69
|
postServiceInvoiceApplyInvoice({
data: {
...values,
subOrderIds: dataList.map((item) => {
return item.id;
}),
},
});
|
曾国涛
authored
|
70
|
onClose();
|
曾国涛
authored
|
71
72
73
|
}}
onOpenChange={(val) => {
return !val && setVisible();
|
曾国涛
authored
|
74
75
|
}}
>
|
曾国涛
authored
|
76
|
<ProFormList
|
曾国涛
authored
|
77
|
name="subOrderIdObjs"
|
曾国涛
authored
|
78
|
readonly={true}
|
曾国涛
authored
|
79
|
label="开票订单"
|
曾国涛
authored
|
80
81
82
83
84
|
initialValue={dataList.map((item) => {
return {
value: item.id,
};
})}
|
曾国涛
authored
|
85
|
deleteIconProps={false}
|
曾国涛
authored
|
86
|
>
|
曾国涛
authored
|
87
|
<ProFormGroup key="group">
|
曾国涛
authored
|
88
|
<ProFormText readonly={true} name="value" label="" />
|
曾国涛
authored
|
89
|
</ProFormGroup>
|
曾国涛
authored
|
90
|
</ProFormList>
|
曾国涛
authored
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<ProFormSelect
key="key"
label="购方名称"
width="lg"
showSearch
name="partyAName"
placeholder="请搜索购方"
rules={[{ required: true, message: '购方名称必填' }]}
onChange={(_, option) => {
form.setFieldValue('partyATaxid', option.taxId);
}}
fieldProps={{
optionItemRender(item) {
if (item.type === 'add') {
|
曾国涛
authored
|
105
|
return <>{item.name}</>;
|
曾国涛
authored
|
106
107
108
|
}
return (
<>
|
曾国涛
authored
|
109
|
{item.name}
|
曾国涛
authored
|
110
|
<Divider type="vertical" />
|
曾国涛
authored
|
111
|
{item.taxId}
|
曾国涛
authored
|
112
113
114
115
116
117
118
119
|
</>
);
},
}}
debounceTime={1000}
request={async (value) => {
const keywords = value.keyWords;
const res = await postServiceInvoiceQueryCompanyInfo({
|
曾国涛
authored
|
120
121
122
123
|
data: {
nameLike: keywords,
taxIdIsNotNull: true,
},
|
曾国涛
authored
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
});
let options = res?.data?.map((company) => {
return {
...company,
label: company.name,
value: company.name + '|' + company.taxId,
key: company.id,
};
});
//第一个商品默认为要新增的商品
if (keywords.trim() !== '') {
options.unshift({
name: keywords,
type: 'add',
label: keywords,
value: keywords,
key: keywords,
});
}
return options;
}}
/>
|
曾国涛
authored
|
147
148
|
<ProFormText
width="md"
|
曾国涛
authored
|
149
|
name="partyATaxid"
|
曾国涛
authored
|
150
151
152
153
154
|
label="购方税号"
placeholder="请输入名称"
/>
<ProFormText
width="md"
|
曾国涛
authored
|
155
|
name="partyAOpenBank"
|
曾国涛
authored
|
156
157
158
159
160
|
label="开户银行"
placeholder="请输入名称"
/>
<ProFormText
width="md"
|
曾国涛
authored
|
161
|
name="partyABankAccount"
|
曾国涛
authored
|
162
163
164
165
166
|
label="开户行账号"
placeholder="请输入名称"
/>
<ProFormMoney
label="开票金额"
|
曾国涛
authored
|
167
|
name="price"
|
曾国涛
authored
|
168
169
|
locale="zh-CN"
rules={[{ required: true, message: '请填写开票金额!' }]}
|
曾国涛
authored
|
170
171
172
|
initialValue={dataList.reduce((accumulator, currentValue) => {
return accumulator + currentValue.subOrderPayment;
}, 0)}
|
曾国涛
authored
|
173
174
|
/>
<ProFormSelect
|
曾国涛
authored
|
175
|
name="invoicingType"
|
曾国涛
authored
|
176
|
label="开具类型"
|
曾国涛
authored
|
177
178
179
180
181
|
request={async () => {
let invoicingTypeRet = await postServiceConstInvoicingType();
let options = enumToSelect(invoicingTypeRet.data);
return options;
}}
|
曾国涛
authored
|
182
183
|
placeholder="请选择开具类型"
rules={[{ required: true, message: '请选择开具类型!' }]}
|
曾国涛
authored
|
184
185
|
/>
<ProFormSelect
|
曾国涛
authored
|
186
|
name="type"
|
曾国涛
authored
|
187
|
label="开票类型"
|
曾国涛
authored
|
188
189
|
placeholder="请选择开票类型"
rules={[{ required: true, message: '请选择开票类型!' }]}
|
曾国涛
authored
|
190
191
192
193
194
|
request={async () => {
let invoiceTypeRet = await postServiceConstInvoiceType();
let options = enumToSelect(invoiceTypeRet.data);
return options;
}}
|
曾国涛
authored
|
195
196
|
/>
<ProFormSelect
|
曾国涛
authored
|
197
|
name="partyB"
|
曾国涛
authored
|
198
|
label="开票收款单位"
|
曾国涛
authored
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
request={async () => {
const res = await postServiceConstGetPayeeEnum();
let options = res?.data?.map((payee: any) => {
return {
...payee,
label: payee.payeeName,
value: payee.name,
};
});
return options;
}}
onChange={(_, option) => {
if (option) {
form.setFieldsValue({
partyBName: option.payeeName,
partyBTaxid: option.taxId,
});
}
}}
|
曾国涛
authored
|
218
219
|
placeholder="请选择收款单位"
rules={[{ required: true, message: '请选择收款单位!' }]}
|
曾国涛
authored
|
220
|
/>
|
曾国涛
authored
|
221
222
223
224
225
226
227
228
229
230
231
232
|
<ProFormText
name="partyBName"
label="开票收款单位名称"
hidden
rules={[{ required: true, message: '请选择收款单位!' }]}
/>
<ProFormText
name="partyBTaxid"
label="开票收款单位税号"
hidden
rules={[{ required: true, message: '请选择收款单位!' }]}
/>
|
曾国涛
authored
|
233
|
<ProFormSelect
|
曾国涛
authored
|
234
|
name="isUrgent"
|
曾国涛
authored
|
235
236
|
label="是否加急"
valueEnum={{
|
曾国涛
authored
|
237
238
|
true: '是',
false: '否',
|
曾国涛
authored
|
239
|
}}
|
曾国涛
authored
|
240
241
|
placeholder="请选择是否加急"
rules={[{ required: true, message: '请选择是否加急!' }]}
|
曾国涛
authored
|
242
|
/>
|
曾国涛
authored
|
243
244
245
|
<ProFormList
name="invoiceDetails"
label="开票明细"
|
曾国涛
authored
|
246
247
|
initialValue={dataList.map((item) => {
return {
|
曾国涛
authored
|
248
|
subOrderId: item.id,
|
曾国涛
authored
|
249
|
/*projectName: item.productName,*/
|
曾国涛
authored
|
250
251
252
253
254
255
256
|
specification: item.parameters,
unit: item.unit,
quantity: item.quantity,
price: item.productPrice,
totalPrice: item.totalPayment,
};
})}
|
曾国涛
authored
|
257
258
259
260
261
262
263
264
265
266
267
268
|
rules={[
{
required: true,
validator: async (_, value) => {
console.log(value);
if (value && value.length > 0) {
return;
}
throw new Error('至少要有一项!');
},
},
]}
|
曾国涛
authored
|
269
270
271
272
273
274
275
276
277
278
279
|
itemRender={(doms, listMeta) => {
console.log(listMeta);
return (
<ProCard
bordered
extra={doms.action}
title={'明细' + (listMeta.index + 1)}
style={{
marginBlockEnd: 8,
}}
>
|
曾国涛
authored
|
280
281
282
283
284
285
|
<ProFormText
key={'subOrderId' + listMeta.index}
name="subOrderId"
label="子订单id"
hidden
/>
|
曾国涛
authored
|
286
287
288
|
<ProFormSelect
key={'projectName' + listMeta.index}
width="md"
|
曾国涛
authored
|
289
|
showSearch
|
曾国涛
authored
|
290
|
name="projectName"
|
曾国涛
authored
|
291
|
rules={[{ required: true, message: '请输入开票项目名称!' }]}
|
曾国涛
authored
|
292
293
294
295
296
297
298
299
300
301
|
request={async (value) => {
const keywords = value.keyWords;
const res = await postServiceConstListInvoiceDetailNames({
data: {
nameLike: keywords,
},
});
let options = res?.data?.map((c: any) => {
return {
...c,
|
曾国涛
authored
|
302
303
304
305
306
|
label:
'*' +
c.productAndServiceCatagoryAbbreviation +
'*' +
c.name,
|
曾国涛
authored
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
value:
'*' +
c.productAndServiceCatagoryAbbreviation +
'*' +
c?.name,
key: c.id,
};
});
return options;
}}
fieldProps={{
filterOption() {
return true;
},
}}
onChange={(_, option) => {
let index = listMeta.index;
let copyList = form.getFieldValue('invoiceDetails');
let currentData = copyList[index];
currentData.projectName =
'*' +
option.productAndServiceCatagoryAbbreviation +
'*' +
option.name;
currentData.specification = option.specification;
currentData.unit = option.unit;
form.setFieldValue('invoiceDetails', copyList);
}}
debounceTime={1000}
label="项目名称"
placeholder="请输入名称"
/>
<ProFormText
key={'specification' + listMeta.index}
name="specification"
label="规格型号"
|
曾国涛
authored
|
343
344
345
346
347
348
349
350
351
352
|
rules={[
{
message: '规格型号不能超过20个字符!',
max: 20,
},
{
message: '规格型号不能为空!',
required: true,
},
]}
|
曾国涛
authored
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
placeholder="请输入名称"
/>
<ProFormText
key={'unit' + listMeta.index}
name="unit"
label="单位"
placeholder="请输入名称"
/>
<ProFormDigit
key={'quantity' + listMeta.index}
label="数量"
name="quantity"
min={0}
/>
<ProFormDigit
key={'price' + listMeta.index}
label="单价"
name="price"
min={0}
/>
<ProFormMoney
key={'totalPrice' + listMeta.index}
label="金额"
name="totalPrice"
locale="zh-CN"
/>
</ProCard>
);
}}
></ProFormList>
|
曾国涛
authored
|
383
384
385
386
387
|
<ProFormTextArea
name="applyInvoicingNotes"
label="备注"
placeholder="请输入名称"
/>
|
曾国涛
authored
|
388
389
390
|
</DrawerForm>
);
};
|