vue iview 批量删除
<Row class="operation"><Button @click="delAll" icon="md-trash">批量删除</Button></Row><Row><Alert show-icon>已选择...
·
<Row class="operation">
<Button @click="delAll" icon="md-trash">批量删除</Button>
</Row>
<Row>
<Alert show-icon>
已选择
<span class="select-count">{{selectCount}}</span> 项
<a class="select-clear" @click="clearSelectAll">清空</a>
</Alert>
</Row>
table
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
data
selectList: [], // 多选数据
selectCount: 0, // 多选计数
method
//批量删除
delAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
onOk: () => {
let ids = "";
this.selectList.forEach(function(e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
// 批量删除
// this.deleteRequest("请求地址,如/deleteByIds/" + ids).then(res => {
// if (res.success) {
// this.$Message.success("操作成功");
// this.clearSelectAll();
// this.getDataList();
// }
// });
// 模拟请求成功
this.$Message.success("操作成功");
this.clearSelectAll();
this.getDataList();
}
});
},
//清空
clearSelectAll() {
this.$refs.table.selectAll(false);
},
//多选
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
//排序
changeSort(e) {
this.sortColumn = e.key;
this.sortType = e.order;
if (e.order == "normal") {
this.sortType = "";
}
this.getDataList();
},
更多推荐
已为社区贡献1条内容
所有评论(0)