Layui 实现批量删除

function bathchDeleteUser() {
//获取选中状态,为table的id
var checkStatus = table.checkStatus('testReload');
//获取选中数量
var selectCount = checkStatus.data.length;
console.log(checkStatus.data);
if (selectCount == 0) {
layer.msg('批量删除至少选中一项数据', function () {
});
return false;
}
layer.confirm('真的要删除选中的项吗?', function (index) {
layer.close(index);
index = layer.load(1, {shade: [0.1, '#fff']});

let isStr = "";
for (let i = 0; i < selectCount; i++) {
isStr = isStr + "," + checkStatus.data[i].uid;
}
$.ajax({
type: 'post',
data: {"idsStr": isStr},
url: 'http://localhost:8080/user_info/batch_delete',
success: function (data) {
if (data.code === 20000) {
layer.close(index);
layer.msg(data.msg);
//表格重载
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
}, 'data');
} else {
layer.msg(data.msg);
}
}
});
})
}
 
posted @ 2020-11-18 23:47  永无八哥  阅读(18)  评论(0编辑  收藏  举报