[1]批量增删时如何判断是否至少选中一条数据$("#add").click(function(){//批量使用(获取选中的复选框)vartest=$("input[name='btSelectItem']:checked");varcheckBoxValue="";test.each(function(){checkBoxValue+=$(this).val()+",",";})checkBoxValue=checkBoxValue。substring(0,checkBoxValue.length-1);//todo验证varrows=$('#exampleTable').bootstrapTable('getSelections');//返回所有选中的行,当没有选中的记录时,返回一个空arrayif(rows.length==0){toastr.error("请选择至少一个供应商");return;}else{vartypeid=$("#typeid").val();$.ajax({缓存:true,类型:“POST”,url:“/base/supSupt/save?typeid="+typeid+"&ids="+encodeURIComponent(checkBoxValue),数据:null,异步:true,错误:函数(请求){toastr.error("Connectionerror");},success:function(data){if(data.code==0){toastr.success("操作成功。");$('#modal-addSup').modal('隐藏');//刷新更新细节();窗口打开();}else{toastr.error(data.msg);}}});}})[2]表格选择下面官方的bootstrap写法$("#add").click(function(){varrows=$('#exampleTable').bootstrapTable('getSelections');//返回所有选中的行,当没有选中的记录时,返回一个空数组if(rows.length==0){toastr.error("请选择要添加的供应商");return;}else{varids=newArray();$.each(rows,function(i,row){ids[i]=row['id'];});console.log(ids);$.ajax({type:'POST',数据:{“ids”:ids},url:'/base/supSupt/save?typeid='+$(“#typeid”).val(),成功:函数(r){if(r.code==0){toastr.success(r.msg);window.open();}else{toastr.error(r.msg);}}});}})代码隐藏:/***Save*/@ResponseBody@PostMapping("/save")@RequiresPermissions("base:supSupt:add")publicRsave(SupSuptDOsupSupt,Modelmodel,@RequestParam("typeid")Stringtypeid,@RequestParam("ids[]")String[]ids){//将要获取的ids(供应商的id=supid)用逗号拆分成数组inti=0;for(Stringsupid:ids){i++;Stringuuid=UUID.randomUUID().toString().replace("-","");supSupt.setToid(uuid);supSupt.setTypeid(typeid);supSupt.setSupid(supid);if(supSuptService.save(supSupt)>0){if(ids.length==i){returnR.ok();}else{继续;}}else{返回R.error();}}returnR.error();}【3】全选复选框,禁止全选//html:
