Commit 78063a4c87ed50ba0bef331e82be99b9e18e4e44

Authored by 曾国涛
1 parent c81dc397

feat: 开票功能开发

src/pages/Invoice/components/InvoiceDetailImportModal.tsx 0 → 100644
  1 +import { RESPONSE_CODE } from '@/constants/enum';
  2 +import { postServiceInvoiceImportInvoiceDetails } from '@/services';
  3 +import { ModalForm, ProFormUploadDragger } from '@ant-design/pro-components';
  4 +import { Button, Form, message } from 'antd';
  5 +
  6 +export default ({ recordId }) => {
  7 + const [form] = Form.useForm();
  8 + return (
  9 + <ModalForm
  10 + title="新建表单"
  11 + trigger={<Button type="primary">导入明细</Button>}
  12 + form={form}
  13 + autoFocusFirstInput
  14 + modalProps={{
  15 + destroyOnClose: true,
  16 + onCancel: () => console.log('run'),
  17 + }}
  18 + submitTimeout={2000}
  19 + onFinish={async (values) => {
  20 + const formData = new FormData();
  21 + // console.log(fileList[0] as RcFile)
  22 + // formData.append('file', fileList[0] as RcFile);
  23 + formData.append('invoiceRecordId', recordId);
  24 + formData.append('detailsExcel', values.detailsExcel[0].originFileObj);
  25 + // You can use any AJAX library you like
  26 + const res = await postServiceInvoiceImportInvoiceDetails({
  27 + data: formData,
  28 + headers: {
  29 + 'Content-Type':
  30 + 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
  31 + },
  32 + });
  33 + if (res.result === RESPONSE_CODE.SUCCESS) {
  34 + message.success('导入成功');
  35 + return true;
  36 + }
  37 + }}
  38 + >
  39 + <ProFormUploadDragger name="detailsExcel" label="导入明细表" />
  40 + </ModalForm>
  41 + );
  42 +};
src/pages/Invoice/components/InvoiceDetailTable.tsx
  1 +import InvoiceDetailImportModal from '@/pages/Invoice/components/InvoiceDetailImportModal';
