index.tsx
6.91 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
import ButtonConfirm from '@/components/ButtomConfirm';
import { RESPONSE_CODE } from '@/constants/enum';
import Audit from '@/pages/Invoice/ReissueRecord/components/Audit';
import {
postServiceConstInvoiceReissueRecordStatus,
postServiceInvoiceReissueRecordDelete,
postServiceInvoiceReissueRecordFlush,
postServiceInvoiceReissueRecords,
} from '@/services';
import { enumToSelect } from '@/utils';
import { useModel } from '@@/exports';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { message } from 'antd';
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');
const columns: ProColumns[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '重开的发票',
dataIndex: 'invoiceNumbers',
render: (_, record) => {
return (
<div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>
{record.invoiceNumbers?.join(',\n')}
</div>
);
},
ellipsis: true,
hideInSearch: true,
},
{
title: '重开原因',
dataIndex: 'notes',
ellipsis: true,
hideInSearch: true,
},
{
title: '申请人',
dataIndex: 'createByName',
ellipsis: true,
hideInSearch: true,
},
{
title: '申请时间',
dataIndex: 'createTime',
ellipsis: true,
hideInSearch: true,
},
{
title: '审核状态',
dataIndex: 'statusText',
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红状态',
dataIndex: 'flushStatusText',
ellipsis: true,
hideInSearch: true,
},
{
title: '财务负责人',
dataIndex: 'financeManager',
ellipsis: true,
hideInSearch: true,
},
{
title: '冲红时间',
dataIndex: 'flushDatetime',
ellipsis: true,
hideInSearch: true,
},
{
title: '发票号码',
dataIndex: 'invoiceNumber',
hideInTable: true,
},
{
title: '申请人',
dataIndex: 'createByNameLike',
hideInTable: true,
},
{
title: '重开原因',
dataIndex: 'notesLike',
hideInTable: true,
},
{
title: '申请时间',
valueType: 'dateTimeRange',
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 () => {
const res = await postServiceConstInvoiceReissueRecordStatus();
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: '冲红时间',
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
flushDatetimeGe: value[0],
flushDatetimeLe: value[1],
};
}
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record) => {
console.log(text);
return [
record.paths?.includes('audit') && (
<Audit
key={'audit'}
recordIds={[record.id]}
onClose={() => {
actionRef.current?.reload();
}}
/>
),
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();
}
}}
/>
),
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();
}
}}
/>
),
];
},
},
];
return (
<ProTable
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="高级表格"
/>
);
};