getSummaries(param) { const { columns, data } = param const sums = [] columns.forEach((column, index) => { if (index === 1) { sums[index] = '合计' return } const values = data.map(item => Number(item[column.property])) console.log(column.property) if (!values.every(value => isNaN(value))) { sums[index] = values.reduce((prev, curr) => { const value = Number(curr) if (!isNaN(value)) { return prev + curr } else { return prev } }, 0)
//通过column.property指定列 switch(column.property){ case 'product_count': sums[index] = toThousandslsFilter(sums[index]) break; case 'sum': sums[index] = toThousandslsFilter(sums[index]) break; default: sums[index] = '' } } else { sums[index] = '' } }) return [sums] }
标签:index,const,column,sums,value,Element,return,table,末尾 From: https://www.cnblogs.com/webwangjie/p/17505869.html