表格批量删除
1. 表格选中后批量删除
// 批量清除
delHandle () {
// 拿到选中的数据;
var val = this.selectTable
// 如果选中数据存在
if (val) {
// 将选中数据遍历
val.forEach((item, index) => {
// 遍历源数据
this.tableData.forEach((itemI, indexI) => {
// 如果选中数据跟元数据某一条标识相等,删除对应的源数据
if (item.id === itemI.id) {
this.tableData.splice(indexI, 1)
}
})
})
}
// 清除选中状态
this.$refs.multipleTable.clearSelection()
}
delHandle() {
// 遍历选中的所有数据
this.selectedRows.forEach((items) => {
// 用 filter 遍历表格所有数据 返回值为新数组
this.tableData = this.tableData.filter(
// 当选中数据的Wellname != 表格中数据的Wellname 就是要保留下的值
(item) => item.WellName != items.WellName
);
});
this.selectedRowKeys = [];
this.selectedRows = [];
},