<el-table ref="dragTable" border @header-dragend="headerDragend" :max-height="tableHeight" stripe :data="list"
:cell-style="$style.cellStyle" :header-cell-style="$style.rowClass" show-summary :summary-method="getSummaries">
<el-table-column label="序号" type="index" width="55" />
<el-table-column prop="houseName" label="仓库名称" v-if="whId == 0" align="center">
</el-table-column>
<el-table-column v-for="item in confirmHead" :key="item.label" :label="item.label" :prop="item.prop"
:width="item.width" align="center" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="item.storageMode">
<span>{{ whAStyleData[scope.row.storageMode] }}</span>
</span>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
<template slot="empty">
<img src="../../assets/img/empty.png" alt="" srcset="" style="height: calc(100vh - 430px)" />
<h4>暂无数据~</h4>
</template>
</el-table>
const noSummariesList = [
"storageMode"
];
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "合计";
return;
}
//去除不用合计得列
if (noSummariesList.includes(column.property)) {
sums[index] = "";
return;
}
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)
.toFixed(2);
} else {
sums[index] = "";
}
});
return sums;
},
element table最后一行总计去除不用合计的列
于 2023-02-15 10:05:16 首次发布