批量选择代码

// 批量推送
$('.send_select').click(() => {
// 显示加载框
var loadingIndex = layer.msg('正在更新数据,请稍候...', { icon: 16, shade: 0.2, time: 0 });
let ids = [];
let checked = $("input:checkbox[name='key[]']:checked");
$.each(checked, (key, val) => {
ids.push(val.value);
});
if (ids.length > 0) {
$.ajax({
type: "post",
url: `{:url('selectSend')}`,
data: { ids },
dataType: "json"
}).then(({ code, msg, data }) => {
// 关闭加载框
layer.close(loadingIndex);
if (code == 1) {
layer.msg(msg, { icon: 1, time: 1500 }, () => {
window.location = data.url;
});
} else {
layer.msg(msg, { icon: 2, time: 1500 });
}
return false;
});
} else {
layer.msg('请先勾选要推送的数据', { icon: 2, time: 1500 });
}
});