曾国涛
authored
7 months ago
1
import ButtonConfirm from '@/components/ButtomConfirm';
曾国涛
authored
7 months ago
2
3
4
import { RESPONSE_CODE } from '@/constants/enum';
import Audit from '@/pages/Invoice/ReissueRecord/components/Audit';
import {
曾国涛
authored
7 months ago
5
postServiceConstInvoiceReissueRecordStatus,
曾国涛
authored
7 months ago
6
postServiceInvoiceReissueRecordDelete,
曾国涛
authored
7 months ago
7
postServiceInvoiceReissueRecordFlush,
曾国涛
authored
7 months ago
8
9
10
11
12
postServiceInvoiceReissueRecords,
} from '@/services';
import { enumToSelect } from '@/utils';
import { useModel } from '@@/exports';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
曾国涛
authored
7 months ago
13
14
import { ProTable } from '@ant-design/pro-components';
import { message } from 'antd';
曾国涛
authored
7 months ago
15
16
17
18
19
20
21
22
23
24
25
26
import { useRef } from 'react';
export const waitTimePromise = async (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
export default () => {
const actionRef = useRef<ActionType>();
曾国涛
authored
7 months ago
27
const { getInvoiceFlushStatus, getPayees } = useModel('enum');
曾国涛
authored
7 months ago
28
const columns: ProColumns[] = [
曾国涛
authored
7 months ago
29
30
31
32
33
34
35
36
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '重开的发票',
dataIndex: 'invoiceNumbers',
曾国涛
authored
7 months ago
37
width: 200,
曾国涛
authored
7 months ago
38
render: (_, record) => {
曾国涛
authored
7 months ago
39
40
41
42
43
return (
<div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>
{record.invoiceNumbers?.join(',\n')}
</div>
);
曾国涛
authored
7 months ago
44
},
曾国涛
authored
7 months ago
45
ellipsis: true,
曾国涛
authored
7 months ago
46
47
48
hideInSearch: true,
},
{
曾国涛
authored
7 months ago
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
title: '收款单位',
dataIndex: 'payees',
width: 230,
render: (_, record) => {
return (
<div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>
{record.payees?.join(',\n')}
</div>
);
},
ellipsis: true,
hideInSearch: true,
},
{
title: '联系人',
dataIndex: 'contacts',
width: 100,
render: (_, record) => {
return (
<div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>
{record.contacts?.join(',\n')}
</div>
);
},
ellipsis: true,
hideInSearch: true,
},
{
曾国涛
authored
7 months ago
77
78
title: '重开原因',
dataIndex: 'notes',
曾国涛
authored
7 months ago
79
valueType: 'textarea',
曾国涛
authored
7 months ago
80
ellipsis: true,
曾国涛
authored
7 months ago
81
width: 180,
曾国涛
authored
7 months ago
82
83
84
85
86
hideInSearch: true,
},
{
title: '申请人',
dataIndex: 'createByName',
曾国涛
authored
7 months ago
87
width: 80,
曾国涛
authored
7 months ago
88
89
90
91
92
93
ellipsis: true,
hideInSearch: true,
},
{
title: '申请时间',
dataIndex: 'createTime',
曾国涛
authored
7 months ago
94
width: 100,
曾国涛
authored
7 months ago
95
96
97
98
99
100
ellipsis: true,
hideInSearch: true,
},
{
title: '审核状态',
dataIndex: 'statusText',
曾国涛
authored
7 months ago
101
width: 100,
曾国涛
authored
7 months ago
102
103
104
105
106
107
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红状态',
dataIndex: 'flushStatusText',
曾国涛
authored
7 months ago
108
width: 100,
曾国涛
authored
7 months ago
109
110
111
112
113
114
ellipsis: true,
hideInSearch: true,
},
{
title: '财务负责人',
dataIndex: 'financeManager',
曾国涛
authored
7 months ago
115
width: 100,
曾国涛
authored
7 months ago
116
117
118
119
120
121
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红时间',
dataIndex: 'flushDatetime',
曾国涛
authored
7 months ago
122
width: 100,
曾国涛
authored
7 months ago
123
124
125
ellipsis: true,
hideInSearch: true,
},
曾国涛
authored
7 months ago
126
127
128
{
title: '审核备注',
dataIndex: 'auditNotes',
曾国涛
authored
7 months ago
129
width: 100,
曾国涛
authored
7 months ago
130
131
hideInSearch: true,
},
曾国涛
authored
7 months ago
132
133
134
135
136
137
138
{
title: '发票号码',
dataIndex: 'invoiceNumber',
hideInTable: true,
},
{
title: '申请人',
曾国涛
authored
7 months ago
139
dataIndex: 'createByNameLike',
曾国涛
authored
7 months ago
140
141
142
143
hideInTable: true,
},
{
title: '重开原因',
曾国涛
authored
7 months ago
144
dataIndex: 'notesLike',
曾国涛
authored
7 months ago
145
146
147
148
hideInTable: true,
},
{
title: '申请时间',
曾国涛
authored
7 months ago
149
valueType: 'dateTimeRange',
曾国涛
authored
7 months ago
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createDatetimeGe: value[0],
createDatetimeLe: value[1],
};
}
},
},
},
{
title: '审核状态',
valueType: 'select',
key: 'status',
dataIndex: 'status',
filters: true,
onFilter: true,
hideInTable: true,
request: async () => {
曾国涛
authored
7 months ago
171
const res = await postServiceConstInvoiceReissueRecordStatus();
曾国涛
authored
7 months ago
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
return enumToSelect(res.data);
},
},
{
title: '冲红状态',
valueType: 'select',
key: 'flushStatus',
dataIndex: 'flushStatus',
filters: true,
onFilter: true,
hideInTable: true,
request: async () => {
const res = await getInvoiceFlushStatus();
return enumToSelect(res);
},
},
{
曾国涛
authored
7 months ago
189
190
191
192
193
194
195
196
197
198
199
200
201
title: '收款单位',
valueType: 'select',
key: 'payee',
dataIndex: 'payee',
filters: true,
onFilter: true,
hideInTable: true,
request: async () => {
const res = await getPayees();
return enumToSelect(res);
},
},
{
曾国涛
authored
7 months ago
202
203
204
205
206
207
208
title: '财务负责人',
dataIndex: 'financeManager',
ellipsis: true,
hideInTable: true,
},
{
title: '冲红时间',
曾国涛
authored
7 months ago
209
valueType: 'dateTimeRange',
曾国涛
authored
7 months ago
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
flushDatetimeGe: value[0],
flushDatetimeLe: value[1],
};
}
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
曾国涛
authored
7 months ago
227
228
229
230
231
232
233
234
render: (text, record) => {
console.log(text);
return [
record.paths?.includes('audit') && (
<Audit
key={'audit'}
recordIds={[record.id]}
onClose={() => {
曾国涛
authored
7 months ago
235
actionRef.current?.reload();
曾国涛
authored
7 months ago
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
}}
/>
),
record.paths?.includes('audit') && (
<ButtonConfirm
key="delete"
className="p-0"
title={'确认删除该记录?'}
text="删除"
onConfirm={async () => {
let res = await postServiceInvoiceReissueRecordDelete({
data: { id: record.id },
});
if (res) {
message.success(res.message);
actionRef.current?.reload();
}
}}
/>
),
曾国涛
authored
7 months ago
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
record.paths?.includes('flush') && (
<ButtonConfirm
key="flush"
className="p-0"
title={'确认冲红发票?'}
text="冲红"
onConfirm={async () => {
let res = await postServiceInvoiceReissueRecordFlush({
data: { id: record.id },
});
if (res) {
message.success(res.message);
actionRef.current?.reload();
}
}}
/>
),
曾国涛
authored
7 months ago
273
274
];
},
曾国涛
authored
7 months ago
275
276
277
},
];
return (
曾国涛
authored
7 months ago
278
<ProTable
曾国涛
authored
7 months ago
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
320
321
322
323
324
325
326
327
328
329
330
331
332
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params) => {
const res = await postServiceInvoiceReissueRecords({
data: {
...params,
},
});
if (res.result === RESPONSE_CODE.SUCCESS) {
return {
data: res?.data?.data,
total: res?.data?.total || 0,
};
}
return {
data: [],
success: false,
};
}}
editable={{
type: 'multiple',
}}
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={{
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
created_at: [values.startTime, values.endTime],
};
}
return values;
},
}}
pagination={{
曾国涛
authored
7 months ago
333
334
335
336
337
338
//pageSize: 5, // 默认每页展示条数
pageSizeOptions: ['5', '10', '20', '50'], // 可选的条数
showSizeChanger: true, // 启用条数选择器
/*
onChange: (page, pageSize) => console.log(`Page: ${page}, PageSize: ${pageSize}`),
*/
曾国涛
authored
7 months ago
339
340
341
}}
dateFormatter="string"
headerTitle="高级表格"
曾国涛
authored
7 months ago
342
scroll={{ x: 'max-content' }}
曾国涛
authored
7 months ago
343
344
345
/>
);
};