Analysis of ideas
after a single use of a background check box is selected to transmit data directly clearly unreasonable (because I am a front desk is open foreach to traverse a list, a transfer can only pass one value), so the need for increased control the button or the detection control for detecting a list in which the check box is selected
Code
$("#exportTreeGrid").click(function(){
alert('123');
var id_array = new Array();
$("input[id='checkId']:checked").each(function(){
id_array.push($(this).val());
});
//alert(id_array);
if(id_array.length == 0){
alert('请您选择要导出的复选框');
return ;
}else{
top.$.jBox.confirm("确认要导出已经确认的数据吗?","系统提示",function(v,h,f){
if(v=="ok"){
location.href="${ctx}/fdzapp/combineList/batchExport?combineCodes="+id_array;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
}
});
$("#checkAll").click(function(){
if(this.checked){
$("input[id='checkId']").attr("checked","checked");
var arrs=new Array();
$("input[id='checkId']:checked").each(function(){
if($(this).attr("checked")){
arrs.push($(this).val());
}
});
if(arrs.length==0 ){
alert('请选择数据!');
return ;
}
var combineCodes = arrs;
//var combineCodes = arrs.join(",");
//alert(combineCodes);
debugger;
top.$.jBox.confirm("确认要导出数据吗?","系统提示",function(v,h,f){
if(v=="ok"){
location.href="${ctx}/fdzapp/combineList/batchExport?combineCodes="+combineCodes;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
// alert(ids);
}else{
$("input[id='checkId']").attr("checked",null);
}
});
前台向后台传入的是字符串,后台取到后分隔就行了
@RequiresPermissions("fdzapp:combineList:edit")
@RequestMapping(value = {"batchExport"})
public void batchExport(@RequestParam String combineCodes,HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes){
System.err.println(combineCodes);
try {
String fileName = "合件明细数据"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
if(StringUtils.isNotBlank(combineCodes)){
String[] staffIds = combineCodes.split(",");
List<CombineList> lists = new ArrayList<CombineList>();
for (String combineCode1 : staffIds) {
String combineCode = combineCode1.substring(0, combineCode1.length());
System.err.println(combineCode);
CombineList combineList = new CombineList();
combineList.setCombineCode(combineCode);
combineList.setListStatus("4");
// System.err.println(combineList.getCombineCode()+"输出看看");
List<CombineList> list = combineListService.find4CwBatchExport(combineList);
System.err.println(list.get(0).getComponentCode()+"12345678");
lists.addAll(list);
}
if(lists.size() == 0) {//没取到值
addMessage(redirectAttributes, "批量操作失败了!!!!");
//return "redirect:" + Global.getAdminPath() + "/fdzapp/combineList/";
}else {
new ExportExcel("合件明细数据", CombineList.class).setDataList(lists).write(response, fileName).dispose();
//return null;
}
}
} catch (Exception e) {
addMessage(redirectAttributes, "数据导出失败!失败信息:"+e.getMessage());
}
// return "modules/fdzapp/combineCostList_Cw";
}
I am a rookie, posted in order to facilitate their future use, if not the exhibitions ah. .
Reproduced in: https: //www.cnblogs.com/hbym/p/11059204.html