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

132 lines
4.5 KiB
TypeScript
Raw Normal View History

2024-04-07 17:37:09 +08:00
import {Button, Divider, Modal} from "antd";
import {useEffect, useState} from "react";
import {get} from "../../util/AjaxUtils.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;
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(() => {
if (!props.invoiceId) {
return;
}
get<DataType>({
messageApi,
url: `/api/invoice/get/${props.invoiceId}`,
onSuccess({data}) {
setInvoiceData({
...data
});
setOrderAmount((data.invoiceAmount / 100).toFixed(2));
}
})
}, []);
return (
<>
{messageContext}
<Divider orientation="left" plain></Divider>
<table className="pay-table">
<colgroup>
<col width="120"/>
<col/>
</colgroup>
<tbody>
<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>
</tbody>
</table>
<Divider orientation="left" plain></Divider>
<table className="pay-table">
<colgroup>
<col width="120"/>
<col/>
</colgroup>
<tbody>
<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>
</tbody>
</table>
<Modal open={isInvoiceOrderListOpen}
title="开票订单"
width={1000}
footer={false}
onCancel={() => setIsInvoiceOrderListOpen(false)}
>
<InvoiceInfoSelectedList invoiceId={props.invoiceId}/>
</Modal>
</>
);
}