elment表格总计列进行字段筛选相加
作者:互联网
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 }
标签:index,const,表格,相加,sums,elment,value,return,curr 来源: https://www.cnblogs.com/liangtang/p/15938784.html