1 import type { ProColumns } from '@ant-design/pro-components'; 2 import type { ProColumns } from '@ant-design/pro-components';
2 import { 3 import {
3 EditableProTable, 4 EditableProTable,
4 ProCard, 5 ProCard,
5 ProFormField, 6 ProFormField,
6 } from '@ant-design/pro-components'; 7 } from '@ant-design/pro-components';
7 -import { Button } from 'antd';  
8 import { useEffect, useState } from 'react'; 8 import { useEffect, useState } from 'react';
9 9
10 -export default ({ details, updateDetails, readOnly }) => { 10 +export default ({ recordId, details, updateDetails, readOnly }) => {
11 const [editableKeys, setEditableRowKeys] = useState([]); 11 const [editableKeys, setEditableRowKeys] = useState([]);
12 12
13 useEffect(() => { 13 useEffect(() => {
@@ -56,7 +56,7 @@ export default ({ details, updateDetails, readOnly }) =&gt; { @@ -56,7 +56,7 @@ export default ({ details, updateDetails, readOnly }) =&gt; {
56 { 56 {
57 title: '金额', 57 title: '金额',
58 readonly: readOnly, 58 readonly: readOnly,
59 - dataIndex: 'taxPrice', 59 + dataIndex: 'totalPrice',
60 valueType: 'digit', 60 valueType: 'digit',
61 width: '30%', 61 width: '30%',
62 }, 62 },
@@ -109,16 +109,7 @@ export default ({ details, updateDetails, readOnly }) =&gt; { @@ -109,16 +109,7 @@ export default ({ details, updateDetails, readOnly }) =&gt; {
109 } 109 }
110 toolBarRender={() => { 110 toolBarRender={() => {
111 return [ 111 return [
112 - <Button  
113 - type="primary"  
114 - key="save"  
115 - onClick={() => {  
116 - // dataSource 就是当前数据,可以调用 api 将其保存  
117 - console.log(details);  
118 - }}  
119 - >  
120 - 保存数据  
121 - </Button>, 112 + <InvoiceDetailImportModal key={'import'} recordId={recordId} />,
122 ]; 113 ];
123 }} 114 }}
124 editable={{ 115 editable={{
src/pages/Invoice/components/InvoiceRecordDetailModal.tsx
@@ -43,24 +43,24 @@ export default ({ id }) =&gt; { @@ -43,24 +43,24 @@ export default ({ id }) =&gt; {
43 }; 43 };
44 getPayees(); 44 getPayees();
45 }, []); 45 }, []);
  46 + const getRecord = async (id) => {
  47 + let ret = await postServiceInvoiceGetInvoiceRecord({
  48 + query: {
  49 + id: id,
  50 + },
  51 + });
  52 + const updatedInvoiceDetails = ret.data.invoiceDetails?.map(
  53 + (item, index) => ({
  54 + ...item, // 保留原有属性
  55 + tid: index + 1, // 添加tid属性,这里以T开头,后面跟索引+1,仅作示例,实际可根据需求生成tid
  56 + }),
  57 + );
  58 + setDetailTableData(updatedInvoiceDetails);
  59 + setInitialValues(ret.data);
  60 + };
46 useEffect(() => { 61 useEffect(() => {
47 - const initRecord = async (id) => {  
48 - let ret = await postServiceInvoiceGetInvoiceRecord({  
49 - query: {  
50 - id: id,  
51 - },  
52 - });  
53 - const updatedInvoiceDetails = ret.data.invoiceDetails?.map(  
54 - (item, index) => ({  
55 - ...item, // 保留原有属性  
56 - tid: index + 1, // 添加tid属性,这里以T开头,后面跟索引+1,仅作示例,实际可根据需求生成tid  
57 - }),  
58 - );  
59 - setDetailTableData(updatedInvoiceDetails);  
60 - setInitialValues(ret.data);  
61 - };  
62 if (!visible) { 62 if (!visible) {
63 - initRecord(id); 63 + getRecord(id);
64 } 64 }
65 }, [visible]); 65 }, [visible]);
66 66
@@ -330,6 +330,7 @@ export default ({ id }) =&gt; { @@ -330,6 +330,7 @@ export default ({ id }) =&gt; {
330 订单信息 330 订单信息
331 <hr /> 331 <hr />
332 <InvoiceDetailTable 332 <InvoiceDetailTable
  333 + recordId={id}
333 details={detailTableData} 334 details={detailTableData}
334 updateDetails={updateDetails} 335 updateDetails={updateDetails}
335 readOnly={readOnly} 336 readOnly={readOnly}
src/services/definition.ts
@@ -2477,9 +2477,9 @@ export interface InvoiceDetail { @@ -2477,9 +2477,9 @@ export interface InvoiceDetail {
2477 specification?: string; 2477 specification?: string;
2478 /** @format int64 */ 2478 /** @format int64 */
2479 subOrderId?: number; 2479 subOrderId?: number;
2480 - /** @format int32 */ 2480 + /** @format double */
2481 taxPrice?: number; 2481 taxPrice?: number;
2482 - /** @format int32 */ 2482 + /** @format double */
2483 taxRate?: number; 2483 taxRate?: number;
2484 /** 2484 /**
2485 * @description 2485 * @description
src/services/request.ts
@@ -54,6 +54,7 @@ import type { @@ -54,6 +54,7 @@ import type {
54 MaterialUnitListRes, 54 MaterialUnitListRes,
55 MeasureUnitListRes, 55 MeasureUnitListRes,
56 MessageQueryDTO, 56 MessageQueryDTO,
  57 + ModelAndView,
57 OrderAddVO, 58 OrderAddVO,
58 OrderAuditLogQueryVO, 59 OrderAuditLogQueryVO,
59 OrderBaseInfoQueryVO, 60 OrderBaseInfoQueryVO,
@@ -1539,9 +1540,7 @@ export interface GetErrorResponse { @@ -1539,9 +1540,7 @@ export interface GetErrorResponse {
1539 * @description 1540 * @description
1540 * OK 1541 * OK
1541 */ 1542 */
1542 - 200: {  
1543 - [propertyName: string]: any;  
1544 - }; 1543 + 200: ModelAndView;
1545 /** 1544 /**
1546 * @description 1545 * @description
1547 * Unauthorized 1546 * Unauthorized
@@ -1562,9 +1561,9 @@ export interface GetErrorResponse { @@ -1562,9 +1561,9 @@ export interface GetErrorResponse {
1562 export type GetErrorResponseSuccess = GetErrorResponse[200]; 1561 export type GetErrorResponseSuccess = GetErrorResponse[200];
1563 /** 1562 /**
1564 * @description 1563 * @description
1565 - * error 1564 + * errorHtml
1566 * @tags basic-error-controller 1565 * @tags basic-error-controller
1567 - * @produces * 1566 + * @produces text/html
1568 */ 1567 */
1569 export const getError = /* #__PURE__ */ (() => { 1568 export const getError = /* #__PURE__ */ (() => {
1570 const method = 'get'; 1569 const method = 'get';
@@ -1588,9 +1587,7 @@ export interface PutErrorResponse { @@ -1588,9 +1587,7 @@ export interface PutErrorResponse {
1588 * @description 1587 * @description
1589 * OK 1588 * OK
1590 */ 1589 */
1591 - 200: {  
1592 - [propertyName: string]: any;  
1593 - }; 1590 + 200: ModelAndView;
1594 /** 1591 /**
1595 * @description 1592 * @description
1596 * Created 1593 * Created
@@ -1616,9 +1613,9 @@ export interface PutErrorResponse { @@ -1616,9 +1613,9 @@ export interface PutErrorResponse {
1616 export type PutErrorResponseSuccess = PutErrorResponse[200]; 1613 export type PutErrorResponseSuccess = PutErrorResponse[200];
1617 /** 1614 /**
1618 * @description 1615 * @description
1619 - * error 1616 + * errorHtml
1620 * @tags basic-error-controller 1617 * @tags basic-error-controller
1621 - * @produces * 1618 + * @produces text/html
1622 * @consumes application/json 1619 * @consumes application/json
1623 */ 1620 */
1624 export const putError = /* #__PURE__ */ (() => { 1621 export const putError = /* #__PURE__ */ (() => {
@@ -1643,9 +1640,7 @@ export interface PostErrorResponse { @@ -1643,9 +1640,7 @@ export interface PostErrorResponse {
1643 * @description 1640 * @description
1644 * OK 1641 * OK
1645 */ 1642 */
1646 - 200: {  
1647 - [propertyName: string]: any;  
1648 - }; 1643 + 200: ModelAndView;
1649 /** 1644 /**
1650 * @description 1645 * @description
1651 * Created 1646 * Created
@@ -1671,9 +1666,9 @@ export interface PostErrorResponse { @@ -1671,9 +1666,9 @@ export interface PostErrorResponse {
1671 export type PostErrorResponseSuccess = PostErrorResponse[200]; 1666 export type PostErrorResponseSuccess = PostErrorResponse[200];
1672 /** 1667 /**
1673 * @description 1668 * @description
1674 - * error 1669 + * errorHtml
1675 * @tags basic-error-controller 1670 * @tags basic-error-controller
1676 - * @produces * 1671 + * @produces text/html
1677 * @consumes application/json 1672 * @consumes application/json
1678 */ 1673 */
1679 export const postError = /* #__PURE__ */ (() => { 1674 export const postError = /* #__PURE__ */ (() => {
@@ -1698,9 +1693,7 @@ export interface DeleteErrorResponse { @@ -1698,9 +1693,7 @@ export interface DeleteErrorResponse {
1698 * @description 1693 * @description
1699 * OK 1694 * OK
1700 */ 1695 */
1701 - 200: {  
1702 - [propertyName: string]: any;  
1703 - }; 1696 + 200: ModelAndView;
1704 /** 1697 /**
1705 * @description 1698 * @description
1706 * No Content 1699 * No Content
@@ -1721,9 +1714,9 @@ export interface DeleteErrorResponse { @@ -1721,9 +1714,9 @@ export interface DeleteErrorResponse {
1721 export type DeleteErrorResponseSuccess = DeleteErrorResponse[200]; 1714 export type DeleteErrorResponseSuccess = DeleteErrorResponse[200];
1722 /** 1715 /**
1723 * @description 1716 * @description
1724 - * error 1717 + * errorHtml
1725 * @tags basic-error-controller 1718 * @tags basic-error-controller
1726 - * @produces * 1719 + * @produces text/html
1727 */ 1720 */
1728 export const deleteError = /* #__PURE__ */ (() => { 1721 export const deleteError = /* #__PURE__ */ (() => {
1729 const method = 'delete'; 1722 const method = 'delete';
@@ -1747,9 +1740,7 @@ export interface OptionsErrorResponse { @@ -1747,9 +1740,7 @@ export interface OptionsErrorResponse {
1747 * @description 1740 * @description
1748 * OK 1741 * OK
1749 */ 1742 */
1750 - 200: {  
1751 - [propertyName: string]: any;  
1752 - }; 1743 + 200: ModelAndView;
1753 /** 1744 /**
1754 * @description 1745 * @description
1755 * No Content 1746 * No Content
@@ -1770,9 +1761,9 @@ export interface OptionsErrorResponse { @@ -1770,9 +1761,9 @@ export interface OptionsErrorResponse {
1770 export type OptionsErrorResponseSuccess = OptionsErrorResponse[200]; 1761 export type OptionsErrorResponseSuccess = OptionsErrorResponse[200];
1771 /** 1762 /**
1772 * @description 1763 * @description
1773 - * error 1764 + * errorHtml
1774 * @tags basic-error-controller 1765 * @tags basic-error-controller
1775 - * @produces * 1766 + * @produces text/html
1776 * @consumes application/json 1767 * @consumes application/json
1777 */ 1768 */
1778 export const optionsError = /* #__PURE__ */ (() => { 1769 export const optionsError = /* #__PURE__ */ (() => {
@@ -1797,9 +1788,7 @@ export interface HeadErrorResponse { @@ -1797,9 +1788,7 @@ export interface HeadErrorResponse {
1797 * @description 1788 * @description
1798 * OK 1789 * OK
1799 */ 1790 */
1800 - 200: {  
1801 - [propertyName: string]: any;  
1802 - }; 1791 + 200: ModelAndView;
1803 /** 1792 /**
1804 * @description 1793 * @description
1805 * No Content 1794 * No Content
@@ -1820,9 +1809,9 @@ export interface HeadErrorResponse { @@ -1820,9 +1809,9 @@ export interface HeadErrorResponse {
1820 export type HeadErrorResponseSuccess = HeadErrorResponse[200]; 1809 export type HeadErrorResponseSuccess = HeadErrorResponse[200];
1821 /** 1810 /**
1822 * @description 1811 * @description
1823 - * error 1812 + * errorHtml
1824 * @tags basic-error-controller 1813 * @tags basic-error-controller
1825 - * @produces * 1814 + * @produces text/html
1826 * @consumes application/json 1815 * @consumes application/json
1827 */ 1816 */
1828 export const headError = /* #__PURE__ */ (() => { 1817 export const headError = /* #__PURE__ */ (() => {
@@ -1847,9 +1836,7 @@ export interface PatchErrorResponse { @@ -1847,9 +1836,7 @@ export interface PatchErrorResponse {
1847 * @description 1836 * @description
1848 * OK 1837 * OK
1849 */ 1838 */
1850 - 200: {  
1851 - [propertyName: string]: any;  
1852 - }; 1839 + 200: ModelAndView;
1853 /** 1840 /**
1854 * @description 1841 * @description
1855 * No Content 1842 * No Content
@@ -1870,9 +1857,9 @@ export interface PatchErrorResponse { @@ -1870,9 +1857,9 @@ export interface PatchErrorResponse {
1870 export type PatchErrorResponseSuccess = PatchErrorResponse[200]; 1857 export type PatchErrorResponseSuccess = PatchErrorResponse[200];
1871 /** 1858 /**
1872 * @description 1859 * @description
1873 - * error 1860 + * errorHtml
1874 * @tags basic-error-controller 1861 * @tags basic-error-controller
1875 - * @produces * 1862 + * @produces text/html
1876 * @consumes application/json 1863 * @consumes application/json
1877 */ 1864 */
1878 export const patchError = /* #__PURE__ */ (() => { 1865 export const patchError = /* #__PURE__ */ (() => {
@@ -7132,6 +7119,77 @@ export const postOrderErpUsersUpdatePass = /* #__PURE__ */ (() =&gt; { @@ -7132,6 +7119,77 @@ export const postOrderErpUsersUpdatePass = /* #__PURE__ */ (() =&gt; {
7132 return request; 7119 return request;
7133 })(); 7120 })();
7134 7121
  7122 +/** @description request parameter type for postOrderImportImportInvoiceProject */
  7123 +export interface PostOrderImportImportInvoiceProjectOption {
  7124 + /**
  7125 + * @description
  7126 + * file
  7127 + */
  7128 + formData: {
  7129 + /**
  7130 + @description
  7131 + file */
  7132 + file: File;
  7133 + };
  7134 +}
  7135 +
  7136 +/** @description response type for postOrderImportImportInvoiceProject */
  7137 +export interface PostOrderImportImportInvoiceProjectResponse {
  7138 + /**
  7139 + * @description
  7140 + * OK
  7141 + */
  7142 + 200: ServerResult;
  7143 + /**
  7144 + * @description
  7145 + * Created
  7146 + */
  7147 + 201: any;
  7148 + /**
  7149 + * @description
  7150 + * Unauthorized
  7151 + */
  7152 + 401: any;
  7153 + /**
  7154 + * @description
  7155 + * Forbidden
  7156 + */
  7157 + 403: any;
  7158 + /**
  7159 + * @description
  7160 + * Not Found
  7161 + */
  7162 + 404: any;
  7163 +}
  7164 +
  7165 +export type PostOrderImportImportInvoiceProjectResponseSuccess =
  7166 + PostOrderImportImportInvoiceProjectResponse[200];
  7167 +/**
  7168 + * @description
  7169 + * 导入发票项目
  7170 + * @tags 导入
  7171 + * @produces *
  7172 + * @consumes multipart/form-data
  7173 + */
  7174 +export const postOrderImportImportInvoiceProject = /* #__PURE__ */ (() => {
  7175 + const method = 'post';
  7176 + const url = '/order/import/importInvoiceProject';
  7177 + function request(
  7178 + option: PostOrderImportImportInvoiceProjectOption,
  7179 + ): Promise<PostOrderImportImportInvoiceProjectResponseSuccess> {
  7180 + return requester(request.url, {
  7181 + method: request.method,
  7182 + ...option,
  7183 + }) as unknown as Promise<PostOrderImportImportInvoiceProjectResponseSuccess>;
  7184 + }
  7185 +
  7186 + /** http method */
  7187 + request.method = method;
  7188 + /** request url */
  7189 + request.url = url;
  7190 + return request;
  7191 +})();
  7192 +
7135 /** @description request parameter type for postOrderImportImportWeightAndVolume */ 7193 /** @description request parameter type for postOrderImportImportWeightAndVolume */
7136 export interface PostOrderImportImportWeightAndVolumeOption { 7194 export interface PostOrderImportImportWeightAndVolumeOption {
7137 /** 7195 /**
@@ -8685,6 +8743,93 @@ export const postServiceInvoiceGetInvoiceRecord = /* #__PURE__ */ (() =&gt; { @@ -8685,6 +8743,93 @@ export const postServiceInvoiceGetInvoiceRecord = /* #__PURE__ */ (() =&gt; {
8685 return request; 8743 return request;
8686 })(); 8744 })();
8687 8745
  8746 +/** @description request parameter type for postServiceInvoiceImportInvoiceDetails */
  8747 +export interface PostServiceInvoiceImportInvoiceDetailsOption {
  8748 + /**
  8749 + * @description
  8750 + * detailsExcel
  8751 + */
  8752 + formData: {
  8753 + /**
  8754 + @description
  8755 + detailsExcel */
  8756 + detailsExcel: File;
  8757 + };
  8758 +}
  8759 +
  8760 +/** @description request parameter type for postServiceInvoiceImportInvoiceDetails */
  8761 +export interface PostServiceInvoiceImportInvoiceDetailsOption {
  8762 + /**
  8763 + * @description
  8764 + * invoiceRecordId
  8765 + * @format int64
  8766 + */
  8767 + query: {
  8768 + /**
  8769 + @description
  8770 + invoiceRecordId
  8771 + @format int64 */
  8772 + invoiceRecordId: number;
  8773 + };
  8774 +}
  8775 +
  8776 +/** @description response type for postServiceInvoiceImportInvoiceDetails */
  8777 +export interface PostServiceInvoiceImportInvoiceDetailsResponse {
  8778 + /**
  8779 + * @description
  8780 + * OK
  8781 + */
  8782 + 200: ServerResult;
  8783 + /**
  8784 + * @description
  8785 + * Created
  8786 + */
  8787 + 201: any;
  8788 + /**
  8789 + * @description
  8790 + * Unauthorized
  8791 + */
  8792 + 401: any;
  8793 + /**
  8794 + * @description
  8795 + * Forbidden
  8796 + */
  8797 + 403: any;
  8798 + /**
  8799 + * @description
  8800 + * Not Found
  8801 + */
  8802 + 404: any;
  8803 +}
  8804 +
  8805 +export type PostServiceInvoiceImportInvoiceDetailsResponseSuccess =
  8806 + PostServiceInvoiceImportInvoiceDetailsResponse[200];
  8807 +/**
  8808 + * @description
  8809 + * 导入发票明细
  8810 + * @tags 发票
  8811 + * @produces *
  8812 + * @consumes multipart/form-data
  8813 + */
  8814 +export const postServiceInvoiceImportInvoiceDetails = /* #__PURE__ */ (() => {
  8815 + const method = 'post';
  8816 + const url = '/service/invoice/importInvoiceDetails';
  8817 + function request(
  8818 + option: PostServiceInvoiceImportInvoiceDetailsOption,
  8819 + ): Promise<PostServiceInvoiceImportInvoiceDetailsResponseSuccess> {
  8820 + return requester(request.url, {
  8821 + method: request.method,
  8822 + ...option,
  8823 + }) as unknown as Promise<PostServiceInvoiceImportInvoiceDetailsResponseSuccess>;
  8824 + }
  8825 +
  8826 + /** http method */
  8827 + request.method = method;
  8828 + /** request url */
  8829 + request.url = url;
  8830 + return request;
  8831 +})();
  8832 +
8688 /** @description request parameter type for postServiceInvoiceInvoiceWriteOff */ 8833 /** @description request parameter type for postServiceInvoiceInvoiceWriteOff */
8689 export interface PostServiceInvoiceInvoiceWriteOffOption { 8834 export interface PostServiceInvoiceInvoiceWriteOffOption {
8690 /** 8835 /**