//#region 返回选中行数据 function getSelectedRowsData(selector) { ///<summary>返回选中行数据</summary> ///<param name="selector">Bootstrap Table 表对象</param> return $.map(selector.bootstrapTable("getSelections"), function(row) { return row; // 返回选中行数据 }); } //#endregion
// 删除 $("#btnBatchDelete").on("click", function() { var selectedRows = getSelectedRowsData($("#tableTop")); if (selectedRows.length === 0) { toastr.warning("请选择要删除的数据!"); return; } else { toastr.warning(selectedRows.length); var idArray = []; for (var i = 0; i < selectedRows.length; i++) { idArray.push(selectedRows[i].BookId); } // 弹窗 确认 swal({ title: "温馨提示", text: "您确认要删除图书ID:" + idArray + "吗?", icon: "warning", buttons: true, dangerMode: true, }) .then((willDelete) => { if (willDelete) { // 删除操作逻辑实现 toastr.success("删除操作执行中!"); window.swal("删除成功!", { icon: "success" }); // 刷新数据 window.swal("刷新数据成功!", { icon: "success" }); } else { } }); } });