批量删除

This commit is contained in:
shilixia 2020-10-13 15:39:53 +08:00
parent 8ec41462d7
commit 6891e1a756
2 changed files with 52 additions and 1 deletions

View File

@ -43,7 +43,14 @@ export function deleteCMA(id) {
method: 'delete' method: 'delete'
}) })
} }
export function deletearry(data)
{
return request({
url: `/ability/cma/deletearry/`,
method: 'post',
data
})
}
export function importCMA(data) { export function importCMA(data) {
return request({ return request({
url: `/ability/cma/import/`, url: `/ability/cma/import/`,

View File

@ -74,6 +74,10 @@
<el-button slot="reference">导入分子公司能力</el-button> <el-button slot="reference">导入分子公司能力</el-button>
</el-popover> </el-popover>
</div> </div>
<div style="margin-top: 20px">
<el-button @click="delAll()" type="danger">批量删除</el-button>
<el-button @click="toggleSelection()">取消选择</el-button>
</div>
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="cmaList.results" :data="cmaList.results"
@ -84,8 +88,13 @@
highlight-current-row highlight-current-row
max-height="700" max-height="700"
ref="filterTable" ref="filterTable"
@selection-change="handleSelectionChange">
@filter-change="filterChange" @filter-change="filterChange"
> >
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="大类名称"> <el-table-column label="大类名称">
<template slot-scope="scope" <template slot-scope="scope"
@ -216,6 +225,7 @@ import {
getCMAList, getCMAList,
createCMA, createCMA,
deleteCMA, deleteCMA,
deletearry,
updateCMA, updateCMA,
importCMA2, importCMA2,
getCNASList, getCNASList,
@ -243,6 +253,7 @@ export default {
cma: defaultCMA, cma: defaultCMA,
upHeaders: upHeaders(), upHeaders: upHeaders(),
upUrl: upUrl(), upUrl: upUrl(),
delarr: [],
groupBy: { sszx: [], glzz: [] }, groupBy: { sszx: [], glzz: [] },
cmaList: { count: 0 }, cmaList: { count: 0 },
listLoading: true, listLoading: true,
@ -363,6 +374,39 @@ export default {
console.error(err); console.error(err);
}); });
}, },
toggleSelection() {
this.$refs.filterTable.clearSelection();
},
delAll() {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
const length = this.multipleSelection.length;
for (let i = 0; i < length; i++) {
this.delarr.push(this.multipleSelection[i].id);
}
let data = { ids: this.delarr };
deletearry(data)
.then((res) => {
this.$message({
message: "删除成功",
type: "success",
});
this.getList();
})
})
.catch((err) => {
console.error(err);
});
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
filterChange(obj) { filterChange(obj) {
for (let key in obj) { for (let key in obj) {
this.listQuery[key] = obj[key][0]; this.listQuery[key] = obj[key][0];