export function getSummaries (param) { /* 表格总计行 */ const { columns, data } = param const sums = [] const columnList = ['boxes', 'purchaseQuantity', 'newboxes', 'newpurchaseQuantity', 'sendQuantity', 'totalPrice', 'totalPay', 'tobeSend', 'deliveryQuantity', 'newdeliveryQuantity', 'quantity', 'receiveQuantity', 'checkQuantity', 'instockQuantity', 'planQuantity', 'allAmount', 'payableAmount'] columns.forEach((column, index) => { if (index === 0) { sums[index] = '总计' } else if (columnList.includes(column.property)) { const values = data.map(item => Number(item[column.property])) if (!values.every(value => isNaN(value))) { sums[index] = values.reduce((prev, curr) => { const value = Number(curr) if (!isNaN(value)) { return accAdd(prev, curr) } else { return prev } }, 0) sums[index] += '' } else { sums[index] = '' } } }) return sums }