system-copyright-react/src/components/invoice/order/InvoiceOrderSelectedList.tsx

167 lines
4.9 KiB
TypeScript
Raw Normal View History

2025-03-28 09:44:48 +08:00
import {Table, TableProps,
Tooltip} from "antd";
2024-04-07 17:37:09 +08:00
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";
2025-03-28 09:44:48 +08:00
// type DetailDataType = {
// productType: string;
// quantity: number;
// unitPrice: number;
// notes: string;
// productDescription: string;
// }
2024-04-07 17:37:09 +08:00
type DataType = {
orderId: string;
orderNo: string;
totalAmount: number;
2025-03-28 09:44:48 +08:00
orderDetails: any;
2024-04-07 17:37:09 +08:00
orderStatus: string;
gmtCreate: string;
}
interface ListProps {
invoiceId: string;
}
export default function InvoiceInfoSelectedList(props: ListProps) {
const [messageApi, messageContext] = useMessage();
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [dataArray, setDataArray] = useState<DataType[]>([]);
const columns: TableProps<DataType>['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: '产品类型',
2025-03-28 09:44:48 +08:00
dataIndex: 'orderDetails.0.productType',
2024-04-07 17:37:09 +08:00
align: 'center',
width: 100,
render: (_value, record) => {
2025-03-28 09:44:48 +08:00
if(record.orderDetails[0].productType === 'PROJ') {
2024-04-07 17:37:09 +08:00
return '项目创建'
}
2025-03-28 09:44:48 +08:00
if(record.orderDetails[0].productType === 'AGENT') {
2024-04-07 17:37:09 +08:00
return '项目代理'
}
2025-03-28 09:44:48 +08:00
return record.orderDetails[0].productType
2024-04-07 17:37:09 +08:00
}
},
{
title: '数量',
2025-03-28 09:44:48 +08:00
dataIndex: 'orderDetails.0.quantity',
2024-04-07 17:37:09 +08:00
align: 'center',
width: 100,
render: (_value, record) => {
2025-03-28 09:44:48 +08:00
return record.orderDetails[0].quantity
2024-04-07 17:37:09 +08:00
}
},
{
title: '单价',
2025-03-28 09:44:48 +08:00
dataIndex: 'orderDetails.0.unitPrice',
2024-04-07 17:37:09 +08:00
align: 'center',
width: 100,
render: (_value, record) => {
2025-03-28 09:44:48 +08:00
return (record.orderDetails[0].unitPrice / 100).toFixed(2)
2024-04-07 17:37:09 +08:00
}
},
{
title: '订单备注',
2025-03-28 09:44:48 +08:00
dataIndex: 'orderDetails.0.notes',
2024-04-07 17:37:09 +08:00
align: 'center',
width: 120,
render: (_value, record) => {
2025-03-28 09:44:48 +08:00
return record.orderDetails[0].notes
2024-04-07 17:37:09 +08:00
}
},
{
title: '描述',
2025-03-28 09:44:48 +08:00
dataIndex: 'orderDetails.0.productDescription',
2024-04-07 17:37:09 +08:00
align: 'center',
width: 200,
ellipsis: {
showTitle: false,
},
render: (_value, record) => {
2025-03-28 09:44:48 +08:00
return <Tooltip placement="top" title={record.orderDetails[0].productDescription}>{record.orderDetails[0].productDescription}</Tooltip>
2024-04-07 17:37:09 +08:00
}
},
]
2025-03-28 09:44:48 +08:00
// const columns = []
2024-04-07 17:37:09 +08:00
useEffect(() => {
get<IListPage<DataType>>({
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}
<div className="invoice-list-container">
<div className="mod-list">
<Table columns={columns} dataSource={dataArray} pagination={
{
pageSize: 20,
total: total,
2024-08-12 14:43:58 +08:00
showSizeChanger: false,
2024-04-07 17:37:09 +08:00
onChange: (currentPage) => {
setPage(currentPage);
}
2024-08-12 14:43:58 +08:00
2024-04-07 17:37:09 +08:00
}
} scroll={{y: 500}} bordered key="dataTable" rowKey="orderId"/>
</div>
</div>
</>
);
}