From f59ab1d7c4f149c3699a92b3b08d538273333bef Mon Sep 17 00:00:00 2001 From: lyp Date: Wed, 2 Apr 2025 15:30:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/invoice/InvoiceEdit.tsx | 1115 +++++++++-------- src/components/invoice/InvoiceList.tsx | 258 ++-- src/components/invoice/InvoiceSave.tsx | 1093 ++++++++-------- src/components/invoice/InvoiceShow.tsx | 98 +- src/components/invoice/NewInvoiceEdit.tsx | 424 +++++++ src/components/invoice/NewInvoiceSave.tsx | 357 ++++++ .../invoice/info/InvoiceInfoEdit.tsx | 131 +- .../invoice/info/InvoiceInfoList.tsx | 260 ++-- .../invoice/info/InvoiceInfoSave.tsx | 85 +- .../invoice/order/InvoiceOrderList.tsx | 302 ++--- .../order/InvoiceOrderSelectedList.tsx | 307 +++-- src/components/list/ListProj.tsx | 6 +- src/layout/head/Head.tsx | 33 +- src/request/api.ts | 26 + src/request/request.ts | 7 +- 15 files changed, 2829 insertions(+), 1673 deletions(-) create mode 100644 src/components/invoice/NewInvoiceEdit.tsx create mode 100644 src/components/invoice/NewInvoiceSave.tsx diff --git a/src/components/invoice/InvoiceEdit.tsx b/src/components/invoice/InvoiceEdit.tsx index ac4e876..7a15b5e 100644 --- a/src/components/invoice/InvoiceEdit.tsx +++ b/src/components/invoice/InvoiceEdit.tsx @@ -1,577 +1,580 @@ -import {Button,Flex, Form, Input, Modal, Radio, Space} from "antd"; -import {useEffect, useState} from "react"; -import {listDictionary, IDictionary, get, put} from "../../util/AjaxUtils.ts"; -import useMessage from "antd/es/message/useMessage"; -import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; -import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; -import useModal from "antd/es/modal/useModal"; +// import {Button,Flex, Form, Input, Modal, Radio, Space} from "antd"; +// import {useEffect, useState} from "react"; +// import {listDictionary, IDictionary, get, put} from "../../util/AjaxUtils.ts"; +// import useMessage from "antd/es/message/useMessage"; +// import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; +// import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; +// import useModal from "antd/es/modal/useModal"; -type FormFieldType = { - invoiceTitle: string; - invoiceNo: string; - invoiceAddress: string; - invoicePhone: string; - invoiceAccount: string; - invoiceBank: string; - content: string; - rate: string; - type: string; - orderIds: string[]; - invoiceNote: string; - isSaveInvoiceInfo: boolean; - invoiceAmount: number; -} +// type FormFieldType = { +// invoiceTitle: string; +// invoiceNo: string; +// invoiceAddress: string; +// invoicePhone: string; +// invoiceAccount: string; +// invoiceBank: string; +// content: string; +// rate: string; +// type: string; +// orderIds: string[]; +// invoiceNote: string; +// isSaveInvoiceInfo: boolean; +// invoiceAmount: number; +// } -type EditProps = { - invoiceId: string; - handleOk: () => void; - handleCancel: () => void; - // invdataArray: any[]; -} +// type EditProps = { +// invoiceId: string; +// handleOk: () => void; +// handleCancel: () => void; +// // invdataArray: any[]; +// } -export default function InvoiceEdit(props: EditProps) { - const [messageApi, messageContext] = useMessage(); - const [modal, modalContext] = useModal(); - const [form] = Form.useForm(); - const [contentArray, setContentArray] = useState([]); - const [rateArray, setRateArray] = useState([]); - const [typeArray, setTypeArray] = useState([]); - const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); - const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); - const [orderAmount, setOrderAmount] = useState('0'); +// export default function InvoiceEdit(props: EditProps) { +// const [messageApi, messageContext] = useMessage(); +// const [modal, modalContext] = useModal(); +// const [form] = Form.useForm(); +// const [contentArray, setContentArray] = useState([]); +// const [rateArray, setRateArray] = useState([]); +// const [typeArray, setTypeArray] = useState([]); +// const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); +// const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); +// const [orderAmount, setOrderAmount] = useState('0'); - useEffect(() => { - if(!props.invoiceId) { - return; - } - // 开票内容 - 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]); - }) - get({ - messageApi, - url: `/api/invoice/get/${props.invoiceId}`, - onSuccess({data}) { - form.setFieldsValue(data); - setOrderAmount((data.invoiceAmount / 100).toFixed(2)); - } - }) +// useEffect(() => { +// if(!props.invoiceId) { +// return; +// } +// // 开票内容 +// 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]); +// }) +// get({ +// messageApi, +// url: `/api/invoice/get/${props.invoiceId}`, +// onSuccess({data}) { +// form.setFieldsValue(data); +// setOrderAmount((data.invoiceAmount / 100).toFixed(2)); +// } +// }) - }, []); +// }, []); - return ( - <> - {messageContext} - {modalContext} -
{ - modal.confirm({ - title: '提示', - centered: true, - content: '确定提交吗?', - okText: '确定', - cancelText: '取消', - okButtonProps: { - style: { - backgroundColor: 'val(--color-primary)' - } - }, - onOk: () => { - put({ - messageApi, - url: `/api/invoice/update/${props.invoiceId}`, - body: values, - onSuccess() { - messageApi.success('提交成功'); - props.handleOk(); - } - }) - } - }); - }} - > - {/* 开票信息 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// return ( +// <> +// {messageContext} +// {modalContext} +// { +// modal.confirm({ +// title: '提示', +// centered: true, +// content: '确定提交吗?', +// okText: '确定', +// cancelText: '取消', +// okButtonProps: { +// style: { +// backgroundColor: 'val(--color-primary)' +// } +// }, +// onOk: () => { +// put({ +// messageApi, +// url: `/api/invoice/update/${props.invoiceId}`, +// body: values, +// onSuccess() { +// messageApi.success('提交成功'); +// props.handleOk(); +// } +// }) +// } +// }); +// }} +// > +// {/* 开票信息 +//
- -
公司名称 * - - - -
纳税人识别号 * - - - -
公司地址 * - - - -
联系电话 * - - - -
开户行 * - - - -
开户行账号 * - - - -
开票内容 * - - - - {contentArray.map(item => {item.dataName})} - - - -
开票税率 * - - - {rateArray.map(item => {item.dataName})} - - -
发票类型 * - - - - {typeArray.map(item => {item.dataName})} - - - -
+// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// - - - - - -
+// +//
公司名称 * +// +// +// +//
纳税人识别号 * +// +// +// +//
公司地址 * +// +// +// +//
联系电话 * +// +// +// +//
开户行 * +// +// +// +//
开户行账号 * +// +// +// +//
开票内容 * +// +// +// +// {contentArray.map(item => {item.dataName})} +// +// +// +//
开票税率 * +// +// +// {rateArray.map(item => {item.dataName})} +// +// +//
发票类型 * +// +// +// +// {typeArray.map(item => {item.dataName})} +// +// +// +//
保存开票信息 * - - - - - - -
- 开票内容 - - - - - - - - - - - - - - - -
开票金额 * - -
- - {orderAmount} - -
-
-
开票备注 - - - -
*/} -
-
-
开票信息
-
- -
-
-
-
公司名称*
- - - -
-
-
纳税人识别号*
- - - -
+// +// 保存开票信息 * +// +// +// +// +// +// +// +// +// +// +// +// 开票内容 +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +//
开票金额 * +// +//
+// +// {orderAmount} +// +//
+//
+//
开票备注 +// +// +// +//
*/} +//
+//
+//
开票信息
+//
+// +//
+//
+//
+//
公司名称*
+// +// +// +//
+//
+//
纳税人识别号*
+// +// +// +//
-
-
-
-
公司地址*
- - - -
-
-
联系电话*
- - - -
+//
+//
+//
+//
公司地址*
+// +// +// +//
+//
+//
联系电话*
+// +// +// +//
-
-
-
-
开户行*
- - - -
-
-
开户行账号*
- - - -
+//
+//
+//
+//
开户行*
+// +// +// +//
+//
+//
开户行账号*
+// +// +// +//
-
-
-
-
开票内容*
- - -
- {contentArray.map(item => {item.dataName})} -
-
-
-
-
-
开票税率*
- - -
- {rateArray.map(item => {item.dataName})} -
-
-
-
+//
+//
+//
+//
开票内容*
+// +// +//
+// {contentArray.map(item => {item.dataName})} +//
+//
+//
+//
+//
+//
开票税率*
+// +// +//
+// {rateArray.map(item => {item.dataName})} +//
+//
+//
+//
-
-
+//
-
-
发票类型*
- - -
- {typeArray.map(item => {item.dataName})} -
-
-
-
-
-
保存开票信息*
- - -
- - -
-
-
-
+// }}> +//
+//
发票类型*
+// +// +//
+// {typeArray.map(item => {item.dataName})} +//
+//
+//
+//
+//
+//
保存开票信息*
+// +// +//
+// +// +//
+//
+//
+//
-
-
-
-
开票内容
-
-
-
开票金额*
- -
- - {orderAmount} - -
-
-
-
-
开票备注
- - - -
-
-
-
- - - - - - - - - - setIsInvoiceInfoListOpen(false)} - > - { - form.setFieldsValue({ - invoiceTitle: selectedInvoice.invoiceTitle, - invoiceNo: selectedInvoice.invoiceNo, - invoiceAddress: selectedInvoice.invoiceAddress, - invoicePhone: selectedInvoice.invoicePhone, - invoiceAccount: selectedInvoice.invoiceAccount, - invoiceBank: selectedInvoice.invoiceBank - }); - setIsInvoiceInfoListOpen(false); - }} - handleCancel={() => { - setIsInvoiceInfoListOpen(false); - }} - /> - - setIsInvoiceOrderListOpen(false)} - > - { - let totalAmount = 0; - const orderIds: string[] = []; - selectedOrders.forEach((item) => { - totalAmount += item.totalAmount; - orderIds.push(item.orderId); - }); - setOrderAmount((totalAmount / 100).toFixed(2)); - setIsInvoiceOrderListOpen(false); - form.setFieldValue('orderIds', orderIds); - }} - handleCancel={() => { - setIsInvoiceOrderListOpen(false); - }} - /> - - - ); -} \ No newline at end of file +//
+//
+//
+//
开票内容
+//
+//
+//
开票金额*
+// +//
+// +// {orderAmount} +// +//
+//
+//
+//
+//
开票备注
+// +// +// +//
+//
+//
+//
+// +// +// +// +// +// +// +// +// +// setIsInvoiceInfoListOpen(false)} +// > +// { +// form.setFieldsValue({ +// invoiceTitle: selectedInvoice.invoiceTitle, +// invoiceNo: selectedInvoice.invoiceNo, +// invoiceAddress: selectedInvoice.invoiceAddress, +// invoicePhone: selectedInvoice.invoicePhone, +// invoiceAccount: selectedInvoice.invoiceAccount, +// invoiceBank: selectedInvoice.invoiceBank +// }); +// setIsInvoiceInfoListOpen(false); +// }} +// handleCancel={() => { +// setIsInvoiceInfoListOpen(false); +// }} +// /> +// +// setIsInvoiceOrderListOpen(false)} +// centered + +// > +// { +// let totalAmount = 0; +// const orderIds: string[] = []; +// selectedOrders.forEach((item) => { +// totalAmount += item.totalAmount; +// orderIds.push(item.orderId); +// }); +// setOrderAmount((totalAmount / 100).toFixed(2)); +// setIsInvoiceOrderListOpen(false); +// form.setFieldValue('orderIds', orderIds); +// }} +// handleCancel={() => { +// setIsInvoiceOrderListOpen(false); +// }} +// /> +// +// +// ); +// } \ No newline at end of file diff --git a/src/components/invoice/InvoiceList.tsx b/src/components/invoice/InvoiceList.tsx index a14f097..d626295 100644 --- a/src/components/invoice/InvoiceList.tsx +++ b/src/components/invoice/InvoiceList.tsx @@ -1,22 +1,27 @@ -import { Button, Dropdown, Flex, MenuProps, Modal, Popconfirm, Space, Table, TableProps, Tag } from "antd"; +import { Button, Dropdown, Flex, MenuProps, Modal, Popconfirm, Space, Table, TableProps, Tag, Spin } from "antd"; import { PlusOutlined } from "@ant-design/icons"; import { useEffect, // useRef, - useState + useState, + useContext } from "react"; -import { get, put } from "../../util/AjaxUtils.ts"; -import { IListPage } from "../../interfaces/listpage/IListPage.ts"; +import { getInvoiceRecordList,cancelInvoice } from "../../request/api.ts"; +import {downloadInvoice} from '../../request/request.ts' +import { GlobalContext } from "../../context/GlobalContext.ts"; +// import { get, put } from "../../util/AjaxUtils.ts"; +// import { IListPage } from "../../interfaces/listpage/IListPage.ts"; import useMessage from "antd/es/message/useMessage"; -import InvoiceSave from "./InvoiceSave.tsx"; -import InvoiceEdit from "./InvoiceEdit.tsx"; +// import InvoiceSave from "./InvoiceSave.tsx"; +import InvoiceSave from "./NewInvoiceSave.tsx"; +import InvoiceEdit from "./NewInvoiceEdit.tsx"; import InvoiceShow from "./InvoiceShow.tsx"; enum InvoiceStatusEnum { - PENDING = 'PENDING', - COMPLETE = 'COMPLETE', - FAILED = 'FAILED', - CANCEL = 'CANCEL', + PENDING = '1', + COMPLETE = '2', + FAILED = '0', + CANCEL = '-1', } type DataType = { @@ -38,6 +43,8 @@ type DataType = { invoiceStatus: InvoiceStatusEnum; invoiceTitle: string; orderIds: string[]; + invoiceRechargeId: string; + invoiceFile: string; } export default function InvoiceList() { @@ -49,57 +56,80 @@ export default function InvoiceList() { const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [isShowModalOpen, setIsShowModalOpen] = useState(false); // const invoiceId = useRef(''); - const [invoiceId, setInvoiceId] = useState(''); + // const [invoiceId, setInvoiceId] = useState(''); + + const [status, setStatus] = useState(''); //状态 + const [invoiceRechargeId, setInvoiceRechargeId] = useState(''); //查看订单主键 // const [invdataArray,setInvDataArray] = useState([]); + //点击取消 + const cancel = async(value:string) => { + try{ + await cancelInvoice(value) + getData() + messageApi.open({ + type: 'success', + content: '取消成功', + }) + }catch(error: any) { + + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + + }; const columns: TableProps['columns'] = [ { title: '名称', - dataIndex: 'invoiceTitle', + dataIndex: 'invoiceName', align: 'center', width: 180 }, { 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', + dataIndex: 'invoiceNumber', align: 'center', width: 180 }, + // { + // title: '地址', + // dataIndex: 'invoiceOrgaddress', + // align: 'center', + // width: 180 + // }, + // { + // title: '电话', + // dataIndex: 'invoiceOrgtel', + // align: 'center', + // width: 180 + // }, + // { + // title: '开户行', + // dataIndex: 'invoiceBank', + // align: 'center', + // width: 180 + // }, + // { + // title: '开户行账号', + // dataIndex: 'invoiceBanknumber', + // align: 'center', + // width: 180 + // }, { title: '金额', - dataIndex: 'invoiceAmount', + dataIndex: 'invoiceRechargeMoney', align: 'center', width: 160, - render: (value) => { - return (value / 100).toFixed(2) - } }, { title: '备注', - dataIndex: 'invoiceNote', + dataIndex: 'invoiceRecord', align: 'center', width: 180 }, @@ -114,7 +144,7 @@ export default function InvoiceList() { dataIndex: 'invoiceStatus', align: 'center', width: 100, - fixed: 'right', + // fixed: 'right', render: (value) => { if (value === InvoiceStatusEnum.PENDING) { return 待审核 @@ -123,11 +153,12 @@ export default function InvoiceList() { return 已开票 } if (value === InvoiceStatusEnum.FAILED) { - return 失败 + return 未通过 } if (value === InvoiceStatusEnum.CANCEL) { return 已取消 } + } }, { @@ -135,7 +166,7 @@ export default function InvoiceList() { dataIndex: 'operate', align: 'center', width: 120, - fixed: 'right', + // fixed: 'right', render: (_value, record) => { if (record.invoiceStatus === InvoiceStatusEnum.PENDING) { return @@ -146,7 +177,8 @@ export default function InvoiceList() { }} onClick={() => { // invoiceId.current = record.invoiceId; // console.log(record.invoiceId); - setInvoiceId(record.invoiceId); + // setInvoiceId(record.invoiceId); + setInvoiceRechargeId(record.invoiceRechargeId); setIsShowModalOpen(true); }}>查看 { - put({ - messageApi, - url: `/api/invoice/update-cancel/${record.invoiceId}`, - onSuccess() { - messageApi.success('取消成功'); - getData(); - } - }) + // put({ + // messageApi, + // url: `/api/invoice/update-cancel/${record.invoiceId}`, + // onSuccess() { + // messageApi.success('取消成功'); + // getData(); + // } + // }) + cancel(record.invoiceRechargeId); }} > } + // if (record.invoiceStatus === InvoiceStatusEnum.FAILED ) { + + // return + // } if (record.invoiceStatus == InvoiceStatusEnum.COMPLETE) { const items: MenuProps['items'] = []; - record.invoiceFileList.forEach((item, index) => { + const arr = record.invoiceFile.split(','); + // record.invoiceFileList.forEach((item, index) => { + // items.push({ + // key: index, + // label: ( + // 下载发票{index + 1} + // ) + // }); + // }) + arr.forEach((item, index) => { items.push({ key: index, label: ( - 下载发票{index + 1} + 下载发票{index + 1} ) }); }) return ( - + ) } } }, ] + const globalContext = useContext(GlobalContext); + const [loading, setLoading] = useState(false); + const getData = async () => { + try { + setLoading(true); + const res: any = await getInvoiceRecordList(globalContext.user.userId, { page: page, rows: 20 }) + setLoading(false); + // console.log(res); + setPage(res.page); + setTotal(res.total); + setDataArray(res.rows); + } catch (error: any) { + - const getData = () => { - get>({ - messageApi, - url: '/api/invoice/listpage/self', - config: { - params: { - page: page, - rows: 20 - } - }, - onSuccess({ data }) { - setPage(data.page); - setTotal(data.total); - setDataArray(data.rows); + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) } - }) + } + + + // get>({ + // messageApi, + // url: '/api/invoice/listpage/self', + // config: { + // params: { + // page: page, + // rows: 20 + // } + // }, + // onSuccess({ data }) { + // setPage(data.page); + // setTotal(data.total); + // setDataArray(data.rows); + // } + // }) } useEffect(() => { @@ -240,15 +321,17 @@ export default function InvoiceList() { setIsSaveModalOpen(true); }}> 新增
- { - setPage(currentPage); - }, - } - } scroll={{ y: 500 }} bordered key="dataTable" rowKey="invoiceId" /> + +
{ + setPage(currentPage); + }, + } + } scroll={{ y:500}} bordered key="dataTable" rowKey="invoiceRechargeId" /> + { getData(); setIsEditModalOpen(false); @@ -288,6 +372,7 @@ export default function InvoiceList() { handleCancel={() => { setIsEditModalOpen(false); }} + status={status} /> {/* {invoiceId.current} */} {messageContext} diff --git a/src/components/invoice/InvoiceSave.tsx b/src/components/invoice/InvoiceSave.tsx index 849106e..6ea77f7 100644 --- a/src/components/invoice/InvoiceSave.tsx +++ b/src/components/invoice/InvoiceSave.tsx @@ -1,566 +1,567 @@ -import { Button, Flex, Form, Input, Modal, Radio, Space } from "antd"; -import { useEffect, useState } from "react"; -import { listDictionary, IDictionary, post } from "../../util/AjaxUtils.ts"; -import useMessage from "antd/es/message/useMessage"; -import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; -import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; -import useModal from "antd/es/modal/useModal"; -import './InvoiceSave.css' -type FormFieldType = { - invoiceTitle: string; - invoiceNo: string; - invoiceAddress: string; - invoicePhone: string; - invoiceAccount: string; - invoiceBank: string; - content: string; - rate: string; - type: string; - orderIds: string[]; - invoiceNote: string; - isSaveInvoiceInfo: boolean; -} +// import { Button, Flex, Form, Input, Modal, Radio, Space } from "antd"; +// import { useEffect, useState } from "react"; +// import { listDictionary, IDictionary, post } from "../../util/AjaxUtils.ts"; +// import useMessage from "antd/es/message/useMessage"; +// import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; +// import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; +// import useModal from "antd/es/modal/useModal"; +// import './InvoiceSave.css' +// type FormFieldType = { +// invoiceTitle: string; +// invoiceNo: string; +// invoiceAddress: string; +// invoicePhone: string; +// invoiceAccount: string; +// invoiceBank: string; +// content: string; +// rate: string; +// type: string; +// orderIds: string[]; +// invoiceNote: string; +// isSaveInvoiceInfo: boolean; +// } -type SaveProps = { - handleOk: () => void; - handleCancel: () => void; -} +// type SaveProps = { +// handleOk: () => void; +// handleCancel: () => void; +// } -export default function InvoiceSave(props: SaveProps) { - const [messageApi, messageContext] = useMessage(); - const [modal, modalContext] = useModal(); - const [form] = Form.useForm(); - const [contentArray, setContentArray] = useState([]); - const [rateArray, setRateArray] = useState([]); - const [typeArray, setTypeArray] = useState([]); - const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); - const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); - const [orderAmount, setOrderAmount] = useState('0'); +// export default function InvoiceSave(props: SaveProps) { +// const [messageApi, messageContext] = useMessage(); +// const [modal, modalContext] = useModal(); +// const [form] = Form.useForm(); +// const [contentArray, setContentArray] = useState([]); +// const [rateArray, setRateArray] = useState([]); +// const [typeArray, setTypeArray] = useState([]); +// const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); +// const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); +// const [orderAmount, setOrderAmount] = useState('0'); - 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]); - }) - }, []); +// 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} - {modalContext} -
+// {messageContext} +// {modalContext} +// { - modal.confirm({ - title: '提示', - content: '确定提交吗?', - okText: '确定', - cancelText: '取消', - centered: true, - okButtonProps: { - style: { - backgroundColor: 'val(--color-primary)' - } - }, - onOk: () => { - post({ - messageApi, - url: '/api/invoice/save', - body: values, - onSuccess() { - messageApi.success('提交成功'); - props.handleOk(); - } - }) - } - }); - }} - > - {/* 开票信息 -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// onFinish={(values) => { +// modal.confirm({ +// title: '提示', +// content: '确定提交吗?', +// okText: '确定', +// cancelText: '取消', +// centered: true, +// okButtonProps: { +// style: { +// backgroundColor: 'val(--color-primary)' +// } +// }, +// onOk: () => { +// post({ +// messageApi, +// url: '/api/invoice/save', +// body: values, +// onSuccess() { +// messageApi.success('提交成功'); +// props.handleOk(); +// } +// }) +// } +// }); +// }} +// > +// {/* 开票信息 +//
- -
公司名称 * - - - -
纳税人识别号 * - - - -
公司地址 * - - - -
联系电话 * - - - -
开户行 * - - - -
开户行账号 * - - - -
开票内容 * - - - - {contentArray.map(item => {item.dataName})} - - - -
开票税率 * - - - {rateArray.map(item => {item.dataName})} - - -
发票类型 * - - - - {typeArray.map(item => {item.dataName})} - - - -
+// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// - - - - - -
+// +//
公司名称 * +// +// +// +//
纳税人识别号 * +// +// +// +//
公司地址 * +// +// +// +//
联系电话 * +// +// +// +//
开户行 * +// +// +// +//
开户行账号 * +// +// +// +//
开票内容 * +// +// +// +// {contentArray.map(item => {item.dataName})} +// +// +// +//
开票税率 * +// +// +// {rateArray.map(item => {item.dataName})} +// +// +//
发票类型 * +// +// +// +// {typeArray.map(item => {item.dataName})} +// +// +// +//
保存开票信息 * - - - - - - -
- 开票内容 - - - - - - - - - - - - - - - -
开票金额 * - -
- - {orderAmount} - -
-
-
开票备注 - - - -
*/} -
-
-
开票信息
-
- -
-
-
-
公司名称*
- - - -
-
-
纳税人识别号*
- - - -
+// +// 保存开票信息 * +// +// +// +// +// +// +// +// +// +// +// +// 开票内容 +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +//
开票金额 * +// +//
+// +// {orderAmount} +// +//
+//
+//
开票备注 +// +// +// +//
*/} +//
+//
+//
开票信息
+//
+// +//
+//
+//
+//
公司名称*
+// +// +// +//
+//
+//
纳税人识别号*
+// +// +// +//
-
-
-
-
公司地址*
- - - -
-
-
联系电话*
- - - -
+//
+//
+//
+//
公司地址*
+// +// +// +//
+//
+//
联系电话*
+// +// +// +//
-
-
-
-
开户行*
- - - -
-
-
开户行账号*
- - - -
+//
+//
+//
+//
开户行*
+// +// +// +//
+//
+//
开户行账号*
+// +// +// +//
-
-
-
-
开票内容*
- - -
- {contentArray.map(item => {item.dataName})} -
-
-
-
-
-
开票税率*
- - -
- {rateArray.map(item => {item.dataName})} -
-
-
-
+//
+//
+//
+//
开票内容*
+// +// +//
+// {contentArray.map(item => {item.dataName})} +//
+//
+//
+//
+//
+//
开票税率*
+// +// +//
+// {rateArray.map(item => {item.dataName})} +//
+//
+//
+//
-
-
+//
-
-
发票类型*
- - -
- {typeArray.map(item => {item.dataName})} -
-
-
-
-
-
保存开票信息*
- - -
- - -
-
-
-
+// }}> +//
+//
发票类型*
+// +// +//
+// {typeArray.map(item => {item.dataName})} +//
+//
+//
+//
+//
+//
保存开票信息*
+// +// +//
+// +// +//
+//
+//
+//
-
-
-
-
开票内容
-
-
-
开票金额*
- -
- - {orderAmount} - -
-
-
-
-
开票备注
- - - -
-
-
-
- - - - - - - - - - { - setIsInvoiceInfoListOpen(false); - }} - > - { - form.setFieldsValue({ - invoiceTitle: selectedInvoice.invoiceTitle, - invoiceNo: selectedInvoice.invoiceNo, - invoiceAddress: selectedInvoice.invoiceAddress, - invoicePhone: selectedInvoice.invoicePhone, - invoiceAccount: selectedInvoice.invoiceAccount, - invoiceBank: selectedInvoice.invoiceBank - }); - setIsInvoiceInfoListOpen(false); - }} - handleCancel={() => { - setIsInvoiceInfoListOpen(false); - }} - /> - - setIsInvoiceOrderListOpen(false)} - > - { - let totalAmount = 0; - const orderIds: string[] = []; - selectedOrders.forEach((item) => { - totalAmount += item.totalAmount; - orderIds.push(item.orderId); - }); - setOrderAmount((totalAmount / 100).toFixed(2)); - setIsInvoiceOrderListOpen(false); - form.setFieldValue('orderIds', orderIds); - }} - handleCancel={() => { - setIsInvoiceOrderListOpen(false); - }} - /> - - - ); -} \ No newline at end of file +//
+//
+//
+//
开票内容
+//
+//
+//
开票金额*
+// +//
+// +// {orderAmount} +// +//
+//
+//
+//
+//
开票备注
+// +// +// +//
+//
+//
+//
+// +// +// +// +// +// +// +// +// +// { +// setIsInvoiceInfoListOpen(false); +// }} +// > +// { +// form.setFieldsValue({ +// invoiceTitle: selectedInvoice.invoiceTitle, +// invoiceNo: selectedInvoice.invoiceNo, +// invoiceAddress: selectedInvoice.invoiceAddress, +// invoicePhone: selectedInvoice.invoicePhone, +// invoiceAccount: selectedInvoice.invoiceAccount, +// invoiceBank: selectedInvoice.invoiceBank +// }); +// setIsInvoiceInfoListOpen(false); +// }} +// handleCancel={() => { +// setIsInvoiceInfoListOpen(false); +// }} +// /> +// +// setIsInvoiceOrderListOpen(false)} +// destroyOnClose +// > +// { +// let totalAmount = 0; +// const orderIds: string[] = []; +// selectedOrders.forEach((item) => { +// totalAmount += item.totalAmount; +// orderIds.push(item.orderId); +// }); +// setOrderAmount((totalAmount / 100).toFixed(2)); +// setIsInvoiceOrderListOpen(false); +// form.setFieldValue('orderIds', orderIds); +// }} +// handleCancel={() => { +// setIsInvoiceOrderListOpen(false); +// }} +// /> +// +// +// ); +// } \ No newline at end of file diff --git a/src/components/invoice/InvoiceShow.tsx b/src/components/invoice/InvoiceShow.tsx index 72de6c3..43868b2 100644 --- a/src/components/invoice/InvoiceShow.tsx +++ b/src/components/invoice/InvoiceShow.tsx @@ -1,27 +1,28 @@ import { Button, Divider, Modal } from "antd"; import { useEffect, useState } from "react"; -import { get } from "../../util/AjaxUtils.ts"; +// import { get } from "../../util/AjaxUtils.ts"; +import {getInvoiceInfoById} from '../../request/api.ts' import useMessage from "antd/es/message/useMessage"; import InvoiceInfoSelectedList from "./order/InvoiceOrderSelectedList.tsx" type DataType = { - invoiceTitle: string; - invoiceNo: string; - invoiceAddress: string; - invoicePhone: string; - invoiceAccount: string; + invoiceName: string; + invoiceNumber: string; + invoiceOrgaddress: string; + invoiceOrgtel: string; + invoiceBanknumber: string; invoiceBank: string; - content: string; - rate: string; - type: string; + invoicePurpose: string; + invoiceTaxrate: string; + invoiceClassify: string; orderIds: string[]; - invoiceNote: string; + invoiceRecord: string; isSaveInvoiceInfo: boolean; invoiceAmount: number; } type ShowProps = { - invoiceId: string; + invoiceRechargeId: string; } export default function InvoiceShow(props: ShowProps) { @@ -29,23 +30,44 @@ export default function InvoiceShow(props: ShowProps) { const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); const [invoiceData, setInvoiceData] = useState(null); const [orderAmount, setOrderAmount] = useState('0'); - + const getData = async () => { + try { + const res: any = await getInvoiceInfoById(props.invoiceRechargeId) + console.log('数据', res); + setInvoiceData({ ...res }) + setOrderAmount(res.invoiceRechargeMoney ) + } catch(error:any){ + if (error.response) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + } useEffect(() => { - if (!props.invoiceId) { + if (!props.invoiceRechargeId) { return; } - get({ - messageApi, - url: `/api/invoice/get/${props.invoiceId}`, - onSuccess({ data }) { - setInvoiceData({ - ...data - }); - setOrderAmount((data.invoiceAmount / 100).toFixed(2)); - } - }) + + // get({ + // messageApi, + // url: `/api/invoice/get/${props.invoiceId}`, + // onSuccess({ data }) { + // setInvoiceData({ + // ...data + // }); + // setOrderAmount((data.invoiceAmount / 100).toFixed(2)); + // } + // }) + getData(); }, []); @@ -61,39 +83,39 @@ export default function InvoiceShow(props: ShowProps) { 公司名称 * - {invoiceData?.invoiceTitle} + {invoiceData?.invoiceName} 纳税人识别号 * - {invoiceData?.invoiceNo} + {invoiceData?.invoiceNumber} 公司地址 * - {invoiceData?.invoiceAddress} + {invoiceData?.invoiceOrgaddress} 联系电话 * - {invoiceData?.invoicePhone} + {invoiceData?.invoiceOrgtel} 开户行 * - {invoiceData?.invoiceAccount} - - - 开户行账号 * {invoiceData?.invoiceBank} + + 开户行账号 * + {invoiceData?.invoiceBanknumber} + 开票内容 * - {invoiceData?.content} + {invoiceData?.invoicePurpose} 开票税率 * - {invoiceData?.rate} + {invoiceData?.invoiceTaxrate} 发票类型 * - {invoiceData?.type} + {invoiceData?.invoiceClassify} @@ -112,24 +134,24 @@ export default function InvoiceShow(props: ShowProps) { {orderAmount} + }}>查看开票的充值记录
开票备注 - {invoiceData?.invoiceNote} + {invoiceData?.invoiceRecord} setIsInvoiceOrderListOpen(false)} > - + ); diff --git a/src/components/invoice/NewInvoiceEdit.tsx b/src/components/invoice/NewInvoiceEdit.tsx new file mode 100644 index 0000000..86c1714 --- /dev/null +++ b/src/components/invoice/NewInvoiceEdit.tsx @@ -0,0 +1,424 @@ +import { Button, Flex, Form, Input, Modal, Radio, Space } from "antd"; +import { useEffect, useState } from "react"; +import { listDictionary, IDictionary } from "../../util/AjaxUtils.ts"; +import { getInvoiceInfoByinvoiceRechargeId, getInvoiceRechargeList, updateInvoiceInfoByinvoiceRechargeId } from '../../request/api.ts' +import useMessage from "antd/es/message/useMessage"; +import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; +import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; +import useModal from "antd/es/modal/useModal"; + +type FormFieldType = { + invoiceName: string; + invoiceNumber: string; + invoiceOrgaddress: string; + invoiceOrgtel: string; + invoiceBank: string; + invoiceBanknumber: string; + invoicePurpose: string; + invoiceTaxrate: string; + invoiceClassify: string; + accountRechargeIds: string[]; + invoiceRecord: string; + isSaveInvoiceInfo: boolean; +} + +type EditProps = { + invoiceRechargeId: string; + handleOk: () => void; + handleCancel: () => void; + // invdataArray: any[]; + // isEditModalOpen: boolean; + showFailed?: boolean; + status?: string; +} + +export default function InvoiceEdit(props: EditProps) { + const [selectedOrders, setSelectedOrders] = useState([]); //被选择的数组 + const [invoiceId, setInvoiceId] = useState(''); // 开票信息id + + + const [messageApi, messageContext] = useMessage(); + const [modal, modalContext] = useModal(); + const [form] = Form.useForm(); + const [contentArray, setContentArray] = useState([]); + const [rateArray, setRateArray] = useState([]); + const [typeArray, setTypeArray] = useState([]); + const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); + const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); + const [orderAmount, setOrderAmount] = useState('0'); + const [invoiceFinalRecord, setInvoiceFinalRecord] = useState(''); //未通过原因 + const getData = async () => { + try { + const res: any = await getInvoiceInfoByinvoiceRechargeId(props.invoiceRechargeId) + // console.log(res); + form.setFieldsValue(res) + setInvoiceId(res.invoiceId) + setInvoiceFinalRecord(res.invoiceFinalRecord) + form.setFieldValue('accountRechargeIds', res.invoiceRechargeIds); + setOrderAmount(res.invoiceRechargeMoney) + } catch (error: any) { + + + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + const getSelect = async () => { + try { + const res: any = await getInvoiceRechargeList(props.invoiceRechargeId, { page: 1, rows: 1000 }) + // console.log(res); + setSelectedOrders(res.rows); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + const upData = async () => { + console.log(form.getFieldsValue()) + + try { + const res: any = await updateInvoiceInfoByinvoiceRechargeId(props.invoiceRechargeId, { + ...form.getFieldsValue(), + invoiceType: '企业', + invoiceRechargeId: props.invoiceRechargeId, + invoiceId: invoiceId, + // invoiceId: + + }) + console.log(res); + props.handleOk() + messageApi.success('提交成功'); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + useEffect(() => { + // console.log(props.invoiceRechargeId); + + if (!props.invoiceRechargeId) { + return; + } + // 开票内容 + 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]); + }) + getData() + getSelect() + // get({ + // messageApi, + // url: `/api/invoice/get/${props.invoiceId}`, + // onSuccess({data}) { + // form.setFieldsValue(data); + // setOrderAmount((data.invoiceAmount / 100).toFixed(2)); + // } + // }) + + }, []); + + return ( + <> + {messageContext} + {modalContext} +
{ + modal.confirm({ + title: '提示', + centered: true, + content: '确定提交吗?', + okText: '确定', + cancelText: '取消', + okButtonProps: { + style: { + backgroundColor: 'val(--color-primary)' + } + }, + onOk: () => { + upData() + + // put({ + // messageApi, + // url: `/api/invoice/update/${props.invoiceId}`, + // body: values, + // onSuccess() { + // messageApi.success('提交成功'); + // props.handleOk(); + // } + // }) + } + }); + }} + > + +
+
+
开票信息
+
+ {/* */} +
+
+
+
选择开票信息*
+ + + +
{ + setIsInvoiceInfoListOpen(true); + }} + > + +
+
+
+
发票类型*
+ + +
+ {typeArray.map(item => {item.dataName})} +
+
+
+
+ + + +
+ +
+
+
开票内容*
+ + +
+ {contentArray.map(item => {item.dataName})} +
+
+
+
+
+
开票税率*
+ + +
+ {rateArray.map(item => {item.dataName})} +
+
+
+
+ + + +
+ +
+
+
开票内容
+
+
失败原因 : {invoiceFinalRecord}
+
+
开票金额*
+ +
+ + {orderAmount} + +
+
+
+
+
开票备注
+ + + +
+
+
+
+ + + + + + + + + + setIsInvoiceInfoListOpen(false)} + > + { + setInvoiceId(selectedInvoice.invoiceId); + form.setFieldsValue({ + invoiceName: selectedInvoice.invoiceName, + invoiceNumber: selectedInvoice.invoiceNumber, + invoiceOrgaddress: selectedInvoice.invoiceOrgaddress, + invoiceOrgtel: selectedInvoice.invoiceOrgtel, + invoiceBank: selectedInvoice.invoiceBank, + invoiceBanknumber: selectedInvoice.invoiceBanknumber + }); + setIsInvoiceInfoListOpen(false); + }} + handleCancel={() => { + setIsInvoiceInfoListOpen(false); + }} + /> + + setIsInvoiceOrderListOpen(false)} + centered + + > + { + // let totalAmount = 0; + // const orderIds: string[] = []; + // selectedOrders.forEach((item) => { + // totalAmount += item.totalAmount; + // orderIds.push(item.orderId); + // }); + // setOrderAmount((totalAmount / 100).toFixed(2)); + // setIsInvoiceOrderListOpen(false); + // form.setFieldValue('orderIds', orderIds); + + setSelectedOrders(selectedArr); + let totalAmount = 0; + const orderIds: string[] = []; + selectedArr.forEach((item) => { + totalAmount += item.rechargeMoney; + orderIds.push(item.accountRechargeId); + }); + const orderIdsString = orderIds.join(','); + setOrderAmount(String(totalAmount.toFixed(2))); + setIsInvoiceOrderListOpen(false); + form.setFieldValue('accountRechargeIds', orderIdsString); + }} + handleCancel={() => { + setIsInvoiceOrderListOpen(false); + }} + selectedOrders={selectedOrders} + setSelectedOrders={setSelectedOrders} + /> + + + ); +} \ No newline at end of file diff --git a/src/components/invoice/NewInvoiceSave.tsx b/src/components/invoice/NewInvoiceSave.tsx new file mode 100644 index 0000000..7121589 --- /dev/null +++ b/src/components/invoice/NewInvoiceSave.tsx @@ -0,0 +1,357 @@ +import { Button, Flex, Form, Input, Modal, Radio, Space } from "antd"; +import { useEffect, useState, useContext } from "react"; +import { GlobalContext } from "../../context/GlobalContext.ts"; +import { + listDictionary, IDictionary, + // post +} from "../../util/AjaxUtils.ts"; +import useMessage from "antd/es/message/useMessage"; +import InvoiceInfoList from "./info/InvoiceInfoList.tsx"; +import InvoiceOrderList from "./order/InvoiceOrderList.tsx"; +import useModal from "antd/es/modal/useModal"; +import { submitInvoiceApply } from "../../request/api.ts" +import './InvoiceSave.css' +type FormFieldType = { + invoiceName: string; + invoiceNumber: string; + invoiceOrgaddress: string; + invoiceOrgtel: string; + invoiceBank: string; + invoiceBanknumber: string; + invoicePurpose: string; + invoiceTaxrate: string; + invoiceClassify: string; + accountRechargeIds: string[]; + invoiceRecord: string; + isSaveInvoiceInfo: boolean; +} + +type SaveProps = { + handleOk: () => void; + handleCancel: () => void; +} + +export default function InvoiceSave(props: SaveProps) { + const [messageApi, messageContext] = useMessage(); + // const [selectedOrderIds, setSelectedOrderIds] = useState([]); // 选中的订单id数组 + const [modal, modalContext] = useModal(); + const [form] = Form.useForm(); + const [contentArray, setContentArray] = useState([]); + const [rateArray, setRateArray] = useState([]); + const [typeArray, setTypeArray] = useState([]); + const [isInvoiceInfoListOpen, setIsInvoiceInfoListOpen] = useState(false); + const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false); + const [orderAmount, setOrderAmount] = useState('0'); + const [invoiceId, setInvoiceId] = useState(''); // 开票信息id + const globalContext = useContext(GlobalContext); + const [selectedOrders, setSelectedOrders] = useState([]); //被选择的数组 + + const submitInvoice = async (values: any) => { + try { + await submitInvoiceApply(globalContext.user.userId, values) + messageApi.success('提交成功'); + props.handleOk(); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + } + // const [selectedOrders, setSelectedOrders] = 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} + {modalContext} +
{ + modal.confirm({ + title: '提示', + content: '确定提交吗?', + okText: '确定', + cancelText: '取消', + centered: true, + okButtonProps: { + style: { + backgroundColor: 'val(--color-primary)' + } + }, + onOk: () => { + console.log(values); + + submitInvoice( + { + invoiceId, + invoiceTaxrate: values.invoiceTaxrate, + invoicePurpose: values.invoicePurpose, + invoiceClassify: values.invoiceClassify, + accountRechargeIds: values.accountRechargeIds, + invoiceRecord: values.invoiceRecord, + // invoiceRechargeMoney: orderAmount, + }) + // console.log(values); + + // post({ + // messageApi, + // url: '/api/invoice/save', + // body: values, + // onSuccess() { + // messageApi.success('提交成功'); + // props.handleOk(); + // } + // }) + } + }); + }} + > + +
+
+
开票信息
+
+ {/* */} +
+
+
+
选择开票信息*
+ + + +
{ + setIsInvoiceInfoListOpen(true); + }} + > + +
+
+
+
发票类型*
+ + +
+ {typeArray.map(item => {item.dataName})} +
+
+
+
+ + + +
+ +
+
+
开票内容*
+ + +
+ {contentArray.map(item => {item.dataName})} +
+
+
+
+
+
开票税率*
+ + +
+ {rateArray.map(item => {item.dataName})} +
+
+
+
+ + + +
+
+ +
+
+
+
开票内容
+
+
+
开票金额*
+ +
+ + {orderAmount} + +
+
+
+
+
开票备注
+ + + +
+
+
+
+ + + + + + + + + + { + setIsInvoiceInfoListOpen(false); + }} + > + { + // console.log(selectedInvoice.invoiceId); + setInvoiceId(selectedInvoice.invoiceId); + form.setFieldsValue({ + invoiceName: selectedInvoice.invoiceName, + invoiceNumber: selectedInvoice.invoiceNumber, + invoiceOrgaddress: selectedInvoice.invoiceOrgaddress, + invoiceOrgtel: selectedInvoice.invoiceOrgtel, + invoiceBank: selectedInvoice.invoiceBank, + invoiceBanknumber: selectedInvoice.invoiceBanknumber + }); + setIsInvoiceInfoListOpen(false); + }} + handleCancel={() => { + setIsInvoiceInfoListOpen(false); + }} + + /> + + setIsInvoiceOrderListOpen(false)} + destroyOnClose + centered + > + { + setSelectedOrders(selectedArr); + let totalAmount = 0; + const orderIds: string[] = []; + selectedArr.forEach((item) => { + totalAmount += item.rechargeMoney; + orderIds.push(item.accountRechargeId); + }); + const orderIdsString = orderIds.join(','); + setOrderAmount(String(totalAmount.toFixed(2))); + setIsInvoiceOrderListOpen(false); + form.setFieldValue('accountRechargeIds', orderIdsString); + + }} + handleCancel={() => { + setIsInvoiceOrderListOpen(false); + }} + + selectedOrders={selectedOrders} + setSelectedOrders={setSelectedOrders} + /> + + + ); +} \ No newline at end of file diff --git a/src/components/invoice/info/InvoiceInfoEdit.tsx b/src/components/invoice/info/InvoiceInfoEdit.tsx index 215e7c6..869eee6 100644 --- a/src/components/invoice/info/InvoiceInfoEdit.tsx +++ b/src/components/invoice/info/InvoiceInfoEdit.tsx @@ -1,9 +1,9 @@ -import {Button, Flex, Form, Input, Space} from "antd"; -import {useForm} from "antd/es/form/Form"; +import { Button, Flex, Form, Input, Space } from "antd"; +import { useForm } from "antd/es/form/Form"; import useModal from "antd/es/modal/useModal"; -import {get, post} from "../../../util/AjaxUtils.ts"; +// import { get, post } from "../../../util/AjaxUtils.ts"; import useMessage from "antd/es/message/useMessage"; -import {useEffect} from "react"; +import { useEffect } from "react"; type FormDataType = { invoiceTitle: string; @@ -15,28 +15,71 @@ type FormDataType = { } interface EditProps { - invoiceInfoId: string; + invoiceId: string; handleOk: () => void; handleCancel: () => void; } - +import { getInvoiceInfo, updateInvoiceInfo } from '../../../request/api.ts' export default function InvoiceInfoSave(props: EditProps) { const [messageApi, messageContext] = useMessage(); const [modal, modalContext] = useModal(); const [form] = useForm() + const getInfoData = async () => { + try { + const res: any = await getInvoiceInfo(props.invoiceId) + // console.log(res); + form.setFieldsValue(res) + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + + } + + } + const upInfoData = async () => { + try { + + await updateInvoiceInfo(props.invoiceId, { ...form.getFieldsValue(), invoiceType: '企业' }); + + messageApi.success('保存成功'); + + props.handleOk(); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + + } useEffect(() => { - if (!props.invoiceInfoId) { + if (!props.invoiceId) { return; } - get({ - messageApi, - url: `/api/invoice-info/get/${props.invoiceInfoId}`, - onSuccess({data}) { - form.setFieldsValue(data); - } - }) - }, [props.invoiceInfoId]); + getInfoData(); + + // get({ + // messageApi, + // url: `/api/invoice-info/get/${props.invoiceInfoId}`, + // onSuccess({data}) { + // form.setFieldsValue(data); + // } + // }) + + }, [props.invoiceId]); return ( <> @@ -44,8 +87,9 @@ export default function InvoiceInfoSave(props: EditProps) { name="basic" layout="vertical" form={form} - onFinish={(values) => { + onFinish={() => { modal.confirm({ + centered: true, title: '提示', content: '确定保存吗', okText: '确定', @@ -56,65 +100,66 @@ export default function InvoiceInfoSave(props: EditProps) { } }, onOk: () => { - post({ - messageApi, - url: `/api/invoice-info/update/${props.invoiceInfoId}`, - body: values, - onSuccess() { - messageApi.success('保存成功'); - props.handleOk(); - } - }) + // post({ + // messageApi, + // url: `/api/invoice-info/update/${props.invoiceInfoId}`, + // body: values, + // onSuccess() { + // messageApi.success('保存成功'); + // props.handleOk(); + // } + // }) + upInfoData() } }) }} > - + - + - + - + - + - + + style={{ backgroundColor: 'var(--color-primary)' }}>保存 diff --git a/src/components/invoice/info/InvoiceInfoList.tsx b/src/components/invoice/info/InvoiceInfoList.tsx index 472ebb2..407b020 100644 --- a/src/components/invoice/info/InvoiceInfoList.tsx +++ b/src/components/invoice/info/InvoiceInfoList.tsx @@ -1,22 +1,21 @@ -import {Button, Flex, Modal, Popconfirm, Space, Table, TableProps} from "antd"; -import {DeleteOutlined, EditOutlined, PlusOutlined} from "@ant-design/icons"; +import { Empty,Button, Flex, Modal, Popconfirm, Space, Table, TableProps } from "antd"; +import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons"; import useMessage from "antd/es/message/useMessage"; -import {useEffect, useRef, useState} from "react"; -import {del, get} from "../../../util/AjaxUtils.ts"; -import {IListPage} from "../../../interfaces/listpage/IListPage.ts"; +import { useEffect, useRef, useState, useContext } from "react"; +// import { del, get } from "../../../util/AjaxUtils.ts"; +// import { IListPage } from "../../../interfaces/listpage/IListPage.ts"; import InvoiceInfoSave from "./InvoiceInfoSave.tsx"; import InvoiceInfoEdit from "./InvoiceInfoEdit.tsx"; - +import { getInvoiceList, deleteInvoiceInfo } from '../../../request/api.ts' +import { GlobalContext } from "../../../context/GlobalContext.ts"; type DataType = { - invoiceTitle: string; - invoicePhone: string; - invoiceNo: string; - invoiceInfoId: string; + invoiceName: string; + invoiceNumber: string; + invoiceOrgaddress: string; + invoiceOrgtel: string; invoiceBank: string; - invoiceAddress: string; - invoiceAccount: string; - gmtCreate: number; - creator: string; + invoiceBanknumber: string; + invoiceId: string; } interface ListProps { @@ -37,54 +36,54 @@ export default function InvoiceInfoList(props: ListProps) { const columns: TableProps['columns'] = [ { title: '公司名称', - dataIndex: 'invoiceTitle', + dataIndex: 'invoiceName', align: 'center', width: 180, fixed: 'left' }, { title: '纳税人识别号', - dataIndex: 'invoiceNo', + dataIndex: 'invoiceNumber', align: 'center', width: 180 }, { title: '公司地址', - dataIndex: 'invoiceAddress', + dataIndex: 'invoiceOrgaddress', align: 'center', width: 180 }, { title: '联系电话', - dataIndex: 'invoicePhone', - align: 'center', - width: 180 - }, - { - title: '开户行', - dataIndex: 'invoiceBank', - align: 'center', - width: 180 - }, - { - title: '开户行账号', - dataIndex: 'invoiceAccount', + dataIndex: 'invoiceOrgtel', align: 'center', width: 180 }, + // { + // title: '开户行', + // dataIndex: 'invoiceBank', + // align: 'center', + // width: 180 + // }, + // { + // title: '开户行账号', + // dataIndex: 'invoiceBanknumber', + // align: 'center', + // width: 180 + // }, { title: '操作', dataIndex: 'option', align: 'center', width: 100, - fixed: 'right', + // fixed: 'right', render: (_value, record) => { return ( + }}> { - del({ - messageApi, - url: `/api/invoice-info/remove/${record.invoiceInfoId}`, - onSuccess() { - messageApi.success('删除成功'); - getData(); - } - }) + deleteInvoice(record.invoiceId); + // del({ + // messageApi, + // url: `/api/invoice-info/remove/${record.invoiceId}`, + // onSuccess() { + // messageApi.success('删除成功'); + // getData(); + // } + // }) }} > - + ) } }, ] + const globalContext = useContext(GlobalContext); + const getData = async () => { - const getData = () => { - 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); + try { + const res: any = await getInvoiceList(globalContext.user.userId, { page: page, rows: 20 }) + // console.log(res); + setTotal(res.total) + setDataArray(res.rows) + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) } - }) + } + // 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); + // } + // }) + } + const deleteInvoice = async (id: string) => { + try { + await deleteInvoiceInfo(id) + // console.log(res); + messageApi.success('删除成功'); + getData(); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } } useEffect(() => { getData(); }, [page]); - return ( <>
-
+
+ }}> 新增
- { - selectedInvoice.current = selectedRows[0]; - }, - } - } columns={columns} dataSource={dataArray} pagination={ - { - pageSize: 20, - total: total, - onChange: (currentPage) => { - setPage(currentPage); + {dataArray.length > 0 + ? <> +
{ + selectedInvoice.current = selectedRows[0]; + }, + + } + } + + columns={columns} dataSource={dataArray} pagination={ + { + pageSize: 20, + total: total, + onChange: (currentPage) => { + setPage(currentPage); + } + } + } scroll={{ y: 500 }} bordered key="dataTable" rowKey="invoiceId" + + /> + : + <> +
+ +
+ + } + {/*
{ + selectedInvoice.current = selectedRows[0]; + }, + } } - } scroll={{y: 500}} bordered key="dataTable" rowKey="invoiceInfoId"/> + + columns={columns} dataSource={dataArray} pagination={ + { + pageSize: 20, + total: total, + onChange: (currentPage) => { + setPage(currentPage); + } + } + } scroll={{ y: 500 }} bordered key="dataTable" rowKey="invoiceId" + + /> */} + style={{ backgroundColor: 'var(--color-primary)' }}>保存 diff --git a/src/components/invoice/order/InvoiceOrderList.tsx b/src/components/invoice/order/InvoiceOrderList.tsx index 9bac0fc..d8b4372 100644 --- a/src/components/invoice/order/InvoiceOrderList.tsx +++ b/src/components/invoice/order/InvoiceOrderList.tsx @@ -1,172 +1,184 @@ -import {Button, Flex, Space, Table, TableProps, Tooltip} from "antd"; +import { + Button, Flex, Space, Table, TableProps,Empty +} from "antd"; import useMessage from "antd/es/message/useMessage"; -import {useEffect, useRef, useState} from "react"; -import {get} from "../../../util/AjaxUtils.ts"; -import {IListPage} from "../../../interfaces/listpage/IListPage.ts"; +import { useEffect, useState, useContext } from "react"; + +import { getRechargeRecordList } from '../../../request/api.ts' +import { GlobalContext } from "../../../context/GlobalContext.ts"; -type DetailDataType = [{ - productType: string; - quantity: number; - unitPrice: number; - notes: string; - productDescription: string; -}] type DataType = { - orderId: string; - orderNo: string; - totalAmount: number; - orderDetails: DetailDataType; - orderStatus: string; - gmtCreate: string; + rechargeMoney: number; + thirdParty: string; + reconciliationTime: string; + rechargeFinalTime: string; + accountRechargeId: string; } interface ListProps { selectedOrderIds?: string[]; handleOk: (selectedOrders: DataType[]) => void; handleCancel: () => void; + selectedOrders?: any; + setSelectedOrders?: React.Dispatch>; + // isInvoiceInfoListOpen?: any; } export default function InvoiceInfoList(props: ListProps) { + const { + selectedOrders, + setSelectedOrders, + } = props; const [messageApi, messageContext] = useMessage(); const [page, setPage] = useState(1); const [total, setTotal] = useState(0); const [dataArray, setDataArray] = useState([]); - const selectedOrders = useRef(null); const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [applyOrders, setApplyOrders] = useState(selectedOrders); const columns: TableProps['columns'] = [ - { - title: '订单号', - dataIndex: 'orderNo', - align: 'center', - width: 250, - fixed: 'left' - }, - { - title: '总金额', - dataIndex: 'totalAmount', - align: 'center', - width: 100, - fixed: 'left', - render: (value) => { - return (value / 100).toFixed(2) - } - }, - { - title: '订单状态', - dataIndex: 'orderStatus', - align: 'center', - width: 100, - render: (value) => { - if(value === 'COMPLETE') { - return '完成'; - } - if(value === 'CHARGEBACK') { - return '已退款'; - } - } - }, - { - title: '创建时间', - dataIndex: 'gmtCreate', - align: 'center', - width: 180 - }, - { - title: '产品类型', - dataIndex: 'orderDetails.productType', - align: 'center', - width: 100, - render: (_value, record) => { - if(record.orderDetails[0].productType === 'PROJ') { - return '项目创建' - } - if(record.orderDetails[0].productType === 'AGENT') { - return '项目代理' - } - return record.orderDetails[0].productType - } - }, - { - title: '数量', - dataIndex: 'detail.quantity', - align: 'center', - width: 100, - render: (_value, record) => { - return record.orderDetails[0].quantity - } - }, - { - title: '单价', - dataIndex: 'detail.unitPrice', - align: 'center', - width: 100, - render: (_value, record) => { - return (record.orderDetails[0].unitPrice / 100).toFixed(2) - } - }, - { - title: '订单备注', - dataIndex: 'detail.notes', - align: 'center', - width: 300, - render: (_value, record) => { - return record.orderDetails[0].notes - } - }, - { - title: '描述', - dataIndex: 'detail.productDescription', - align: 'center', - width: 300, - ellipsis: { - showTitle: false, - }, - render: (_value, record) => { - return {record.orderDetails[0].productDescription} - } - }, - ] - const getData = () => { - get>({ - messageApi, - url: '/api/order/listpage/complete/no-invoiced/self', - config: { - params: { - page: page, - rows: 20 - } - }, - onSuccess({data}) { - console.log('数据',data.rows); - - setPage(data.page); - setTotal(data.total); - setDataArray(data.rows); + { + title: '充值金额', + dataIndex: 'rechargeMoney', + align: 'center', + width: 80, + + }, + { + title: '充值方式', + dataIndex: 'thirdParty', + align: 'center', + width: 80, + + }, + { + title: '充值时间', + dataIndex: 'reconciliationTime', + align: 'center', + width: 100, + + }, + { + title: '充值到账时间', + dataIndex: 'rechargeFinalTime', + align: 'center', + width: 100, + }, + + ] + const globalContext = useContext(GlobalContext); + const getData = async () => { + try { + const res: any = await getRechargeRecordList(globalContext.user.userId, { page: page, rows: 20 }) + // console.log('数据', res); + setPage(res.page); + setTotal(res.total); + setDataArray(res.rows); + + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) } - }) + } + } useEffect(() => { getData(); - if(props.selectedOrderIds && props.selectedOrderIds.length > 0) { - setSelectedRowKeys(props.selectedOrderIds) - } }, [page]); + useEffect(() => { + // console.log('11', applyOrders); + if (applyOrders) { + const selectedIds = applyOrders.map((order: DataType) => order.accountRechargeId); + setSelectedRowKeys(selectedIds); + } + }, [applyOrders]) + return ( <>
-
0 ? + <> +
{ + const isSelect = applyOrders?.some((item: DataType) => item.accountRechargeId === data.accountRechargeId) + // console.log('onSelect', data, isSelect); + if (!isSelect) { + setApplyOrders?.([...applyOrders, data]) + } else { + setApplyOrders?.(applyOrders?.filter((item: DataType) => item.accountRechargeId !== data.accountRechargeId)) + } + }, + onSelectAll: (isAll) => { + if (isAll) { + const newSelectedOrders = dataArray.filter((item: DataType) => !applyOrders?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // const setectSelectedOrders = applyOrders?.filter((item: DataType) => !dataArray?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // console.log('newSelectedOrders', newSelectedOrders, setectSelectedOrders); + setApplyOrders?.([...applyOrders, ...newSelectedOrders]) + } else { + const setectSelectedOrders = applyOrders?.filter((item: DataType) => !dataArray?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // console.log('setectSelectedOrders', setectSelectedOrders); + setApplyOrders?.([...setectSelectedOrders]) + } + }, + + } + } columns={columns} dataSource={dataArray} pagination={ + { + pageSize: 20, + total: total, + showSizeChanger: false, + onChange: (currentPage) => { + setPage(currentPage); + } + } + } scroll={{ y: 500 }} bordered key="dataTable" rowKey="accountRechargeId" /> + : + <> +
+ +
+ + } + {/*
{ - setSelectedRowKeys(selectedRowKeys); - selectedOrders.current = selectedRows; + onSelect: (data) => { + const isSelect = applyOrders?.some((item: DataType) => item.accountRechargeId === data.accountRechargeId) + // console.log('onSelect', data, isSelect); + if (!isSelect) { + setApplyOrders?.([...applyOrders, data]) + } else { + setApplyOrders?.(applyOrders?.filter((item: DataType) => item.accountRechargeId !== data.accountRechargeId)) + } }, + onSelectAll: (isAll) => { + if (isAll) { + const newSelectedOrders = dataArray.filter((item: DataType) => !applyOrders?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // const setectSelectedOrders = applyOrders?.filter((item: DataType) => !dataArray?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // console.log('newSelectedOrders', newSelectedOrders, setectSelectedOrders); + setApplyOrders?.([...applyOrders, ...newSelectedOrders]) + } else { + const setectSelectedOrders = applyOrders?.filter((item: DataType) => !dataArray?.some((order: DataType) => order.accountRechargeId === item.accountRechargeId)); + // console.log('setectSelectedOrders', setectSelectedOrders); + setApplyOrders?.([...setectSelectedOrders]) + } + }, + } } columns={columns} dataSource={dataArray} pagination={ { @@ -177,21 +189,25 @@ export default function InvoiceInfoList(props: ListProps) { setPage(currentPage); } } - } scroll={{y: 500}} bordered key="dataTable" rowKey="orderId"/> + } scroll={{ y: 500 }} bordered key="dataTable" rowKey="accountRechargeId" /> */} diff --git a/src/components/invoice/order/InvoiceOrderSelectedList.tsx b/src/components/invoice/order/InvoiceOrderSelectedList.tsx index 0ea20ae..21735d9 100644 --- a/src/components/invoice/order/InvoiceOrderSelectedList.tsx +++ b/src/components/invoice/order/InvoiceOrderSelectedList.tsx @@ -1,9 +1,13 @@ -import {Table, TableProps, - Tooltip} from "antd"; +import { + Table, TableProps, + // Tooltip +} from "antd"; 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 { useEffect, useState } from "react"; +import { get } from "../../../util/AjaxUtils.ts"; +import { IListPage } from "../../../interfaces/listpage/IListPage.ts"; + +import { getInvoiceRechargeList } from "../../../request/api.ts" // type DetailDataType = { // productType: string; @@ -14,16 +18,15 @@ import {IListPage} from "../../../interfaces/listpage/IListPage.ts"; // } type DataType = { - orderId: string; - orderNo: string; - totalAmount: number; - orderDetails: any; - orderStatus: string; - gmtCreate: string; + rechargeMoney: number; + thirdParty: string; + reconciliationTime: string; + rechargeFinalTime: string; + accountRechargeId: string; } interface ListProps { - invoiceId: string; + invoiceRechargeId: string; } export default function InvoiceInfoSelectedList(props: ListProps) { @@ -32,124 +35,181 @@ export default function InvoiceInfoSelectedList(props: ListProps) { const [total, setTotal] = useState(0); const [dataArray, setDataArray] = useState([]); - const columns: TableProps['columns'] = [ - { - title: '订单号', - dataIndex: 'orderNo', - align: 'center', - width: 250, - fixed: 'left' - }, - { - title: '总金额', - dataIndex: 'totalAmount', - align: 'center', - width: 100, - fixed: 'left', - render: (value) => { - return (value / 100).toFixed(2) - } - }, - { - title: '订单状态', - dataIndex: 'orderStatus', - align: 'center', - width: 100, - render: (value) => { - if(value === 'COMPLETE') { - return '完成'; - } - if(value === 'CHARGEBACK') { - return '已退款'; - } - } - }, - { - title: '创建时间', - dataIndex: 'gmtCreate', - align: 'center', - width: 180 - }, - { - title: '产品类型', - dataIndex: 'orderDetails.0.productType', - align: 'center', - width: 100, - render: (_value, record) => { - if(record.orderDetails[0].productType === 'PROJ') { - return '项目创建' - } - if(record.orderDetails[0].productType === 'AGENT') { - return '项目代理' - } - return record.orderDetails[0].productType - } - }, - { - title: '数量', - dataIndex: 'orderDetails.0.quantity', - align: 'center', - width: 100, - render: (_value, record) => { - return record.orderDetails[0].quantity - } - }, - { - title: '单价', - dataIndex: 'orderDetails.0.unitPrice', - align: 'center', - width: 100, - render: (_value, record) => { - return (record.orderDetails[0].unitPrice / 100).toFixed(2) - } - }, - { - title: '订单备注', - dataIndex: 'orderDetails.0.notes', - align: 'center', - width: 120, - render: (_value, record) => { - return record.orderDetails[0].notes - } - }, - { - title: '描述', - dataIndex: 'orderDetails.0.productDescription', - align: 'center', - width: 200, - ellipsis: { - showTitle: false, - }, - render: (_value, record) => { - return {record.orderDetails[0].productDescription} - } - }, - ] + // const columns: TableProps['columns'] = [ + // { + // title: '订单号', + // dataIndex: 'orderNo', + // align: 'center', + // width: 250, + // fixed: 'left' + // }, + // { + // title: '总金额', + // dataIndex: 'totalAmount', + // align: 'center', + // width: 100, + // fixed: 'left', + // render: (value) => { + // return (value / 100).toFixed(2) + // } + // }, + // { + // title: '订单状态', + // dataIndex: 'orderStatus', + // align: 'center', + // width: 100, + // render: (value) => { + // if(value === 'COMPLETE') { + // return '完成'; + // } + // if(value === 'CHARGEBACK') { + // return '已退款'; + // } + // } + // }, + // { + // title: '创建时间', + // dataIndex: 'gmtCreate', + // align: 'center', + // width: 180 + // }, + // { + // title: '产品类型', + // dataIndex: 'orderDetails.0.productType', + // align: 'center', + // width: 100, + // render: (_value, record) => { + // if(record.orderDetails[0].productType === 'PROJ') { + // return '项目创建' + // } + // if(record.orderDetails[0].productType === 'AGENT') { + // return '项目代理' + // } + // return record.orderDetails[0].productType + // } + // }, + // { + // title: '数量', + // dataIndex: 'orderDetails.0.quantity', + // align: 'center', + // width: 100, + // render: (_value, record) => { + // return record.orderDetails[0].quantity + // } + // }, + // { + // title: '单价', + // dataIndex: 'orderDetails.0.unitPrice', + // align: 'center', + // width: 100, + // render: (_value, record) => { + // return (record.orderDetails[0].unitPrice / 100).toFixed(2) + // } + // }, + // { + // title: '订单备注', + // dataIndex: 'orderDetails.0.notes', + // align: 'center', + // width: 120, + // render: (_value, record) => { + // return record.orderDetails[0].notes + // } + // }, + // { + // title: '描述', + // dataIndex: 'orderDetails.0.productDescription', + // align: 'center', + // width: 200, + // ellipsis: { + // showTitle: false, + // }, + // render: (_value, record) => { + // return {record.orderDetails[0].productDescription} + // } + // }, + // ] + // const columns = [] - useEffect(() => { - get>({ - messageApi, - url: `/api/order/listpage/complete/self?invoiceId=${props.invoiceId}`, - config: { - params: { - page: page, - rows: 20 - } - }, - onSuccess({data}) { - setPage(data.page); - setTotal(data.total); - setDataArray(data.rows); + const columns: TableProps['columns'] = [ + + { + title: '充值金额', + dataIndex: 'rechargeMoney', + align: 'center', + width: 150, + key: 'accountRechargeId', + + }, + { + title: '充值方式', + dataIndex: 'thirdParty', + align: 'center', + width: 150, + key: 'thirdParty', + }, + { + title: '充值时间', + dataIndex: 'reconciliationTime', + align: 'center', + // width: 150, + key: 'reconciliationTime', + + }, + { + title: '充值到账时间', + dataIndex: 'rechargeFinalTime', + align: 'center', + // width: 150, + key:'rechargeFinalTime', + }, + + ] + const getData = async () => { + try { + const res: any = await getInvoiceRechargeList(props.invoiceRechargeId, { page: page, rows: 20 }) + console.log('数据', res); + setPage(res.page); + setTotal(res.total); + setDataArray(res.rows); + } catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) } - }) + } + } + useEffect(() => { + getData() + // get>({ + // messageApi, + // url: `/api/order/listpage/complete/self?invoiceId=${props.invoiceId}`, + // config: { + // params: { + // page: page, + // rows: 20 + // } + // }, + // onSuccess({data}) { + // setPage(data.page); + // setTotal(data.total); + // setDataArray(data.rows); + // } + // }) }, [page]); return ( <> {messageContext}
+
-
{ setPage(currentPage); } - + } - } scroll={{y: 500}} bordered key="dataTable" rowKey="orderId"/> + } scroll={{ y: 500 }} bordered key="accountRechargeId" rowKey="accountRechargeId" + /> diff --git a/src/components/list/ListProj.tsx b/src/components/list/ListProj.tsx index b8c85bb..6aef1d0 100644 --- a/src/components/list/ListProj.tsx +++ b/src/components/list/ListProj.tsx @@ -80,9 +80,9 @@ export default function ListProj() { rows: 10, keywords: keywords, // charge: type, - chargeType: type, - chargeAdditionals: chargeAdditionals, - tagDataId: part1, + chargeType: type, //类型 + chargeAdditionals: chargeAdditionals, //拓展收费 + tagDataId: part1, //标签 projRemindId: projRemindId, authorId: authorId, payStatus: payStatus, diff --git a/src/layout/head/Head.tsx b/src/layout/head/Head.tsx index d8abee0..3e87d3e 100644 --- a/src/layout/head/Head.tsx +++ b/src/layout/head/Head.tsx @@ -845,7 +845,7 @@ export default function Head() { } }) } - + useEffect(() => { getUnRead() // 五分钟刷新一次用户信息 @@ -853,24 +853,36 @@ export default function Head() { getMyPackNum() }, []) - const loginFlag = async() => { - // await getLoginflag(globalContext.user.userId) - - await getLoginflag(globalContext.user.userId); - + const loginFlag = async () => { + try { + await getLoginflag(globalContext.user.userId) sessionStorage.setItem('isLoggedIn', 'true'); - + + } + catch (error: any) { + if (error.response) { + const data = error.response.data; + messageApi.open({ + type: 'error', + content: data.msg ? data.msg : `${data.path}(${data.status})`, + }); + } else { + console.error(error) + } + } + + } useEffect(() => { if (globalContext.user.userId) { const islogin = sessionStorage.getItem('isLoggedIn'); - if (!islogin ) { + if (!islogin) { loginFlag() } // loginFlag() } // loginFlag() - + }, [globalContext.user.userId]) const items: MenuProps['items'] = [ @@ -1319,9 +1331,10 @@ export default function Head() { setIsInvoiceModalOpen(false)} + destroyOnClose > diff --git a/src/request/api.ts b/src/request/api.ts index e226db7..1803829 100644 --- a/src/request/api.ts +++ b/src/request/api.ts @@ -1,4 +1,30 @@ import request from './request' // 获取登录标志 export const getLoginflag = (userId:string) => request.get(`/operator-plugin/app/contentcensusrelease/log?requestUrl=网页USER${userId}`) +// 获取开票记录列表 +export const getInvoiceRecordList = (userId:string,params: any) => request.get(`/operator-plugin/api/invoicerecharge/listpage/${userId}`,{params}) +// 获取开票信息数组 +export const getInvoiceList = (userId:string,params: any) => request.get(`/operator-plugin/api/invoice-config/listpage/${userId}`,{params}) +// 新增开票信息 +export const addInvoiceInfo = (userId:string,params:any) => request.post(`/operator-plugin/api/invoice-config/save/${userId}`,params) +// 获取开票信息 +export const getInvoiceInfo = (invoiceId: string) => request.get(`/operator-plugin/api/invoice-config/get/${invoiceId}`) +//更新开票信息 +export const updateInvoiceInfo = (invoiceId: string,params:any) => request.put(`/operator-plugin/api/invoice-config/update/${invoiceId}`,params) +// 删除开票信息 +export const deleteInvoiceInfo = (invoiceId: string) => request.delete(`/operator-plugin/api/invoice-config/remove/${invoiceId}`) +// 获取可申请开票的充值记录列表 +export const getRechargeRecordList = (userId:string,params: any) => request.get(`/operator-plugin/api/invoicerecharge/recharge-listpage/${userId}/not`,{params}) +//获取开票的充值记录(点击查看开票的充值记录) +export const getInvoiceRechargeList = (invoiceRechargeId:string,params:any) => request.get(`/operator-plugin/api/invoicerecharge/listpage-byid/${invoiceRechargeId}`,{params}) +// 提交开票申请 +export const submitInvoiceApply = (userId:string,params:any) => request.post(`/operator-plugin/api/invoicerecharge/save/${userId}`,params) +// 查看开票信息 +export const getInvoiceInfoById = (invoiceRechargeId: string) => request.get(`/operator-plugin/api/invoicerecharge/get/${invoiceRechargeId}`) +// 取消开票 +export const cancelInvoice = (invoiceRechargeId: string) => request.put(`/operator-plugin/api/invoicerecharge/cancel/${invoiceRechargeId}`) +// 获取开票信息 +export const getInvoiceInfoByinvoiceRechargeId = (invoiceRechargeId: string) => request.get(`/operator-plugin/api/invoicerecharge/get/${invoiceRechargeId}`) +// 修改开票信息 +export const updateInvoiceInfoByinvoiceRechargeId = (invoiceRechargeId: string,params:any) => request.put(`/operator-plugin/api/invoicerecharge/update/${invoiceRechargeId}`,params) \ No newline at end of file diff --git a/src/request/request.ts b/src/request/request.ts index 5106367..049d746 100644 --- a/src/request/request.ts +++ b/src/request/request.ts @@ -1,5 +1,6 @@ import axios from "axios"; -const baseURL = 'https://www.aimzhu.com'; +const baseURL = 'http://192.168.0.115:8099'; +// const baseURL = 'https://www.aimzhu.com'; const request = axios.create({ baseURL: baseURL, timeout: 5000, @@ -23,5 +24,9 @@ request.interceptors.response.use( (err) => Promise.reject(err) ); +// 下载发票 +export const downloadInvoice = (id: string) => { + return `${baseURL}/operator-plugin/route/file/download/false/${id}` +}; export default request \ No newline at end of file