Commit 80092cd120a3b400089d09d9bd25aea1039fb406

Authored by 曾国涛
1 parent 01578991

refactor(order): 确保枚举值在引用前正确定义

重构订单页面的枚举值引用,确保在使用之前已经定义。这避免了在组件中直接引用枚举值可能导致的错误。添加了核销记录按钮,以提供更直观的访问点。
- 修正了银行报表删除操作的错误,该操作在以前的代码中错误地包含了。

这些变化提供了更流畅的用户体验,并确保用户可以更有效地执行核销相关操作。
src/pages/Invoice/Invoice/components/invoiceWriteOffModal.tsx
... ... @@ -104,29 +104,27 @@ export default ({ getData, triggerButton, readOnly }) => {
104 104 valueType: 'date',
105 105 },
106 106 ];
107   - if (!readOnly) {
108   - columns.push({
109   - title: '操作',
110   - valueType: 'option',
111   - width: 200,
112   - render: (text, record) => [
113   - <a
114   - key="delete"
115   - onClick={() => {
116   - const tableDataSource =
117   - formRef.current?.getFieldValue('bankStatements');
118   - console.log(JSON.stringify(tableDataSource));
119   - formRef.current?.setFieldValue(
120   - 'bankStatements',
121   - tableDataSource.filter((item) => item.id !== record.id),
122   - );
123   - }}
124   - >
125   - 删除
126   - </a>,
127   - ],
128   - });
129   - }
  107 + columns.push({
  108 + title: '操作',
  109 + valueType: 'option',
  110 + width: 200,
  111 + render: (text, record) => [
  112 + <a
  113 + key="delete"
  114 + onClick={() => {
  115 + const tableDataSource =
  116 + formRef.current?.getFieldValue('bankStatements');
  117 + console.log(JSON.stringify(tableDataSource));
  118 + formRef.current?.setFieldValue(
  119 + 'bankStatements',
  120 + tableDataSource.filter((item) => item.id !== record.id),
  121 + );
  122 + }}
  123 + >
  124 + 删除
  125 + </a>,
  126 + ],
  127 + });
130 128 return columns;
131 129 };
132 130  
... ... @@ -295,30 +293,27 @@ export default ({ getData, triggerButton, readOnly }) =&gt; {
295 293 recordCreatorProps={false}
296 294 toolBarRender={() => [
297 295 <>
298   - {!readOnly && (
299   - <AddBankStatementModal
300   - getRows={() => formRef.current?.getFieldValue('bankStatements')}
301   - onFinish={(datas) => {
302   - const bankStatements =
303   - formRef.current?.getFieldValue('bankStatements');
304   - // 添加非空判断,并处理为空的情况
305   - const mergedBankStatements =
306   - bankStatements && Array.isArray(bankStatements)
307   - ? bankStatements
308   - : [];
309   - const mergedDatas =
310   - datas && Array.isArray(datas) ? datas : [];
311   - let res = [...mergedBankStatements, ...mergedDatas];
312   - //对res 进行去重处理,根据id去重
313   - const resMap = new Map();
314   - res.forEach((item) => {
315   - resMap.set(item.id, item);
316   - });
317   - res = Array.from(resMap.values());
318   - formRef.current?.setFieldValue('bankStatements', res);
319   - }}
320   - />
321   - )}
  296 + <AddBankStatementModal
  297 + getRows={() => formRef.current?.getFieldValue('bankStatements')}
  298 + onFinish={(datas) => {
  299 + const bankStatements =
  300 + formRef.current?.getFieldValue('bankStatements');
  301 + // 添加非空判断,并处理为空的情况
  302 + const mergedBankStatements =
  303 + bankStatements && Array.isArray(bankStatements)
  304 + ? bankStatements
  305 + : [];
  306 + const mergedDatas = datas && Array.isArray(datas) ? datas : [];
  307 + let res = [...mergedBankStatements, ...mergedDatas];
  308 + //对res 进行去重处理,根据id去重
  309 + const resMap = new Map();
  310 + res.forEach((item) => {
  311 + resMap.set(item.id, item);
  312 + });
  313 + res = Array.from(resMap.values());
  314 + formRef.current?.setFieldValue('bankStatements', res);
  315 + }}
  316 + />
322 317 </>,
323 318 ]}
324 319 columns={getBankStatementColumns()}
... ...
src/pages/Invoice/InvoiceVerification/index.tsx
1 1 import ButtonConfirm from '@/components/ButtomConfirm';
2 2 import EllipsisDiv from '@/components/Div/EllipsisDiv';
3 3 import { RESPONSE_CODE } from '@/constants/enum';
  4 +import InvoiceWriteOffModal from '@/pages/Invoice/Invoice/components/invoiceWriteOffModal';
4 5 import BankImportModal from '@/pages/Invoice/InvoiceVerification/components/BankImportModal';
5 6 import InvoiceRecordDetailModal from '@/pages/Invoice/InvoiceVerification/components/InvoiceRecordDetailModal';
6 7 import InvoiceVerificationModal from '@/pages/Invoice/InvoiceVerification/components/InvoiceVerificationModal';
... ... @@ -13,6 +14,7 @@ import {
13 14 postServiceBankStatementDeleteBankStatement,
14 15 postServiceBankStatementEditBankStatement,
15 16 postServiceBankStatementQueryBankStatement,
  17 + postServiceInvoiceGetWriteOffRecord,
16 18 } from '@/services';
17 19 import { enumValueToLabel, formatDateTime } from '@/utils';
18 20 import { formatDate } from '@/utils/time';
... ... @@ -133,6 +135,27 @@ const InvoiceRecord = () =&gt; {
133 135 );
134 136 }
135 137  
  138 + if (record.writeOffId !== null) {
  139 + btns.push(
  140 + <InvoiceWriteOffModal
  141 + getData={async () => {
  142 + const res = await postServiceInvoiceGetWriteOffRecord({
  143 + data: { id: record.writeOffId },
  144 + });
  145 + const data = res.data;
  146 + return {
  147 + invoiceWriteOffId: data.id,
  148 + invoices: data.invoiceDtos,
  149 + bankStatements: data.bankStatementDtos,
  150 + };
  151 + }}
  152 + key="writeOff"
  153 + triggerButton={<Button type="link">核销记录</Button>}
  154 + readOnly={true}
  155 + />,
  156 + );
  157 + }
  158 +
136 159 if (record.paths?.includes('deleteBankStatement')) {
137 160 btns.push(
138 161 <ButtonConfirm
... ...