InvoiceVerificationModal.tsx
4.66 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
import { INVOCING_STATUS, PAYEE_OPTIONS } from '@/pages/Order/constant';
import { postServiceInvoiceQueryInvoiceDetail } from '@/services';
import { enumValueToLabel } from '@/utils';
import { formatDate } from '@/utils/time';
import { ActionType, ModalForm, ProCard } from '@ant-design/pro-components';
import {
Button,
Descriptions,
DescriptionsProps,
Divider,
Flex,
Form,
} from 'antd';
import { useEffect, useRef, useState } from 'react';
import { INVOICE_STATUS } from '../../constant';
import '../index.less';
import BankChooseModal from './BankChooseModal';
export default ({ invoiceId, setVisible, onClose }) => {
const [form] = Form.useForm<{ id: string }>();
const [bankChooseModalVisible, setBankChooseModalVisible] = useState(false);
const [invoiceInfo, setInvoiceInfo] = useState({});
const [relationOrderIds, setRelationOrderIds] = useState([]);
const [setRelationBankStatements] = useState([]);
const actionRef = useRef<ActionType>();
const loadInvoiceData = async () => {
let res = await postServiceInvoiceQueryInvoiceDetail({
data: { invoiceId: invoiceId },
});
if (res && res.data) {
setInvoiceInfo(res.data);
setRelationOrderIds(res.data.mainOrderIds);
console.log('bs:' + res.data.bankStatementDtos);
setRelationBankStatements(res.data.bankStatementDtos);
}
};
const showRelationOrders = () => {
return relationOrderIds?.map((item) => {
return (
<>
<Button
className="pl-1 pr-0"
type="link"
target="_blank"
href={'/order/order?id=' + item}
>
{item}
</Button>
<Divider type="vertical" />
</>
);
});
};
const items: DescriptionsProps['items'] = [
{
key: '1',
label: '发票号码',
children: invoiceInfo?.invoiceNumber,
span: 6,
},
{
key: '2',
label: '发票类型',
children: enumValueToLabel(invoiceInfo?.invoiceStatus, INVOCING_STATUS),
span: 6,
},
{
key: '3',
label: '状态',
children: enumValueToLabel(invoiceInfo?.status, INVOICE_STATUS),
span: 4,
},
{
key: '4',
label: '购买方',
children: invoiceInfo?.purchaser,
span: 8,
},
{
key: '5',
label: '收款单位',
children: enumValueToLabel(invoiceInfo?.payee, PAYEE_OPTIONS),
span: 12,
},
{
key: '6',
label: '联系人',
children: invoiceInfo?.contacts,
span: 4,
},
{
key: '7',
label: '销售',
children: invoiceInfo?.sale,
span: 8,
},
{
key: '9',
label: '开票日期',
children: formatDate(invoiceInfo?.invoicingTime),
span: 12,
},
{
key: '10',
label: '收款时间',
children: formatDate(invoiceInfo?.collectionTime),
span: 4,
},
{
key: '8',
label: '金额',
children: invoiceInfo?.money,
span: 10,
},
{
key: '11',
label: '备注',
children: invoiceInfo?.notes,
span: 24,
},
];
useEffect(() => {
loadInvoiceData();
}, []);
return (
<>
<ModalForm<{
id: string;
}>
className="invoice-detail"
open
width="80%"
title="发票详情"
form={form}
autoFocusFirstInput
modalProps={{
okText: '确定',
cancelText: '返回',
destroyOnClose: true,
onCancel: () => {
setVisible(false);
onClose();
},
}}
submitter={{
render: (props, defaultDoms) => {
return [defaultDoms[0]];
},
}}
onFinish={async () => {
onClose();
}}
onOpenChange={setVisible}
>
<Divider orientation="left" plain>
发票信息
</Divider>
<Descriptions
bordered
column={24}
size="small"
title=""
items={items}
/>
<Divider orientation="left" plain>
订单号
</Divider>
<ProCard bordered style={{}}>
<Flex>
<div>{showRelationOrders()}</div>
</Flex>
</ProCard>
<Divider plain></Divider>
</ModalForm>
{bankChooseModalVisible ? (
<BankChooseModal
loadInvoiceData={loadInvoiceData}
setVisible={setBankChooseModalVisible}
invoiceId={invoiceId}
onClose={() => {
setBankChooseModalVisible(false);
loadInvoiceData();
actionRef.current?.reload();
}}
></BankChooseModal>
) : (
''
)}
</>
);
};