1.首先加一项多选框
<el-table
ref="table"
:data="tableData"
style="width: 100%"
border
height="95%"
>
<el-table-column type="selection" width="55" align="center">
</el-table-column>
</table>
// 批量删除
async delAll() {
if (this.$refs.table.selection.length == 0) {
this.$message.error("请选择要删除的参数!");
return;
}
const ret = await this.$confirm("此操作将永久删除,是否继续?", "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning"
}).catch(err => err);
if (ret == "cancel") return;
let params = [];
this.$refs.table.selection.map(data => {
params.push(data.roleId);
});
const res = await roleInfoAreaDel({ id: params.join(",") });
if (res.code == "1000") {
this.$message.success("删除成功!");
} else {
this.$message.error("删除失败!");
}
this.getRoleList();
},