曾国涛
authored
8 months ago
1
import { RESPONSE_CODE } from '@/constants/enum';
曾国涛
authored
9 months ago
2
import InvoiceRecordDetailModal from '@/pages/Invoice/InvoiceRecord/components/InvoiceRecordDetailModal';
曾国涛
authored
10 months ago
3
4
5
6
7
8
9
10
import InvoiceModal from '@/pages/Invoice/waitProcessRecord/components/InvoiceModal';
import InvoicingModal from '@/pages/Invoice/waitProcessRecord/components/InvoicingModal';
import ManualInvoicingModal from '@/pages/Invoice/waitProcessRecord/components/ManualInvoicingModal';
import { PAYEE_OPTIONS } from '@/pages/Order/constant';
import {
postServiceConstBeforeInvoicingInvoiceRecordStatus,
postServiceConstInvoiceType,
postServiceConstInvoicingType,
曾国涛
authored
8 months ago
11
postServiceInvoiceCancelInvoiceRecord,
曾国涛
authored
10 months ago
12
13
14
15
16
postServiceInvoiceQueryInvoiceRecordList,
postServiceOrderQuerySalesCode,
} from '@/services';
import { enumToProTableEnumValue, enumToSelect } from '@/utils';
import { ActionType, ProTable } from '@ant-design/pro-components';
曾国涛
authored
8 months ago
17
18
19
20
21
22
23
24
25
import {
Button,
Divider,
Popconfirm,
Space,
Table,
Tooltip,
message,
} from 'antd';
曾国涛
authored
10 months ago
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
import { useEffect, useRef, useState } from 'react';
const InvoiceRecord = () => {
const waitDealrecordActionRef = useRef<ActionType>();
const [invoiceTypeValueEnum, setInvoiceTypeValueEnum] = useState({});
const [invoicingTypeValueEnum, setInvoicingTypeValueEnum] = useState({});
const [salesCodeValueEnum, setSalesCodeValueEnum] = useState({});
const [invoiceRecordDetailVisible, setInvoiceRecordDetailVisible] =
useState(false);
const [invoiceRecord, setInvoiceRecord] = useState({});
useEffect(() => {
async function extracted() {
let invoiceTypeRet = await postServiceConstInvoiceType();
setInvoiceTypeValueEnum(invoiceTypeRet.data);
}
extracted().catch(console.error);
}, []);
useEffect(() => {
async function extracted() {
let invoicingTypeRet = await postServiceConstInvoicingType();
setInvoicingTypeValueEnum(invoicingTypeRet.data);
}
extracted().catch(console.error);
}, []);
useEffect(() => {
async function extracted() {
const res = await postServiceOrderQuerySalesCode();
let map = {};
res.data?.forEach((item) => {
map[item.userName] = { text: item.userName, status: item.userName };
});
setSalesCodeValueEnum(map);
}
extracted().catch(console.error);
}, []);
const reloadRecordTable = () => {
waitDealrecordActionRef.current?.reload();
};
const waitDealRecordColumns = [
{
dataIndex: 'index',
valueType: 'indexBorder',
hideInSearch: true,
ellipsis: true,
width: 48,
},
{
title: '开票编号',
valueType: 'text',
dataIndex: 'id',
copyable: true,
hideInSearch: true,
ellipsis: true,
width: 100,
},
{
title: '发票状态',
valueType: 'Text',
dataIndex: 'statusText',
ellipsis: true,
曾国涛
authored
10 months ago
93
width: 100,
曾国涛
authored
10 months ago
94
95
96
hideInSearch: true,
},
{
曾国涛
authored
10 months ago
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
title: '重开发票',
key: 'reissueInvoiceNumbers',
ellipsis: true,
width: 160,
hideInSearch: true,
render: (_, record) => {
//将record.reissueInvoiceNumbers用,拼接
const numbersText = record.reissueInvoiceNumbers?.join(',');
return record.reissueInvoiceNumbers?.map((item) => {
return (
<Tooltip title={numbersText} key={item}>
<Space>
{item}
<Divider type={'vertical'} />
</Space>
</Tooltip>
);
});
},
},
{
曾国涛
authored
10 months ago
118
119
120
title: '申请开票时间',
dataIndex: 'createTime',
valueType: 'dateTime',
曾国涛
authored
10 months ago
121
width: 160,
曾国涛
authored
10 months ago
122
123
124
125
hideInSearch: true,
ellipsis: true,
},
{
曾国涛
authored
10 months ago
126
127
128
129
130
131
title: '订单号',
valueType: 'text',
dataIndex: 'mainOrderId',
hideInTable: true,
},
{
曾国涛
authored
10 months ago
132
title: '申请人',
曾国涛
authored
10 months ago
133
134
135
valueType: 'text',
hideInSearch: true,
ellipsis: true,
曾国涛
authored
10 months ago
136
width: 100,
曾国涛
authored
10 months ago
137
138
139
140
141
142
143
144
145
146
dataIndex: 'createByName',
},
{
title: '购方名称',
valueType: 'text',
dataIndex: 'partyAName',
hideInSearch: true,
ellipsis: true,
},
{
曾国涛
authored
10 months ago
147
148
149
150
151
152
153
154
title: '联系人',
valueType: 'text',
dataIndex: 'contacts',
width: 100,
hideInSearch: true,
ellipsis: true,
},
{
曾国涛
authored
10 months ago
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
title: '购方税号',
valueType: 'text',
hideInSearch: true,
dataIndex: 'partyATaxid',
ellipsis: true,
},
{
title: '收款单位',
valueType: 'text',
hideInSearch: true,
dataIndex: 'partyBName',
ellipsis: true,
},
{
title: '开票金额',
valueType: 'money',
dataIndex: 'price',
曾国涛
authored
10 months ago
172
width: 100,
曾国涛
authored
10 months ago
173
174
175
176
177
178
179
hideInSearch: true,
ellipsis: true,
},
{
title: '开具类型',
valueType: 'Text',
dataIndex: 'invoicingTypeText',
曾国涛
authored
10 months ago
180
width: 100,
曾国涛
authored
10 months ago
181
182
183
184
185
186
187
hideInSearch: true,
ellipsis: true,
},
{
title: '发票类型',
valueType: 'Text',
dataIndex: 'typeText',
曾国涛
authored
10 months ago
188
width: 100,
曾国涛
authored
10 months ago
189
190
191
192
193
194
195
hideInSearch: true,
ellipsis: true,
},
{
title: '是否加急',
valueType: 'Text',
dataIndex: 'isUrgentText',
曾国涛
authored
10 months ago
196
width: 50,
曾国涛
authored
10 months ago
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
hideInSearch: true,
ellipsis: true,
},
{
title: '申请备注',
valueType: 'text',
dataIndex: 'applyInvoicingNotes',
hideInSearch: true,
ellipsis: true,
},
{
title: '购方名称',
valueType: 'Text',
dataIndex: 'partyANameLike',
hideInTable: true,
},
{
曾国涛
authored
10 months ago
214
215
216
217
218
219
title: '联系人',
valueType: 'text',
dataIndex: 'contactsLike',
hideInTable: true,
},
{
曾国涛
authored
10 months ago
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
title: '收款单位',
valueType: 'select',
dataIndex: 'partyB',
filters: true,
onFilter: true,
hideInTable: true,
valueEnum: enumToProTableEnumValue(PAYEE_OPTIONS),
},
{
title: '主订单号',
valueType: 'Text',
dataIndex: 'mainOrderId',
hideInTable: true,
},
{
title: '子订单号',
valueType: 'Text',
dataIndex: 'subOrderId',
hideInTable: true,
},
{
title: '销售代表',
valueType: 'select',
dataIndex: 'salesCode',
filters: true,
onFilter: true,
hideInTable: true,
valueEnum: salesCodeValueEnum,
},
{
title: '发票类型',
valueType: 'select',
dataIndex: 'type',
filters: true,
onFilter: true,
hideInTable: true,
valueEnum: enumToProTableEnumValue(invoiceTypeValueEnum),
},
{
title: '开具类型',
valueType: 'select',
dataIndex: 'invoicingType',
filters: true,
onFilter: true,
hideInTable: true,
valueEnum: enumToProTableEnumValue(invoicingTypeValueEnum),
},
{
title: '开票状态',
valueType: 'select',
曾国涛
authored
9 months ago
270
key: 'status',
曾国涛
authored
10 months ago
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
dataIndex: 'status',
filters: true,
onFilter: true,
hideInTable: true,
request: async () => {
const res = await postServiceConstBeforeInvoicingInvoiceRecordStatus();
return enumToSelect(res.data);
},
},
{
title: '是否加急',
valueType: 'select',
dataIndex: 'isUrgent',
filters: true,
onFilter: true,
hideInTable: true,
valueEnum: {
true: {
text: '是',
status: true,
},
false: {
text: '否',
status: false,
},
},
},
{
title: '申请开票时间',
dataIndex: 'createTime',
valueType: 'dateTimeRange',
width: 200,
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createTimeGe: value[0],
createTimeLe: value[1],
};
}
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
曾国涛
authored
10 months ago
319
width: 200,
曾国涛
authored
10 months ago
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
render: (text, record) => {
return [
/*<InvoiceRecordDetailModal
key="detail"
id={record.id}
subOrderIds={record.subOrderIds}
onClose={()=>{
waitDealrecordActionRef.current?.reload();
}
}
/>*/
<>
{record.paths.includes('DETAIL') && (
<a
key="detail"
onClick={() => {
setInvoiceRecordDetailVisible(true);
setInvoiceRecord(record);
}}
>
详情
</a>
)}
</>,
<>
{record.paths.includes('PREVIEW') && (
<InvoiceModal key="invoiceModal" recordId={record.id} />
)}
</>,
<>
{record.paths.includes('INVOICING') && (
<ManualInvoicingModal
key={'ManualInvoicingModal'}
record={record}
></ManualInvoicingModal>
)}
</>,
曾国涛
authored
8 months ago
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
<>
{record.paths.includes('CANCEL') && (
<Popconfirm
title="取消开票"
description="确认取消开票?"
onConfirm={async () => {
let res = await postServiceInvoiceCancelInvoiceRecord({
data: {
invoiceRecordIds: [record.id],
},
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success('取消成功');
}
waitDealrecordActionRef?.current?.reload();
}}
okText="确定"
cancelText="取消"
>
<Button type="link" danger>
取消
</Button>
</Popconfirm>
)}
</>,
曾国涛
authored
10 months ago
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
];
},
},
];
return (
<div className="invoice-index">
<ProTable
columns={waitDealRecordColumns}
actionRef={waitDealrecordActionRef}
cardBordered
pagination={{
showSizeChanger: true, // 显示可以选择每页显示条数的下拉菜单
pageSizeOptions: ['10', '20', '50', '100'], // 设置可以选择的每页显示条数选项
}}
rowSelection={{
selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
alwaysShowAlert: true,
}}
tableAlertOptionRender={({ selectedRowKeys, selectedRows }) => {
console.log(selectedRows);
console.log(selectedRowKeys);
return (
<Space size={16}>
<InvoicingModal
reloadRecordTable={reloadRecordTable}
key="button"
selectedRowKeys={selectedRowKeys}
/>
</Space>
);
}}
request={async (params) => {
let res = await postServiceInvoiceQueryInvoiceRecordList({
data: {
...params,
statusIn: [
'WAITING_FOR_INVOICING',
'AUDITING',
'AUDITING_NOT_PASSED',
],
needBuildDetails: true,
needBuildSubOrders: true,
},
});
return {
data: res?.data?.data,
total: res?.data?.total || 0,
};
}}
columnsState={{
persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage',
defaultValue: {
option: { fixed: 'right', disable: true },
},
onChange(value) {
console.log('value: ', value);
},
}}
rowKey="id"
search={{
labelWidth: 'auto',
}}
options={{
setting: {
listsHeight: 400,
},
}}
form={{}}
dateFormatter="string"
headerTitle="待开票列表"
曾国涛
authored
10 months ago
453
scroll={{ x: 2000, y: 500 }}
曾国涛
authored
10 months ago
454
455
456
457
458
459
/>
{invoiceRecordDetailVisible ? (
<InvoiceRecordDetailModal
key="detail"
id={invoiceRecord.id}
setVisible={setInvoiceRecordDetailVisible}
曾国涛
authored
9 months ago
460
461
462
reloadTable={() => {
waitDealrecordActionRef?.current?.reload();
}}
曾国涛
authored
10 months ago
463
464
465
466
467
468
469
470
471
/>
) : (
''
)}
</div>
);
};
export default InvoiceRecord;