曾国涛
authored
|
1
|
import { RESPONSE_CODE } from '@/constants/enum';
|
曾国涛
authored
|
2
|
import UploadC from '@/pages/Invoice/components/UploadSingleImg';
|
曾国涛
authored
|
3
4
5
6
|
import {
postOrderErpOrderStagesUpload,
postServiceInvoiceDealInvoicingResult,
} from '@/services';
|
曾国涛
authored
|
7
8
|
import {
ModalForm,
|
曾国涛
authored
|
9
|
ProCard,
|
曾国涛
authored
|
10
|
ProFormDatePicker,
|
曾国涛
authored
|
11
|
ProFormDigit,
|
曾国涛
authored
|
12
|
ProFormList,
|
曾国涛
authored
|
13
|
ProFormMoney,
|
曾国涛
authored
|
14
15
16
17
|
ProFormText,
} from '@ant-design/pro-components';
import { Col, Form, Row, message } from 'antd';
import { RcFile } from 'antd/es/upload';
|
曾国涛
authored
|
18
|
import { useEffect } from 'react';
|
曾国涛
authored
|
19
|
|
曾国涛
authored
|
20
|
export default ({ record }) => {
|
曾国涛
authored
|
21
22
23
24
|
useEffect(() => {
console.log('invoicing');
}, []);
const [form] = Form.useForm();
|
曾国涛
authored
|
25
|
return (
|
曾国涛
authored
|
26
|
<ModalForm
|
曾国涛
authored
|
27
28
|
title="手动开票"
trigger={<a type="primary">手动开票</a>}
|
曾国涛
authored
|
29
|
width={600}
|
曾国涛
authored
|
30
31
32
33
34
35
36
37
38
|
layout={'horizontal'}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitTimeout={2000}
onFinish={async (values) => {
|
曾国涛
authored
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
const res = await postServiceInvoiceDealInvoicingResult({
data: {
...values,
isSuccess: true,
invoiceRecordId: record.id,
manual: true,
},
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success('开票成功');
return true;
} else {
message.error('开票失败');
}
|
曾国涛
authored
|
53
54
|
}}
>
|
曾国涛
authored
|
55
56
57
58
59
60
61
62
63
64
65
66
|
<ProFormText
rules={[{ required: true, message: '此项为必填项' }]}
width={'md'}
name="invoicingPerson"
label="开票人"
/>
<ProFormText
rules={[{ required: true, message: '此项为必填项' }]}
width={'md'}
name="invoiceNumber"
label="发票号码"
/>
|
曾国涛
authored
|
67
|
<ProFormDatePicker
|
曾国涛
authored
|
68
|
rules={[{ required: true, message: '此项为必填项' }]}
|
曾国涛
authored
|
69
|
fieldProps={{
|
曾国涛
authored
|
70
|
format: 'YYYY-MM-DD',
|
曾国涛
authored
|
71
72
73
74
|
}}
name="invoicingDate"
label="开票日期"
/>
|
曾国涛
authored
|
75
76
77
78
79
80
|
<ProFormText
rules={[{ required: true, message: '发票必须上传' }]}
hidden
name="url"
label="發票地址"
/>
|
曾国涛
authored
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<Row>
<Col span={4}>上传发票</Col>
<Col span={20}>
<UploadC
onFilesChange={async (newFileList) => {
if (newFileList.length > 0) {
const formData = new FormData();
formData.append('file', newFileList[0].originFileObj as RcFile);
const res = await postOrderErpOrderStagesUpload({
data: formData,
headers: {
'Content-Type':
'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
},
});
const url = res.data;
form.setFieldValue('url', url);
} else {
form.setFieldValue('url', null);
}
}}
></UploadC>
</Col>
</Row>
|
曾国涛
authored
|
105
|
<ProFormList
|
曾国涛
authored
|
106
|
name="invoiceDetailDtoList"
|
曾国涛
authored
|
107
108
109
|
label="明细"
creatorButtonProps={false}
copyIconProps={false}
|
曾国涛
authored
|
110
|
itemRender={({ listDom }, { index }) => (
|
曾国涛
authored
|
111
112
113
114
115
116
117
118
119
120
121
|
<ProCard
bordered
style={{ marginBlockEnd: 8 }}
title={`明细${index + 1}`}
bodyStyle={{ paddingBlockEnd: 0 }}
>
{listDom}
</ProCard>
)}
creatorRecord={{ name: '', items: [{ name: '' }] }}
initialValue={record.invoiceDetails}
|
曾国涛
authored
|
122
123
124
125
126
127
128
129
130
131
|
>
<ProFormText
name="projectName"
label="名称"
placeholder="请输入名称"
readonly
/>
<ProFormDigit label="税率" name="taxRate" min={0} max={100} />
<ProFormMoney label="税额" name="taxPrice" locale="zh-CN" min={0} />
</ProFormList>
|
曾国涛
authored
|
132
133
134
|
</ModalForm>
);
};
|