<el-table
border
show-summary //显示合计
:summary-method="yearEvalDetaSum"//合计计算方法
:span-method="arraySpanMethod2"
// 合并相同name单元格
arraySpanMethod1({ row, column, rowIndex, columnIndex }) {
},
//计算合计
yearEvalSum(params) {
const { columns, data } = params;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "合计";
return;
}
if (column.property === "score") {
const values = data.map((item) => item[column.property]);
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] += "";
} else if (column.property === "scoreExam") {
const values = data.map((item) => item[column.property]);
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(2) + "";
} else {
sums[index] = "";
}
});
return sums;
},
//字符串转数值
Number(item.dayScoreExam)
数字input中英文导致值失效
oninput="this.value=this.value.replace(/[^\d]/g,'');"
@blur="yearChange"
yearChange(e) {
this.dataForm.year = e.target.value;
}
转化tabledata column枚举值
:formatter="setwarType"
setwarType(row, column){
switch (row.type) {
case "1":
return "行政处罚";
default:
return "";
}
},