注意点:
1. <el-table> 中 加:summary-method=”getSummaries”
2. <el-table-column> 中要加 prop
// 房间号的合计去掉
getSummaries (param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总计'
} else if (index === 5 || index === 6) {
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 prev + curr
} else {
return prev
}
}, 0)
} else {
sums[index] = 'N/A'
}
版权声明:本文为Akatsuki233原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。