添加页面合计
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 (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, DatePicker, Form, Modal, Select, Typography } from 'antd';
|
||||
import { Button, DatePicker, Form, Modal, Select, Table, Typography } from 'antd';
|
||||
import type { TableProps } from 'antd';
|
||||
import { DownloadOutlined } from '@ant-design/icons';
|
||||
import dayjs from 'dayjs';
|
||||
import XinTable from '@/components/XinTable';
|
||||
@@ -165,6 +166,36 @@ const ContainerReturnPage: React.FC = () => {
|
||||
},
|
||||
];
|
||||
|
||||
/** 列表底部合计行:统计当前页的 压(回)筐数量/压(回)托盘数量/抵扣(附加)金额 */
|
||||
const renderListSummary: TableProps<IContainerReturn>['summary'] = (pageData) => {
|
||||
const sums = pageData.reduce(
|
||||
(acc, row) => ({
|
||||
box_num: acc.box_num + Number(row.box_num ?? 0),
|
||||
tray_num: acc.tray_num + Number(row.tray_num ?? 0),
|
||||
amount: acc.amount + Number(row.amount ?? 0),
|
||||
}),
|
||||
{ box_num: 0, tray_num: 0, amount: 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">
|
||||
<SignedNum value={sums.box_num} />
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={3} align="center">
|
||||
<SignedNum value={sums.tray_num} />
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={4} colSpan={2} />
|
||||
<Table.Summary.Cell index={6} align="center">
|
||||
<SignedAmount value={sums.amount.toFixed(2)} />
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={7} colSpan={3} />
|
||||
</Table.Summary.Row>
|
||||
);
|
||||
};
|
||||
|
||||
const tableProps: XinTableProps<IContainerReturn> = {
|
||||
api: '/recon/container-return',
|
||||
columns,
|
||||
@@ -175,6 +206,7 @@ const ContainerReturnPage: React.FC = () => {
|
||||
editShow: false,
|
||||
deleteShow: false,
|
||||
formProps: false,
|
||||
summary: renderListSummary,
|
||||
toolBarRender: (dom) => [
|
||||
<AuthButton key="export" auth="recon.containerReturn.export">
|
||||
<Button icon={<DownloadOutlined />} onClick={() => setExportOpen(true)}>
|
||||
|
||||
@@ -245,6 +245,22 @@ const PaymentPage: React.FC = () => {
|
||||
) : null,
|
||||
];
|
||||
|
||||
/** 列表底部合计行:统计当前页的支付金额 */
|
||||
const renderListSummary: TableProps<IPayment>['summary'] = (pageData) => {
|
||||
const totalAmount = pageData.reduce((sum, row) => sum + Number(row.amount ?? 0), 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 type="danger">¥{totalAmount.toFixed(2)}</Text>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={3} colSpan={6} />
|
||||
</Table.Summary.Row>
|
||||
);
|
||||
};
|
||||
|
||||
const tableProps: XinTableProps<IPayment> = {
|
||||
api: '/recon/payment',
|
||||
columns,
|
||||
@@ -253,6 +269,7 @@ const PaymentPage: React.FC = () => {
|
||||
tableRef,
|
||||
operateRender,
|
||||
formProps: false,
|
||||
summary: renderListSummary,
|
||||
actionBarRender: (dom) => [dom.search, dom.keywordSearch],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user