layui批量删除
//批量删除
$(".delAll_btn").on("click", function () {
//获取复选框的组件,testReload为table实例的id属性,不是table标签的id
var checkStatus = table.checkStatus('testReload'),
data = checkStatus.data,
linkId = [];
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
linkId.push(data[i].id);
}
//通过ajax提交删除id后台接口,实现数据删除
layer.confirm('确定批量删除部门?', {icon: 3, title: '提示信息'}, function (index) {
var ajaxReturnData;
$.ajax({
url: '${pageContext.servletContext.contextPath}/user/deleteBatch',
type: 'post',
data: {ids: linkId.toString()},
success: function (data) {
ajaxReturnData = data;
}
});
//删除结果
if (ajaxReturnData == '1') {
layer.msg('删除失败', {icon: 5});
} else {
window.parent.location.reload();
layer.msg('删除成功', {icon: 1});
}
layer.close(index);
});
}
});