From 3e56632e34554eee195dc4cd0ee1863685bd6144 Mon Sep 17 00:00:00 2001 From: WenC <450292408@qq.com> Date: Wed, 3 Apr 2024 18:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=91=E7=A5=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/invoice/InvoiceList.tsx | 1 + src/components/invoice/InvoiceSave.tsx | 68 +++++++-- .../invoice/info/InvoiceInfoList.tsx | 136 ++++++++++++++++++ .../invoice/info/InvoiceInfoSave.tsx | 78 ++++++++++ src/components/payment/Payment.tsx | 1 - src/util/AjaxUtils.ts | 19 +++ 6 files changed, 287 insertions(+), 16 deletions(-) create mode 100644 src/components/invoice/info/InvoiceInfoList.tsx create mode 100644 src/components/invoice/info/InvoiceInfoSave.tsx diff --git a/src/components/invoice/InvoiceList.tsx b/src/components/invoice/InvoiceList.tsx index 4b13bc6..f503279 100644 --- a/src/components/invoice/InvoiceList.tsx +++ b/src/components/invoice/InvoiceList.tsx @@ -185,6 +185,7 @@ export default function InvoiceList() { diff --git a/src/components/invoice/InvoiceSave.tsx b/src/components/invoice/InvoiceSave.tsx index d7aff6f..3fd457d 100644 --- a/src/components/invoice/InvoiceSave.tsx +++ b/src/components/invoice/InvoiceSave.tsx @@ -1,5 +1,8 @@ -import {Button, Divider, Form, Input, Radio, Space} from "antd"; -import {useState} from "react"; +import {Button, Divider, Flex, Form, Input, Modal, Radio, Space} from "antd"; +import {useEffect, useState} from "react"; +import {listDictionary, IDictionary} from "../../util/AjaxUtils.ts"; +import useMessage from "antd/es/message/useMessage"; +import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; type FormFieldType = { invoiceTitle: string; @@ -14,11 +17,32 @@ type FormFieldType = { } export default function InvoiceSave() { + const [messageApi, messageContext] = useMessage(); const [form] = Form.useForm(); const [isSaveInvoiceInfo, setIsSaveInvoiceInfo] = useState(0); + const [contentArray, setContentArray] = useState([]); + const [rateArray, setRateArray] = useState([]); + const [typeArray, setTypeArray] = useState([]); + + useEffect(() => { + // 开票内容 + listDictionary('e0251d55-cd52-4f57-be92-b2bef8a6dd62', messageApi).then((data)=>{ + setContentArray([...data]); + }) + // 开票税率 + listDictionary('b67d5208-db1d-4d0e-99de-cc22d9d50041', messageApi).then((data)=>{ + setRateArray([...data]); + }) + // 开票类型 + listDictionary('e4808c45-64ee-42fa-a413-a470fbdc0aea', messageApi).then((data)=>{ + setTypeArray([...data]); + }) + }, []); + return ( <> + {messageContext}
- A - B - C - D + {contentArray.map(item => {item.dataName})} @@ -131,10 +152,7 @@ export default function InvoiceSave() { rules={[{required: true, message: '请选择开票税率'}]} > - A - B - C - D + {rateArray.map(item => {item.dataName})} @@ -148,10 +166,9 @@ export default function InvoiceSave() { rules={[{required: true, message: '请选择发票类型'}]} > - A - B - C - D + + {typeArray.map(item => {item.dataName})} + @@ -183,7 +200,9 @@ export default function InvoiceSave() {
300 - +
@@ -201,7 +220,26 @@ export default function InvoiceSave() { + + + + + + + +
+ + + ); } \ No newline at end of file diff --git a/src/components/invoice/info/InvoiceInfoList.tsx b/src/components/invoice/info/InvoiceInfoList.tsx new file mode 100644 index 0000000..4dd0f1d --- /dev/null +++ b/src/components/invoice/info/InvoiceInfoList.tsx @@ -0,0 +1,136 @@ +import {Button, Modal, Space, Table, TableProps} from "antd"; +import {DeleteOutlined, EditOutlined, PlusOutlined} from "@ant-design/icons"; +import useMessage from "antd/es/message/useMessage"; +import {useEffect, useState} from "react"; +import {get} from "../../../util/AjaxUtils.ts"; +import {IListPage} from "../../../interfaces/listpage/IListPage.ts"; +import InvoiceInfoSave from "./InvoiceInfoSave.tsx"; + +type DataType = { + invoiceTitle: string; + invoicePhone: string; + invoiceNo: string; + invoiceInfoId: string; + invoiceBank: string; + invoiceAddress: string; + invoiceAccount: string; + gmtCreate: number; + creator: string; +} + +export default function InvoiceInfoList() { + const [messageApi, messageContext] = useMessage(); + const [page, setPage] = useState(1); + const [total, setTotal] = useState(0); + const [dataArray, setDataArray] = useState([]); + + const columns: TableProps['columns'] = [ + { + title: '公司名称', + dataIndex: 'invoiceTitle', + align: 'center', + width: 180, + fixed: 'left' + }, + { + title: '纳税人识别号', + dataIndex: 'invoiceNo', + align: 'center', + width: 180 + }, + { + title: '公司地址', + dataIndex: 'invoiceAddress', + align: 'center', + width: 180 + }, + { + title: '联系电话', + dataIndex: 'invoicePhone', + align: 'center', + width: 180 + }, + { + title: '开户行', + dataIndex: 'invoiceBank', + align: 'center', + width: 180 + }, + { + title: '开户行账号', + dataIndex: 'invoiceAccount', + align: 'center', + width: 180 + }, + { + title: '操作', + dataIndex: 'option', + align: 'center', + width: 100, + fixed: 'right', + render: () => { + return ( + + + + + ) + } + }, + ] + + useEffect(() => { + get>({ + messageApi, + url: '/api/invoice-info/listpage/self', + config: { + params: { + page: page, + rows: 20 + } + }, + onSuccess({data}) { + setPage(data.page); + setTotal(data.total); + setDataArray(data.rows); + } + }) + }, [page]); + + return ( + <> +
+
+
+ +
+ { + console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); + }, + } + } columns={columns} dataSource={dataArray} pagination={ + { + pageSize: 20, + total: total, + onChange: (currentPage) => { + setPage(currentPage); + } + } + } scroll={{y: 500}} bordered key="dataTable" rowKey="invoiceInfoId"/> + + + + + + {messageContext} + + ); +} \ No newline at end of file diff --git a/src/components/invoice/info/InvoiceInfoSave.tsx b/src/components/invoice/info/InvoiceInfoSave.tsx new file mode 100644 index 0000000..690a17e --- /dev/null +++ b/src/components/invoice/info/InvoiceInfoSave.tsx @@ -0,0 +1,78 @@ +import {Button, Flex, Form, Input, Space} from "antd"; +import {useForm} from "antd/es/form/Form"; + +type FormDataType = { + invoiceTitle: string; + invoicePhone: string; + invoiceNo: string; + invoiceBank: string; + invoiceAddress: string; + invoiceAccount: string; +} + +export default function InvoiceInfoSave() { + + const [form] = useForm() + + return ( + <> +
{ + + }} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} \ No newline at end of file diff --git a/src/components/payment/Payment.tsx b/src/components/payment/Payment.tsx index edaedd1..73eaeed 100644 --- a/src/components/payment/Payment.tsx +++ b/src/components/payment/Payment.tsx @@ -384,7 +384,6 @@ export default function Payment(props: IPaymentProps) {
{ post({ diff --git a/src/util/AjaxUtils.ts b/src/util/AjaxUtils.ts index 7d1e129..e9a84ad 100644 --- a/src/util/AjaxUtils.ts +++ b/src/util/AjaxUtils.ts @@ -18,6 +18,13 @@ type Req = { onFinally?(): void; } +export interface IDictionary { + dataId: string; + dataParentId: string; + dataName: string; + dataCode: string; +} + axios.interceptors.request.use(config => { if (config.method === 'get') { config.data = {unused: 0} // 这个是关键点,解决get 请求添加不上content_type @@ -39,6 +46,18 @@ export function uploadFileUrl() { return `${Axios.defaults?.baseURL}/api/file/v2/upload-file`; } +export async function listDictionary(parentId: string, messageApi: MessageInstance) { + return new Promise(resolve => { + get({ + messageApi, + url: `/api/data/listbyparentid/${parentId}`, + onSuccess({data}) { + resolve(data); + } + }) + }) +} + export function get(req: Req) { req.onBefore?.(); Axios.get(req.url, req.config).then(res => {