添加页面合计

This commit is contained in:
liu
2026-09-16 23:51:57 +08:00
parent 80cbd452e5
commit 751e8a196c
5 changed files with 129 additions and 2 deletions
+40
View File
@@ -162,6 +162,45 @@ const BillPage: React.FC = () => {
);
};
/** 列表底部合计行:统计当前页的 商品金额/配送费/附加金额/售后金额/账单总金额 */
const renderListSummary: TableProps<IBill>['summary'] = (pageData) => {
const sums = pageData.reduce(
(acc, row) => ({
product_amount: acc.product_amount + Number(row.product_amount ?? 0),
delivery_fee: acc.delivery_fee + Number(row.delivery_fee ?? 0),
added_amount: acc.added_amount + Number(row.added_amount ?? 0),
after_sale: acc.after_sale + Number(row.after_sale ?? 0),
total_amount: acc.total_amount + Number(row.total_amount ?? 0),
}),
{ product_amount: 0, delivery_fee: 0, added_amount: 0, after_sale: 0, total_amount: 0 },
);
return (
<Table.Summary.Row>
<Table.Summary.Cell index={0} colSpan={4} align="center">
<Text strong>本页合计</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={4} align="center">
<Text strong>¥{sums.product_amount.toFixed(2)}</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={5} align="center">
<Text strong>¥{sums.delivery_fee.toFixed(2)}</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={6} align="center">
<Text strong>¥{sums.added_amount.toFixed(2)}</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={7} align="center">
<Text strong type={sums.after_sale < 0 ? 'success' : undefined}>
¥{sums.after_sale.toFixed(2)}
</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={8} align="center">
<Text strong type="danger">¥{sums.total_amount.toFixed(2)}</Text>
</Table.Summary.Cell>
<Table.Summary.Cell index={9} colSpan={4} />
</Table.Summary.Row>
);
};
/** 关联订单列 */
const orderColumns: TableProps<IBillOrder>['columns'] = [
{
@@ -343,6 +382,7 @@ const BillPage: React.FC = () => {
tableRef,
operateRender,
formProps: false,
summary: renderListSummary,
actionBarRender: (dom) => [dom.search, dom.keywordSearch],
toolBarRender: (dom) => [
dom.columnSetting,