前端页面代码:
onfocus="if(value!='')value=''" onblur="if(!value)value=''"/> onfocus="if(value!='')value=''" onblur="if(!value)value=''"/> onfocus="if(value!='')value=''" onblur="if(!value)value=''"/> onfocus="if(value!='')value=''" onblur="if(!value)value=''"/> 搜索 @if(shiro.hasPermission("/deviceManage/add")){ 添加 @} 导出 js代码: /** * 导出Excel(导出全部,导出选中条数,根据条件导出) */$('#btnExp').click(function (obj){ var checkRows = table.checkStatus(DeviceManage.tableId); var data = checkRows.data; //获取选中的数据 // 没有勾选数据就导出所有数据 if (data == null || data == "" || data == undefined){ // 获取搜索框的条件 var lineAlias = $("#lineAlias").val(); var deviceName = $("#deviceName").val(); var deviceIp = $("#deviceIp").val(); var tensionName = $("#tensionName").val(); $.ajax({ url: Feng.ctxPath + '/deviceManage/list?lineAlias='+lineAlias+'&deviceName='+deviceName +'&deviceIp='+deviceIp+'&tensionName='+tensionName, type: "post", dataType: 'json', data: { page: 1, limit: 1000000 // 总条数,确保数据都能导出 }, success: function (result) { table.exportFile(tableResult.config.id, result.data,"xls","xxx管理表"); }, error:function(result){ alert("导出失败!"); } }); } else { /* 如果复选框有勾选就导出勾选的数据,但只有勾选本页的数据才会导出 */ table.exportFile(tableResult.config.id,data,"xls",'xxx管理表'); }});后台代码: /** * 查询列表 */@ResponseBody@RequestMapping("/list")public LayuiPageInfo list(String lineAlias,String deviceName,String deviceIp,String tensionName) { Page> list = this.deviceManageService.joinList(lineAlias,deviceName,deviceIp,tensionName); Page> wrap = new DeviceManageWrapper(list).wrap(); return LayuiPageFactory.createPageInfo(wrap);} java
js代码:
/**
* 导出Excel(导出全部,导出选中条数,根据条件导出) */$('#btnExp').click(function (obj){ var checkRows = table.checkStatus(DeviceManage.tableId); var data = checkRows.data; //获取选中的数据 // 没有勾选数据就导出所有数据 if (data == null || data == "" || data == undefined){ // 获取搜索框的条件 var lineAlias = $("#lineAlias").val(); var deviceName = $("#deviceName").val(); var deviceIp = $("#deviceIp").val(); var tensionName = $("#tensionName").val(); $.ajax({ url: Feng.ctxPath + '/deviceManage/list?lineAlias='+lineAlias+'&deviceName='+deviceName +'&deviceIp='+deviceIp+'&tensionName='+tensionName, type: "post", dataType: 'json', data: { page: 1, limit: 1000000 // 总条数,确保数据都能导出 }, success: function (result) { table.exportFile(tableResult.config.id, result.data,"xls","xxx管理表"); }, error:function(result){ alert("导出失败!"); } }); } else { /* 如果复选框有勾选就导出勾选的数据,但只有勾选本页的数据才会导出 */ table.exportFile(tableResult.config.id,data,"xls",'xxx管理表'); }});后台代码:
/** * 查询列表 */@ResponseBody@RequestMapping("/list")public LayuiPageInfo list(String lineAlias,String deviceName,String deviceIp,String tensionName) { Page> list = this.deviceManageService.joinList(lineAlias,deviceName,deviceIp,tensionName); Page> wrap = new DeviceManageWrapper(list).wrap(); return LayuiPageFactory.createPageInfo(wrap);}