el-table 的sort-change
@sort-change="changeTableSort"
changeTableSort (column) {
const fieldName = column.prop;
const sortingType = column.order;
let tableData = [...this.tableDataCopy];
let sumData = {};
tableData.map((item, index) => {
if (item.problemTypeName === null) {
sumData = item;
}
})
if (sortingType != null) {
if (sortingType == "ascending") {
// 升序
tableData = tableData.sort((a, b) => b[fieldName] - a[fieldName]);
} else if (sortingType == "descending") {
// 降序
tableData = tableData.sort((a, b) => a[fieldName] - b[fieldName]);
}
tableData.forEach((item, index) => {
if (item.problemTypeName === null) {
tableData.splice(index, 1);
}
})
tableData.unshift(sumData)
this.tableData = tableData;
}
else {
this.tableData = this.tableDataCopy;
}
},