曾国涛
authored
7 months ago
1
import ButtonConfirm from '@/components/ButtomConfirm';
曾国涛
authored
8 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
8 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
8 months ago
15
16
17
18
19
20
21
22
23
24
25
26
27
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>();
const { getInvoiceFlushStatus } = useModel('enum');
曾国涛
authored
7 months ago
28
const columns: ProColumns[] = [
曾国涛
authored
8 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
8 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
8 months ago
44
},
曾国涛
authored
7 months ago
45
ellipsis: true,
曾国涛
authored
8 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
8 months ago
77
78
title: '重开原因',
dataIndex: 'notes',
曾国涛
authored
7 months ago
79
valueType: 'textarea',
曾国涛
authored
8 months ago
80
ellipsis: true,
曾国涛
authored
7 months ago
81
width: 180,
曾国涛
authored
8 months ago
82
83
84
85
86
hideInSearch: true,
},
{
title: '申请人',
dataIndex: 'createByName',
曾国涛
authored
7 months ago
87
width: 80,
曾国涛
authored
8 months ago
88
89
90
91
92
93
ellipsis: true,
hideInSearch: true,
},
{
title: '申请时间',
dataIndex: 'createTime',
曾国涛
authored
7 months ago
94
width: 100,
曾国涛
authored
8 months ago
95
96
97
98
99
100
ellipsis: true,
hideInSearch: true,
},
{
title: '审核状态',
dataIndex: 'statusText',
曾国涛
authored
7 months ago
101
width: 100,
曾国涛
authored
8 months ago
102
103
104
105
106
107
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红状态',
dataIndex: 'flushStatusText',
曾国涛
authored
7 months ago
108
width: 100,
曾国涛
authored
8 months ago
109
110
111
112
113
114
ellipsis: true,
hideInSearch: true,
},
{
title: '财务负责人',
dataIndex: 'financeManager',
曾国涛
authored
7 months ago
115
width: 100,
曾国涛
authored
8 months ago
116
117
118
119
120
121
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红时间',
dataIndex: 'flushDatetime',
曾国涛
authored
7 months ago
122
width: 100,
曾国涛
authored
8 months ago
123
124
125
ellipsis: true,
hideInSearch: true,
},
曾国涛
authored
7 months ago
126
127
128
{
title: '审核备注',
dataIndex: 'auditNotes',
曾国涛
authored
7 months ago
129
130
width: 100,
width: 180,
曾国涛
authored
7 months ago
131
132
hideInSearch: true,
},
曾国涛
authored
8 months ago
133
134
135
136
137
138
139
{
title: '发票号码',
dataIndex: 'invoiceNumber',
hideInTable: true,
},
{
title: '申请人',
曾国涛
authored
7 months ago
140
dataIndex: 'createByNameLike',
曾国涛
authored
8 months ago
141
142
143
144
hideInTable: true,
},
{
title: '重开原因',
曾国涛
authored
7 months ago
145
dataIndex: 'notesLike',
曾国涛
authored
8 months ago
146
147
148
149
hideInTable: true,
},
{
title: '申请时间',
曾国涛
authored
7 months ago
150
valueType: 'dateTimeRange',
曾国涛
authored
8 months ago
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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
172
const res = await postServiceConstInvoiceReissueRecordStatus();
曾国涛
authored
8 months ago
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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);
},
},
{
title: '财务负责人',
dataIndex: 'financeManager',
ellipsis: true,
hideInTable: true,
},
{
title: '冲红时间',
曾国涛
authored
7 months ago
197
valueType: 'dateTimeRange',
曾国涛
authored
8 months ago
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
flushDatetimeGe: value[0],
flushDatetimeLe: value[1],
};
}
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
曾国涛
authored
7 months ago
215
216
217
218
219
220
221
222
render: (text, record) => {
console.log(text);
return [
record.paths?.includes('audit') && (
<Audit
key={'audit'}
recordIds={[record.id]}
onClose={() => {
曾国涛
authored
7 months ago
223
actionRef.current?.reload();
曾国涛
authored
7 months ago
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
}}
/>
),
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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
261
262
];
},
曾国涛
authored
8 months ago
263
264
265
},
];
return (
曾国涛
authored
7 months ago
266
<ProTable
曾国涛
authored
8 months ago
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
320
321
322
323
324
325
326
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={{
// 由于配置了 transform,提交的参数与定义的不同这里需要转化一下
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
created_at: [values.startTime, values.endTime],
};
}
return values;
},
}}
pagination={{
pageSize: 5,
onChange: (page) => console.log(page),
}}
dateFormatter="string"
headerTitle="高级表格"
曾国涛
authored
7 months ago
327
scroll={{ x: 'max-content' }}
曾国涛
authored
8 months ago
328
329
330
/>
);
};