使用antd4中summary
https://ant.design/components/table-cn/#components-table-demo-edit-row
summary={pageData => {
let totalNumber = 0;
let totalUnitPrice = 0;
pageData.forEach(({ number, unitPrice }) => {
totalNumber += Number(number);
totalUnitPrice += Number(unitPrice);
});
return (
<Table.Summary.Row>
<Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
<Table.Summary.Cell index={1}></Table.Summary.Cell>
<Table.Summary.Cell index={2}>{totalNumber||''}</Table.Summary.Cell>
<Table.Summary.Cell index={3}>{totalUnitPrice||''}</Table.Summary.Cell>
</Table.Summary.Row>
);
}}
侧边动态计算 onSave
onSave: async (rowKey, record, row) => {
record.totalAmt=record.number*record.approveUnitPrice-record.scrapValue
},