system-copyright-react/src/components/invoice/InvoiceShow.tsx

136 lines
4.8 KiB
TypeScript
Raw Normal View History

2025-03-28 09:44:48 +08:00
import { Button, Divider, Modal } from "antd";
import { useEffect, useState } from "react";
import { get } from "../../util/AjaxUtils.ts";
2024-04-07 17:37:09 +08:00
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;
invoiceBank: string;
content: string;
rate: string;
type: string;
orderIds: string[];
invoiceNote: string;
isSaveInvoiceInfo: boolean;
invoiceAmount: number;
}
type ShowProps = {
invoiceId: string;
}
export default function InvoiceShow(props: ShowProps) {
const [messageApi, messageContext] = useMessage();
const [isInvoiceOrderListOpen, setIsInvoiceOrderListOpen] = useState(false);
const [invoiceData, setInvoiceData] = useState<DataType | null>(null);
const [orderAmount, setOrderAmount] = useState('0');
useEffect(() => {
2025-03-28 09:44:48 +08:00
2024-04-07 17:37:09 +08:00
if (!props.invoiceId) {
return;
}
get<DataType>({
messageApi,
url: `/api/invoice/get/${props.invoiceId}`,
2025-03-28 09:44:48 +08:00
onSuccess({ data }) {
2024-04-07 17:37:09 +08:00
setInvoiceData({
...data
});
setOrderAmount((data.invoiceAmount / 100).toFixed(2));
}
})
2025-03-28 09:44:48 +08:00
2024-04-07 17:37:09 +08:00
}, []);
return (
<>
{messageContext}
<Divider orientation="left" plain></Divider>
<table className="pay-table">
<colgroup>
2025-03-28 09:44:48 +08:00
<col width="120" />
<col />
2024-04-07 17:37:09 +08:00
</colgroup>
<tbody>
2025-03-28 09:44:48 +08:00
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoiceTitle}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoiceNo}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoiceAddress}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoicePhone}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoiceAccount}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.invoiceBank}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.content}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.rate}</td>
</tr>
<tr>
<td className="table-label"> *</td>
<td>{invoiceData?.type}</td>
</tr>
2024-04-07 17:37:09 +08:00
</tbody>
</table>
<Divider orientation="left" plain></Divider>
<table className="pay-table">
<colgroup>
2025-03-28 09:44:48 +08:00
<col width="120" />
<col />
2024-04-07 17:37:09 +08:00
</colgroup>
<tbody>
2025-03-28 09:44:48 +08:00
<tr>
<td className="table-label"> *</td>
<td>
<div>
<span></span>
<span style={{ fontSize: '20px', fontWeight: 'bold' }}>{orderAmount}</span>
<Button type="link" size="small" onClick={() => {
setIsInvoiceOrderListOpen(true);
}}></Button>
</div>
</td>
</tr>
<tr>
<td className="table-label"></td>
<td>{invoiceData?.invoiceNote}</td>
</tr>
2024-04-07 17:37:09 +08:00
</tbody>
</table>
<Modal open={isInvoiceOrderListOpen}
2025-03-28 09:44:48 +08:00
centered
title="开票订单"
width={1000}
footer={false}
onCancel={() => setIsInvoiceOrderListOpen(false)}
2024-04-07 17:37:09 +08:00
>
2025-03-28 09:44:48 +08:00
<InvoiceInfoSelectedList invoiceId={props.invoiceId} />
2024-04-07 17:37:09 +08:00
</Modal>
</>
);
}