import React, { memo } from 'react'; import { SummaryRow, TD } from '../style'; import { calcOffsets, mapFixedClass } from '../helpers'; import { IColumn, ITable } from '../types'; const Summary = function({ columns, showChecker, showSummary, fixRow, summaryData, onChange }: ITable) { const filteredColumns = columns.filter(Boolean) as IColumn[]; const [leftOffset, rightOffset, leftFixedIndex, rightFixedIndex] = calcOffsets(filteredColumns, !!showChecker); const checkFixed = filteredColumns[0] && filteredColumns[0].fixed === 'left' ? 'fix-left-cell' : ''; return ( showSummary && ( {[ !!showChecker && ( 汇总 ), ].concat( filteredColumns.map((col: IColumn, index) => { if (!index && !showChecker) { return ( index ? leftOffset[index] : rightOffset[index]} > 汇总 ); } return ( index ? leftOffset[index] : rightOffset[index]} > {col.render ? col.render({ value: summaryData[col.key as string], index, row: summaryData, onChange, key: col.key, }) : summaryData[col.key as string] || '-'} ); }) )} ) ); }; export default memo(Summary);