曾国涛
authored
10 months ago
1
2
3
import ButtonConfirm from '@/components/ButtomConfirm';
import EllipsisDiv from '@/components/Div/EllipsisDiv';
import { RESPONSE_CODE } from '@/constants/enum';
曾国涛
authored
9 months ago
4
import InvoiceWriteOffModal from '@/pages/Invoice/Invoice/components/invoiceWriteOffModal';
曾国涛
authored
10 months ago
5
6
7
8
9
10
11
12
13
14
15
16
import BankImportModal from '@/pages/Invoice/InvoiceVerification/components/BankImportModal';
import InvoiceRecordDetailModal from '@/pages/Invoice/InvoiceVerification/components/InvoiceRecordDetailModal';
import InvoiceVerificationModal from '@/pages/Invoice/InvoiceVerification/components/InvoiceVerificationModal';
import {
BANK_STATEMENT_COLUMNS,
INVOICE_STATUS,
} from '@/pages/Invoice/constant';
import { INVOCING_STATUS, PAYEE_OPTIONS } from '@/pages/Order/constant';
import {
postServiceBankStatementDeleteBankStatement,
postServiceBankStatementEditBankStatement,
postServiceBankStatementQueryBankStatement,
曾国涛
authored
9 months ago
17
postServiceInvoiceGetWriteOffRecord,
曾国涛
authored
10 months ago
18
} from '@/services';
曾国涛
authored
9 months ago
19
import { orderExport } from '@/services/order';
曾国涛
authored
10 months ago
20
21
22
23
24
25
26
27
28
29
30
31
32
import { enumValueToLabel, formatDateTime } from '@/utils';
import { formatDate } from '@/utils/time';
import { PlusOutlined } from '@ant-design/icons';
import { ActionType, ProTable } from '@ant-design/pro-components';
import { Button, message } from 'antd';
import { useRef, useState } from 'react';
const InvoiceRecord = () => {
const invoiceActionRef = useRef<ActionType>();
const bankActionRef = useRef<ActionType>();
const [bankImportModalVisible, setBankImportModalVisible] = useState(false);
const [invoiceVerificationVisible, setInvoiceVerificationVisible] =
useState(false);
曾国涛
authored
8 months ago
33
const [perms, setPerms] = useState([]);
曾国涛
authored
9 months ago
34
const [messageApi, contextHolder] = message.useMessage();
曾国涛
authored
10 months ago
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
const [invoiceId] = useState(undefined);
const [invoiceRecordDetailVisible, setInvoiceRecordDetailVisible] =
useState(false);
const [invoiceRecord] = useState({});
const reloadBankStatementTable = () => {
bankActionRef.current?.reload();
};
const getTableCellText = (target: any) => {
if (!target) {
return '';
}
if (target.props) {
return target.props.text;
}
return target;
};
const bankStatemetColumnsInit = () => {
let columns = BANK_STATEMENT_COLUMNS.map((item) => {
let newItem = { ...item };
let dataIndex = item.dataIndex;
let dataType = item.valueType;
newItem.render = (text, record) => {
let textValue = record[dataIndex];
if (dataType === 'date') {
textValue = formatDate(textValue);
}
if (dataType === 'dateTime') {
textValue = formatDateTime(textValue);
}
if (dataType === 'money') {
if (textValue === null || textValue === undefined) {
textValue = '';
} else {
textValue = '¥' + textValue;
}
}
switch (dataIndex) {
case 'invoiceStatus':
return (
<EllipsisDiv
text={enumValueToLabel(
getTableCellText(textValue),
INVOCING_STATUS,
)}
/>
);
case 'status':
return (
<EllipsisDiv
text={enumValueToLabel(
getTableCellText(textValue),
INVOICE_STATUS,
)}
/>
);
case 'payee':
return (
<EllipsisDiv
text={enumValueToLabel(
getTableCellText(textValue),
PAYEE_OPTIONS,
)}
/>
);
default:
return <EllipsisDiv text={getTableCellText(textValue)} />;
}
};
return newItem;
});
columns.push({
title: '操作',
valueType: 'option',
key: 'option',
fixed: 'right',
曾国涛
authored
9 months ago
125
width: 80,
曾国涛
authored
10 months ago
126
127
render: (text, record, _, action) => {
let btns = [];
曾国涛
authored
9 months ago
128
if (record.paths?.includes('editBankStatement')) {
曾国涛
authored
10 months ago
129
130
131
132
133
134
135
136
137
138
139
140
btns.push(
<a
key="editable"
onClick={() => {
action?.startEditable?.(record.id);
}}
>
编辑
</a>,
);
}
曾国涛
authored
8 months ago
141
if (record.paths?.includes('writeOff') && record.writeOffId !== null) {
曾国涛
authored
9 months ago
142
143
144
btns.push(
<InvoiceWriteOffModal
getData={async () => {
曾国涛
authored
9 months ago
145
console.log(record.writeOffId);
曾国涛
authored
9 months ago
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
const res = await postServiceInvoiceGetWriteOffRecord({
data: { id: record.writeOffId },
});
const data = res.data;
return {
invoiceWriteOffId: data.id,
invoices: data.invoiceDtos,
bankStatements: data.bankStatementDtos,
};
}}
key="writeOff"
triggerButton={<Button type="link">核销记录</Button>}
readOnly={true}
/>,
);
}
曾国涛
authored
9 months ago
163
if (record.paths?.includes('deleteBankStatement')) {
曾国涛
authored
10 months ago
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
btns.push(
<ButtonConfirm
key="delete"
className="p-0"
title={'是否删除该银行流水记录?'}
text="删除"
onConfirm={async () => {
let res = await postServiceBankStatementDeleteBankStatement({
data: { id: record.id },
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success(res.message);
reloadBankStatementTable();
}
}}
/>,
);
}
return btns;
},
});
return columns;
};
return (
<div className="invoice-index">
<ProTable
columns={bankStatemetColumnsInit()}
actionRef={bankActionRef}
cardBordered
pagination={{
曾国涛
authored
8 months ago
196
pageSizeOptions: ['10', '20', '50', '100'],
曾国涛
authored
10 months ago
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
}}
editable={{
type: 'multiple',
onSave: async (rowKey, data) => {
await postServiceBankStatementEditBankStatement({ data: data });
},
actionRender: (row, config, defaultDom) => [
defaultDom.save,
defaultDom.cancel,
],
}}
request={async (params) => {
const res = await postServiceBankStatementQueryBankStatement({
data: { ...params },
});
if (res) {
曾国涛
authored
8 months ago
213
setPerms(res?.data?.specialPath);
曾国涛
authored
10 months ago
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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',
曾国涛
authored
9 months ago
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
optionRender: (searchConfig, formProps, dom) => [
...dom.reverse(),
<Button
key="out"
onClick={() => {
const values = searchConfig?.form?.getFieldsValue();
messageApi.open({
type: 'loading',
content: '导出中...',
duration: 0,
});
orderExport(
'/api/service/invoice/exportBankStatements',
'银行流水.xlsx',
'POST',
values,
() => {
messageApi.destroy();
},
);
}}
>
导出
</Button>,
],
曾国涛
authored
10 months ago
258
259
260
261
262
263
264
265
266
267
268
}}
options={{
setting: {
listsHeight: 400,
},
}}
form={{}}
dateFormatter="string"
headerTitle="银行流水列表"
scroll={{ x: 1400, y: 360 }}
toolBarRender={() => [
曾国涛
authored
8 months ago
269
<>
曾国涛
authored
8 months ago
270
{perms?.includes('import') && (
曾国涛
authored
8 months ago
271
272
273
274
275
276
277
278
279
280
281
282
<Button
key="button"
icon={<PlusOutlined />}
onClick={() => {
setBankImportModalVisible(true);
}}
type="primary"
>
导入
</Button>
)}
</>,
曾国涛
authored
10 months ago
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
]}
/>
{bankImportModalVisible ? (
<BankImportModal
setVisible={setBankImportModalVisible}
onClose={() => {
setBankImportModalVisible(false);
invoiceActionRef.current?.reload();
bankActionRef.current?.reload();
}}
></BankImportModal>
) : (
''
)}
{invoiceVerificationVisible ? (
<InvoiceVerificationModal
setVisible={setInvoiceVerificationVisible}
invoiceId={invoiceId}
onClose={() => {
invoiceActionRef.current?.reload();
bankActionRef.current?.reload();
}}
></InvoiceVerificationModal>
) : (
''
)}
{invoiceRecordDetailVisible ? (
<InvoiceRecordDetailModal
key="detail"
id={invoiceRecord.id}
setVisible={setInvoiceRecordDetailVisible}
/>
) : (
''
)}
曾国涛
authored
9 months ago
320
{contextHolder}
曾国涛
authored
10 months ago
321
322
323
324
325
</div>
);
};
export default InvoiceRecord;