InvoicingDrawerForm.tsx
4.56 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
// import { PlusOutlined } from '@ant-design/icons';
import {
postServiceConstInvoiceType,
postServiceConstInvoicingType,
postServiceInvoiceApplyInvoice,
} from '@/services';
import { enumToSelect } from '@/utils';
import {
DrawerForm,
ProFormGroup,
ProFormList,
ProFormMoney,
ProFormSelect,
ProFormText,
ProFormTextArea,
ProFormUploadDragger,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import { useEffect } from 'react';
import { PAYEE_OPTIONS } from '../constant';
export default ({ dataList, mainOrder, setVisible, onClose }) => {
// let subOrderIds = dataList?.map((item) => {
// return item.id;
// });
const [form] = Form.useForm();
useEffect(() => {}, []);
return (
<DrawerForm
open
title="合并开票"
resize={{
onResize() {
console.log('resize!');
},
maxWidth: window.innerWidth * 0.8,
minWidth: 400,
}}
form={form}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
}}
submitTimeout={2000}
onFinish={async (values) => {
postServiceInvoiceApplyInvoice({
data: {
...values,
subOrderIds: dataList.map((item) => {
return item.id;
}),
},
});
onClose();
}}
onOpenChange={(val) => {
return !val && setVisible();
}}
>
<ProFormList
name="subOrderIdObjs"
readonly={true}
label="开票订单"
initialValue={dataList.map((item) => {
return {
value: item.id,
};
})}
deleteIconProps={false}
>
<ProFormGroup key="group">
<ProFormText readonly={true} name="value" label="" />
</ProFormGroup>
</ProFormList>
<ProFormText
rules={[
{
required: true,
},
]}
width="md"
name="partyAName"
label="购方名称"
initialValue={mainOrder.institution}
placeholder="请输入名称"
/>
<ProFormText
rules={[
{
required: true,
},
]}
width="md"
name="partyATaxid"
label="购方税号"
placeholder="请输入名称"
/>
<ProFormText
width="md"
name="partyAOpenBank"
label="开户银行"
placeholder="请输入名称"
/>
<ProFormText
width="md"
name="partyABankAccount"
label="开户行账号"
placeholder="请输入名称"
/>
<ProFormMoney
label="开票金额"
name="price"
locale="zh-CN"
rules={[{ required: true, message: '请填写开票金额!' }]}
initialValue={dataList.reduce((accumulator, currentValue) => {
return accumulator + currentValue.subOrderPayment;
}, 0)}
/>
<ProFormSelect
name="invoicingType"
label="开具类型"
request={async () => {
let invoicingTypeRet = await postServiceConstInvoicingType();
let options = enumToSelect(invoicingTypeRet.data);
return options;
}}
placeholder="请选择开具类型"
rules={[{ required: true, message: '请选择开具类型!' }]}
/>
<ProFormSelect
name="type"
label="开票类型"
placeholder="请选择开票类型"
rules={[{ required: true, message: '请选择开票类型!' }]}
request={async () => {
let invoiceTypeRet = await postServiceConstInvoiceType();
let options = enumToSelect(invoiceTypeRet.data);
return options;
}}
/>
<ProFormSelect
name="partyBName"
label="开票收款单位"
options={enumToSelect(PAYEE_OPTIONS)}
placeholder="请选择收款单位"
rules={[{ required: true, message: '请选择收款单位!' }]}
/>
<ProFormSelect
name="isUrgent"
label="是否加急"
valueEnum={{
true: '是',
false: '否',
}}
placeholder="请选择是否加急"
rules={[{ required: true, message: '请选择是否加急!' }]}
/>
<ProFormUploadDragger
key="filePaths"
label="附件"
name="filePaths"
action="/api/service/order/fileProcess"
fieldProps={{
headers: { Authorization: localStorage.getItem('token') },
}}
/>
<ProFormTextArea
name="applyInvoicingNotes"
label="备注"
placeholder="请输入名称"
/>
</DrawerForm>
);
};