Commit b4527016d1b8b008ecd4ea1e060b9999f639c729
1 parent
0d3aa831
feat: 开票功能开发
Showing
4 changed files
with
220 additions
and
116 deletions
src/pages/Order/components/InvoicingDrawerForm.tsx
1 | +// import { PlusOutlined } from '@ant-design/icons'; | |
2 | +import { | |
3 | + postServiceConstInvoiceType, | |
4 | + postServiceConstInvoicingType, | |
5 | + postServiceInvoiceApplyInvoice, | |
6 | +} from '@/services'; | |
7 | +import { enumToSelect } from '@/utils'; | |
8 | +import { CloseCircleOutlined } from '@ant-design/icons'; | |
1 | 9 | import { |
2 | 10 | DrawerForm, |
11 | + ProFormGroup, | |
3 | 12 | ProFormList, |
4 | 13 | ProFormMoney, |
5 | 14 | ProFormSelect, |
6 | 15 | ProFormText, |
7 | 16 | ProFormUploadDragger, |
8 | 17 | } from '@ant-design/pro-components'; |
9 | -import { Form, message } from 'antd'; | |
10 | - | |
11 | -const waitTime = (time: number = 100) => { | |
12 | - return new Promise((resolve) => { | |
13 | - setTimeout(() => { | |
14 | - resolve(true); | |
15 | - }, time); | |
16 | - }); | |
17 | -}; | |
18 | - | |
19 | -export default ({ subOrders, onClose }) => { | |
20 | - const [form] = Form.useForm<{ name: string; company: string }>(); | |
18 | +import { Form } from 'antd'; | |
19 | +import { useEffect, useState } from 'react'; | |
20 | +import { PAYEE_OPTIONS } from '../constant'; | |
21 | 21 | |
22 | +export default ({ dataList, setVisible, onClose }) => { | |
23 | + // let subOrderIds = dataList?.map((item) => { | |
24 | + // return item.id; | |
25 | + // }); | |
26 | + const [invoiceTypeValueEnum, setInvoiceTypeValueEnum] = useState({}); | |
27 | + const [invoicingTypeValueEnum, setInvoicingTypeValueEnum] = useState({}); | |
28 | + let initEnum = async () => { | |
29 | + let invoiceTypeRet = await postServiceConstInvoiceType(); | |
30 | + setInvoiceTypeValueEnum(invoiceTypeRet.data); | |
31 | + let invoicingTypeRet = await postServiceConstInvoicingType(); | |
32 | + setInvoicingTypeValueEnum(invoicingTypeRet.data); | |
33 | + }; | |
34 | + useEffect(() => { | |
35 | + initEnum(); | |
36 | + }, []); | |
37 | + const [form] = Form.useForm(); | |
22 | 38 | return ( |
23 | - <DrawerForm<{ | |
24 | - name: string; | |
25 | - company: string; | |
26 | - }> | |
27 | - title="申请开票" | |
39 | + <DrawerForm | |
40 | + open | |
41 | + title="合并开票" | |
28 | 42 | resize={{ |
29 | 43 | onResize() { |
30 | 44 | console.log('resize!'); |
31 | 45 | }, |
32 | 46 | maxWidth: window.innerWidth * 0.8, |
33 | - minWidth: 300, | |
47 | + minWidth: 400, | |
34 | 48 | }} |
35 | 49 | form={form} |
36 | - /*trigger={ | |
37 | - <Button type="primary"> | |
38 | - <PlusOutlined /> | |
39 | - 新建表单 | |
40 | - </Button> | |
41 | - }*/ | |
42 | - open={true} | |
43 | 50 | autoFocusFirstInput |
44 | 51 | drawerProps={{ |
45 | 52 | destroyOnClose: true, |
46 | 53 | }} |
47 | 54 | submitTimeout={2000} |
48 | 55 | onFinish={async (values) => { |
49 | - await waitTime(2000); | |
50 | - console.log(values); | |
51 | - console.log(subOrders); | |
52 | - message.success('提交成功'); | |
56 | + postServiceInvoiceApplyInvoice({ | |
57 | + data: { | |
58 | + ...values, | |
59 | + subOrderIds: dataList.map((item) => { | |
60 | + return item.id; | |
61 | + }), | |
62 | + }, | |
63 | + }); | |
53 | 64 | onClose(); |
54 | - // 不返回不会关闭弹框 | |
55 | - return true; | |
65 | + }} | |
66 | + onOpenChange={(val) => { | |
67 | + return !val && setVisible(); | |
56 | 68 | }} |
57 | 69 | > |
58 | - <ProFormText | |
59 | - style={{ padding: 0 }} | |
60 | - width="md" | |
61 | - name="name" | |
62 | - label="开票订单" | |
63 | - /> | |
64 | 70 | <ProFormList |
65 | - name="subOrders" | |
66 | - creatorButtonProps={{ | |
67 | - creatorButtonText: '新建', | |
68 | - icon: false, | |
69 | - type: 'link', | |
70 | - style: { width: 'unset' }, | |
71 | + name="subOrderIdObjs" | |
72 | + label="开票订单" | |
73 | + /*initialValue={subOrders.map((item) => { | |
74 | + return { | |
75 | + value:item.id | |
76 | + } | |
77 | + })}*/ | |
78 | + deleteIconProps={{ | |
79 | + Icon: CloseCircleOutlined, | |
80 | + tooltipText: '不需要这行了', | |
71 | 81 | }} |
72 | - min={1} | |
73 | - copyIconProps={false} | |
74 | - deleteIconProps={{ tooltipText: '删除' }} | |
75 | - itemRender={({ listDom, action }) => ( | |
76 | - <div | |
77 | - style={{ | |
78 | - display: 'inline-flex', | |
79 | - marginInlineEnd: 25, | |
80 | - }} | |
81 | - > | |
82 | - {listDom} | |
83 | - {action} | |
84 | - </div> | |
85 | - )} | |
86 | 82 | > |
87 | - <ProFormText allowClear={false} width="xs" name={['name']} /> | |
83 | + <ProFormGroup key="group"> | |
84 | + <ProFormText name="value" label="" /> | |
85 | + </ProFormGroup> | |
88 | 86 | </ProFormList> |
89 | 87 | <ProFormText |
90 | 88 | rules={[ |
... | ... | @@ -93,7 +91,7 @@ export default ({ subOrders, onClose }) => { |
93 | 91 | }, |
94 | 92 | ]} |
95 | 93 | width="md" |
96 | - name="company" | |
94 | + name="partyAName" | |
97 | 95 | label="购方名称" |
98 | 96 | placeholder="请输入名称" |
99 | 97 | /> |
... | ... | @@ -104,7 +102,7 @@ export default ({ subOrders, onClose }) => { |
104 | 102 | }, |
105 | 103 | ]} |
106 | 104 | width="md" |
107 | - name="company" | |
105 | + name="partyATaxid" | |
108 | 106 | label="购方税号" |
109 | 107 | placeholder="请输入名称" |
110 | 108 | /> |
... | ... | @@ -115,7 +113,7 @@ export default ({ subOrders, onClose }) => { |
115 | 113 | }, |
116 | 114 | ]} |
117 | 115 | width="md" |
118 | - name="company" | |
116 | + name="partyAOpenBank" | |
119 | 117 | label="开户银行" |
120 | 118 | placeholder="请输入名称" |
121 | 119 | /> |
... | ... | @@ -126,55 +124,46 @@ export default ({ subOrders, onClose }) => { |
126 | 124 | }, |
127 | 125 | ]} |
128 | 126 | width="md" |
129 | - name="company" | |
127 | + name="partyABankAccount" | |
130 | 128 | label="开户行账号" |
131 | 129 | placeholder="请输入名称" |
132 | 130 | /> |
133 | 131 | <ProFormMoney |
134 | 132 | label="开票金额" |
135 | - name="amount2" | |
133 | + name="price" | |
136 | 134 | locale="en-GB" |
137 | 135 | initialValue={22.22} |
138 | 136 | /> |
139 | 137 | <ProFormSelect |
140 | - name="select" | |
138 | + name="invoicingType" | |
141 | 139 | label="开具类型" |
142 | - valueEnum={{ | |
143 | - open: '未解决', | |
144 | - closed: '已解决', | |
145 | - }} | |
146 | - placeholder="Please select a country" | |
147 | - rules={[{ required: true, message: 'Please select your country!' }]} | |
140 | + options={enumToSelect(invoicingTypeValueEnum)} | |
141 | + placeholder="请选择开具类型" | |
142 | + rules={[{ required: true, message: '请选择开具类型!' }]} | |
148 | 143 | /> |
149 | 144 | <ProFormSelect |
150 | - name="select" | |
145 | + name="type" | |
151 | 146 | label="开票类型" |
152 | - valueEnum={{ | |
153 | - open: '未解决', | |
154 | - closed: '已解决', | |
155 | - }} | |
156 | - placeholder="Please select a country" | |
157 | - rules={[{ required: true, message: 'Please select your country!' }]} | |
147 | + options={enumToSelect(invoiceTypeValueEnum)} | |
148 | + placeholder="请选择开票类型" | |
149 | + rules={[{ required: true, message: '请选择开票类型!' }]} | |
158 | 150 | /> |
159 | 151 | <ProFormSelect |
160 | - name="select" | |
152 | + name="partyBName" | |
161 | 153 | label="开票收款单位" |
162 | - valueEnum={{ | |
163 | - open: '未解决', | |
164 | - closed: '已解决', | |
165 | - }} | |
166 | - placeholder="Please select a country" | |
167 | - rules={[{ required: true, message: 'Please select your country!' }]} | |
154 | + options={enumToSelect(PAYEE_OPTIONS)} | |
155 | + placeholder="请选择收款单位" | |
156 | + rules={[{ required: true, message: '请选择收款单位!' }]} | |
168 | 157 | /> |
169 | 158 | <ProFormSelect |
170 | - name="select" | |
159 | + name="isUrgent" | |
171 | 160 | label="是否加急" |
172 | 161 | valueEnum={{ |
173 | - open: '未解决', | |
174 | - closed: '已解决', | |
162 | + true: '是', | |
163 | + false: '否', | |
175 | 164 | }} |
176 | - placeholder="Please select a country" | |
177 | - rules={[{ required: true, message: 'Please select your country!' }]} | |
165 | + placeholder="请选择是否加急" | |
166 | + rules={[{ required: true, message: '请选择是否加急!' }]} | |
178 | 167 | /> |
179 | 168 | <ProFormUploadDragger name="drag-pic" label="拖拽上传" /> |
180 | 169 | </DrawerForm> | ... | ... |
src/pages/Order/index.tsx
... | ... | @@ -123,8 +123,6 @@ const OrderPage = () => { |
123 | 123 | const [allMainChecked, setAllMainChecked] = useState(false); |
124 | 124 | const [imagesViewerModalVisible, setImagesViewerModalVisible] = |
125 | 125 | useState<boolean>(false); |
126 | - const [InvoicingDrawerFormVisible, setInvoicingDrawerFormVisible] = | |
127 | - useState<boolean>(false); | |
128 | 126 | const [data, setData] = useState([]); //列表数据 |
129 | 127 | const [notesEditVisible, setNotesEditVisible] = useState<boolean>(false); |
130 | 128 | const [financialMergeDrawerVisible, setFinancialMergeDrawerVisible] = |
... | ... | @@ -155,6 +153,8 @@ const OrderPage = () => { |
155 | 153 | useState<boolean>(false); |
156 | 154 | const [procureConvertModalVisible, setProcureConvertModalVisible] = |
157 | 155 | useState<boolean>(false); |
156 | + const [invoicingDrawerFormVisible, setInvoicingDrawerFormVisible] = | |
157 | + useState<boolean>(false); | |
158 | 158 | const [confirmReceiptVisible, setConfirmReceiptVisible] = |
159 | 159 | useState<boolean>(false); |
160 | 160 | const [productionTimeModalVisible, setProductionTimeModalVisible] = |
... | ... | @@ -3972,21 +3972,6 @@ const OrderPage = () => { |
3972 | 3972 | ); |
3973 | 3973 | } |
3974 | 3974 | |
3975 | - toolBtns.push( | |
3976 | - <Button | |
3977 | - type="primary" | |
3978 | - key="applyInvoicing" | |
3979 | - onClick={() => { | |
3980 | - setIsEdit(false); | |
3981 | - setIsMainOrder(true); | |
3982 | - setInvoicingDrawerFormVisible(true); | |
3983 | - }} | |
3984 | - disabled={selectedSubOrderKeys?.length === 0} | |
3985 | - > | |
3986 | - 申请开票 | |
3987 | - </Button>, | |
3988 | - ); | |
3989 | - | |
3990 | 3975 | if (rolePath?.includes('mergeInvoicing')) { |
3991 | 3976 | toolBtns.push( |
3992 | 3977 | <Button |
... | ... | @@ -4021,6 +4006,19 @@ const OrderPage = () => { |
4021 | 4006 | {roleCode === 'admin' ? '合并(财务)' : '合并开票'} |
4022 | 4007 | </Button>, |
4023 | 4008 | ); |
4009 | + toolBtns.push( | |
4010 | + <Button | |
4011 | + type="primary" | |
4012 | + key="inv" | |
4013 | + onClick={() => { | |
4014 | + setIsMainOrder(true); | |
4015 | + setInvoicingDrawerFormVisible(true); | |
4016 | + }} | |
4017 | + disabled={selectedSubOrderKeys?.length === 0} | |
4018 | + > | |
4019 | + 申请开票 | |
4020 | + </Button>, | |
4021 | + ); | |
4024 | 4022 | } |
4025 | 4023 | |
4026 | 4024 | if (rolePath?.includes('addOrder')) { |
... | ... | @@ -4638,24 +4636,27 @@ const OrderPage = () => { |
4638 | 4636 | }} |
4639 | 4637 | /> |
4640 | 4638 | )} |
4641 | - | |
4642 | - {InvoicingDrawerFormVisible && ( | |
4639 | + {invoicingDrawerFormVisible && ( | |
4643 | 4640 | <InvoicingDrawerForm |
4644 | - subOrders={ | |
4641 | + dataList={ | |
4645 | 4642 | isMainOrder |
4646 | 4643 | ? [...subOrderSelectedMap.values()].flat() |
4647 | 4644 | : buildSubOrders() |
4648 | 4645 | } |
4649 | - totalPayment={getApplyInvoicingTotalPayment()} | |
4646 | + setVisible={(val: boolean) => { | |
4647 | + setInvoicingDrawerFormVisible(val); | |
4648 | + if (!val) { | |
4649 | + clearOptObject(); | |
4650 | + } | |
4651 | + }} | |
4650 | 4652 | onClose={() => { |
4651 | - setApplyForInvoicingVisible(false); | |
4652 | - setIsMainOrder(false); | |
4653 | + setInvoicingDrawerFormVisible(false); | |
4654 | + setIsMainOrder(true); | |
4653 | 4655 | clearOptObject(); |
4654 | 4656 | refreshTable(); |
4655 | 4657 | }} |
4656 | - ></InvoicingDrawerForm> | |
4658 | + /> | |
4657 | 4659 | )} |
4658 | - | |
4659 | 4660 | {contextHolder} |
4660 | 4661 | <FloatButton.BackTop visibilityHeight={0} /> |
4661 | 4662 | </div> | ... | ... |
src/services/definition.ts
... | ... | @@ -1003,12 +1003,12 @@ export interface InvoiceRecordDto { |
1003 | 1003 | invoicingTime?: string; |
1004 | 1004 | /** |
1005 | 1005 | * @description |
1006 | - * 发票类型 | |
1006 | + * 开具类型 | |
1007 | 1007 | */ |
1008 | 1008 | invoicingType?: string; |
1009 | 1009 | /** |
1010 | 1010 | * @description |
1011 | - * 发票类型 | |
1011 | + * 开具类型 | |
1012 | 1012 | */ |
1013 | 1013 | invoicingTypeText?: string; |
1014 | 1014 | /** |
... | ... | @@ -1088,6 +1088,7 @@ export interface InvoiceRecordDto { |
1088 | 1088 | * 开票状态 |
1089 | 1089 | */ |
1090 | 1090 | statusText?: string; |
1091 | + subOrderIds?: Array<number>; | |
1091 | 1092 | /** |
1092 | 1093 | * @description |
1093 | 1094 | * 关联订单 |
... | ... | @@ -1819,6 +1820,11 @@ export interface QueryInvoiceRecordDto { |
1819 | 1820 | * @description |
1820 | 1821 | * 发票号码 |
1821 | 1822 | */ |
1823 | + invoiceNumber?: string; | |
1824 | + /** | |
1825 | + * @description | |
1826 | + * 发票号码 | |
1827 | + */ | |
1822 | 1828 | invoiceNumberLike?: string; |
1823 | 1829 | /** |
1824 | 1830 | * @description |
... | ... | @@ -1827,6 +1833,18 @@ export interface QueryInvoiceRecordDto { |
1827 | 1833 | invoicingTime?: string; |
1828 | 1834 | /** |
1829 | 1835 | * @description |
1836 | + * 开票时间 | |
1837 | + * @format date-time | |
1838 | + */ | |
1839 | + invoicingTimeGe?: string; | |
1840 | + /** | |
1841 | + * @description | |
1842 | + * 开票时间 | |
1843 | + * @format date-time | |
1844 | + */ | |
1845 | + invoicingTimeLe?: string; | |
1846 | + /** | |
1847 | + * @description | |
1830 | 1848 | * 开票类型 |
1831 | 1849 | */ |
1832 | 1850 | invoicingType?: string; |
... | ... | @@ -1840,6 +1858,12 @@ export interface QueryInvoiceRecordDto { |
1840 | 1858 | * 是否加急文本 |
1841 | 1859 | */ |
1842 | 1860 | isUrgentText?: string; |
1861 | + /** | |
1862 | + * @description | |
1863 | + * 订单号 | |
1864 | + * @format int64 | |
1865 | + */ | |
1866 | + mainOrderId?: number; | |
1843 | 1867 | mainOrderIdIn?: Array<number>; |
1844 | 1868 | /** |
1845 | 1869 | * @description |
... | ... | @@ -1885,6 +1909,11 @@ export interface QueryInvoiceRecordDto { |
1885 | 1909 | partyATaxid?: string; |
1886 | 1910 | /** |
1887 | 1911 | * @description |
1912 | + * 买方税号 | |
1913 | + */ | |
1914 | + partyATaxidLike?: string; | |
1915 | + /** | |
1916 | + * @description | |
1888 | 1917 | * 抬头类型 |
1889 | 1918 | */ |
1890 | 1919 | partyAType?: string; |
... | ... | @@ -1904,6 +1933,7 @@ export interface QueryInvoiceRecordDto { |
1904 | 1933 | * 接收邮箱地址 |
1905 | 1934 | */ |
1906 | 1935 | receiveEmail?: string; |
1936 | + salesCode?: string; | |
1907 | 1937 | /** |
1908 | 1938 | * @description |
1909 | 1939 | * 销售代表 |
... | ... | @@ -1914,14 +1944,27 @@ export interface QueryInvoiceRecordDto { |
1914 | 1944 | * 开票状态 |
1915 | 1945 | */ |
1916 | 1946 | status?: string; |
1947 | + statusIsNotNull?: boolean; | |
1948 | + statusIsNull?: boolean; | |
1917 | 1949 | /** |
1918 | 1950 | * @description |
1919 | 1951 | * 开票状态 |
1920 | 1952 | */ |
1921 | 1953 | statusText?: string; |
1954 | + /** | |
1955 | + * @description | |
1956 | + * 子订单 | |
1957 | + * @format int64 | |
1958 | + */ | |
1959 | + subOrderId?: number; | |
1922 | 1960 | subOrderIdIn?: Array<number>; |
1923 | 1961 | /** |
1924 | 1962 | * @description |
1963 | + * 子订单 | |
1964 | + */ | |
1965 | + subOrderIdLike?: string; | |
1966 | + /** | |
1967 | + * @description | |
1925 | 1968 | * 关联订单 |
1926 | 1969 | */ |
1927 | 1970 | subOrders?: Array<SubOrder>; | ... | ... |
src/services/request.ts
... | ... | @@ -8062,6 +8062,77 @@ export const postServiceInvoiceAddInvoice = /* #__PURE__ */ (() => { |
8062 | 8062 | return request; |
8063 | 8063 | })(); |
8064 | 8064 | |
8065 | +/** @description request parameter type for postServiceInvoiceApplyInvoice */ | |
8066 | +export interface PostServiceInvoiceApplyInvoiceOption { | |
8067 | + /** | |
8068 | + * @description | |
8069 | + * dto | |
8070 | + */ | |
8071 | + body: { | |
8072 | + /** | |
8073 | + @description | |
8074 | + dto */ | |
8075 | + dto: InvoiceRecordDto; | |
8076 | + }; | |
8077 | +} | |
8078 | + | |
8079 | +/** @description response type for postServiceInvoiceApplyInvoice */ | |
8080 | +export interface PostServiceInvoiceApplyInvoiceResponse { | |
8081 | + /** | |
8082 | + * @description | |
8083 | + * OK | |
8084 | + */ | |
8085 | + 200: ServerResult<SimplePageUtils<InvoiceRecordDto>>; | |
8086 | + /** | |
8087 | + * @description | |
8088 | + * Created | |
8089 | + */ | |
8090 | + 201: any; | |
8091 | + /** | |
8092 | + * @description | |
8093 | + * Unauthorized | |
8094 | + */ | |
8095 | + 401: any; | |
8096 | + /** | |
8097 | + * @description | |
8098 | + * Forbidden | |
8099 | + */ | |
8100 | + 403: any; | |
8101 | + /** | |
8102 | + * @description | |
8103 | + * Not Found | |
8104 | + */ | |
8105 | + 404: any; | |
8106 | +} | |
8107 | + | |
8108 | +export type PostServiceInvoiceApplyInvoiceResponseSuccess = | |
8109 | + PostServiceInvoiceApplyInvoiceResponse[200]; | |
8110 | +/** | |
8111 | + * @description | |
8112 | + * 申请开票 | |
8113 | + * @tags 发票 | |
8114 | + * @produces * | |
8115 | + * @consumes application/json | |
8116 | + */ | |
8117 | +export const postServiceInvoiceApplyInvoice = /* #__PURE__ */ (() => { | |
8118 | + const method = 'post'; | |
8119 | + const url = '/service/invoice/applyInvoice'; | |
8120 | + function request( | |
8121 | + option: PostServiceInvoiceApplyInvoiceOption, | |
8122 | + ): Promise<PostServiceInvoiceApplyInvoiceResponseSuccess> { | |
8123 | + return requester(request.url, { | |
8124 | + method: request.method, | |
8125 | + ...option, | |
8126 | + }) as unknown as Promise<PostServiceInvoiceApplyInvoiceResponseSuccess>; | |
8127 | + } | |
8128 | + | |
8129 | + /** http method */ | |
8130 | + request.method = method; | |
8131 | + /** request url */ | |
8132 | + request.url = url; | |
8133 | + return request; | |
8134 | +})(); | |
8135 | + | |
8065 | 8136 | /** @description request parameter type for postServiceInvoiceCancelInvoiceAndBankStatement */ |
8066 | 8137 | export interface PostServiceInvoiceCancelInvoiceAndBankStatementOption { |
8067 | 8138 | /** | ... | ... |