添加页面合计
This commit is contained in:
@@ -1214,6 +1214,43 @@ const PurchaseOrderPage: React.FC = () => {
|
||||
)
|
||||
];
|
||||
|
||||
/** 列表底部合计行:统计当前页的 预估成本/账单总金额/商品金额/总件数/总重量 */
|
||||
const renderListSummary: TableProps<IPurchaseOrder>['summary'] = (pageData) => {
|
||||
const sums = pageData.reduce(
|
||||
(acc, row) => ({
|
||||
estimate_amount: acc.estimate_amount + Number(row.estimate_amount ?? 0),
|
||||
bill_total_amount: acc.bill_total_amount + Number(row.bill_total_amount ?? 0),
|
||||
bill_product_amount: acc.bill_product_amount + Number(row.bill_product_amount ?? 0),
|
||||
total_quantity: acc.total_quantity + Number(row.total_quantity ?? 0),
|
||||
total_weight: acc.total_weight + Number(row.total_weight ?? 0),
|
||||
}),
|
||||
{ estimate_amount: 0, bill_total_amount: 0, bill_product_amount: 0, total_quantity: 0, total_weight: 0 },
|
||||
);
|
||||
return (
|
||||
<Table.Summary.Row>
|
||||
<Table.Summary.Cell index={0} colSpan={2} align="center">
|
||||
<Text strong>本页合计</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={2} align="center">
|
||||
<Text strong>¥{sums.estimate_amount.toFixed(2)}</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={3} align="center">
|
||||
<Text strong type="danger">¥{sums.bill_total_amount.toFixed(2)}</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={4} align="center">
|
||||
<Text strong type="danger">¥{sums.bill_product_amount.toFixed(2)}</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={5} align="center">
|
||||
<Text strong>{sums.total_quantity}</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={6} align="center">
|
||||
<Text strong>{sums.total_weight.toFixed(3)}斤</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={7} colSpan={3} />
|
||||
</Table.Summary.Row>
|
||||
);
|
||||
};
|
||||
|
||||
const tableProps: XinTableProps<IPurchaseOrder> = {
|
||||
api: '/purchase/order',
|
||||
columns,
|
||||
@@ -1225,6 +1262,7 @@ const PurchaseOrderPage: React.FC = () => {
|
||||
width: 300
|
||||
},
|
||||
formProps: false,
|
||||
summary: renderListSummary,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user