table2excel 导出真分页数据如何处理
导入js:
<script type="text/javascript" src="${base}/js/jquery.table2excel.js"></script>
html部分:
<div class="ui edit buttons">
<button class="query ui red button" id="submit">查询</button>
<button class="query ui green button" id="export">导出</button>
</div>
<div class="column" id="column">
<table id="column1" class="ui very compact selectable celled table mini">
<thead>
<tr>
<th>序号</th>
<th>科室</th>
<th>姓名</th>
<th>工号</th>
<th>工龄</th>
<th>职称</th>
<th>类型</th>
<th>原因</th>
<th>申请时间</th>
<th>离院时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody id="tbody1" style="cursor:pointer">
</tbody>
<tfoot>
<tr>
<th colspan="12" id="pageBox">
</th>
</tr>
</tfoot>
</table>
</div>
<div id="printTableDiv" style="display: none">
<table id="printTable">
<thead>
<tr>
<th>序号</th>
<th>科室</th>
<th>姓名</th>
<th>工号</th>
<th>工龄</th>
<th>职称</th>
<th>类型</th>
<th>原因</th>
<th>申请时间</th>
<th>离院时间</th>
<th>状态</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
$(document).ready(function() {
//导出
$("#export").click(function () {
parent.layer.confirm('您确定导出此文件?', {
btn: ['确定', '取消'] //按钮
}, function () {
parent.layer.closeAll();
showPrintTable();
var cols=$("#printTable thead").find("th").length;
$("#printTable").table2excel({
exclude: ".noExl",
name: "Excel Document Name",
filename: "离职转岗退休报表",
exclude_img: true,
exclude_links: true,
exclude_inputs: true,
cols:cols
});
});
});
function showPrintTable(){
var str = "";
if (dataList.length == 0) {
var count = $("#table thead tr ").children("th").length;
str += "<tr><td colspan='" + count + "' style='font-size:1.0em'>很抱歉,暂无数据</td></tr>";
} else {
for (var i = 0; i < dataList.length; i++) {
str += renderTable(i, dataList[i], false);
}
}
$("#printTable tbody").html(str);
}
});
//加载数据方法
function loadData(curr,maproot){
var deptid=$("#dept_id").val();
var type=$("#type").val();
var reason=$("#reason").val();
var starttime=$("#starttime").val();
var endtime=$("#endtime").val();
var userName=$("#userName").val();
var jsonData={deptid:deptid,reason:reason,type:type,starttime:starttime,endtime:endtime,userName:userName};
$.layerPagerAjax({
url: basePath+'/personRegister/view.do',
datas:jsonData,
limit:10,
pagerBoxId:"pageBox",
isViewPagerInfo:true,
skin: '#D95C5C',
groups:5,
skip: true,
pageNumber:curr,
succuss:function(msg){
$("#tbody1").empty();
var str="";
var datas=msg.list;
dataList = datas;
if(datas.length==0){
var count=$("#column1 thead tr ").children("th").length;
$("#tbody1").append("<tr><td colspan='"+count+"' style='font-size:1.9em'>很抱歉,暂无数据</td></tr>");
}else{
var reasonname,useid,workingYear,teachnical;
for(var i = 0;i<datas.length;i++){
str += renderTable(i, datas[i], true);
}
$('#tbody1').append(str);
}
},
error:msgError
})
}
function renderTable(i, data, needbtn){
var userid=$("#loc_user_id").val();
var stateStr="";
var stateInfo="审核中";
if(maproot.b6!=undefined && data.state==0){
stateInfo="待审核";
stateStr+="<button class='ui edit green button' name='edit' id="+data.id+" type='3'>审核</button>";
}
if((data.operationusrid==userid && data.state==0) || maproot.a2=="a2"){
stateStr+="<button class='ui edit orange button'name='edit' type='2' id="+data.id+" >编辑</button>";
}if(data.state==1){
var day_count=data.day_count;
if(Number(day_count)<0){
stateInfo="待执行";
}else{
stateInfo="已审核";
}
stateStr="<button class='ui edit blue button' name='look' type='1' id="+data.id+">查看</button>";
}if(maproot.a4!=undefined ){
stateStr+="<button class='ui edit button' name='delete' data-user="+data.userid+" id="+data.id+">删除</button>";
}
if(data.state==2){
stateInfo="退回";
stateStr+="<button class='ui edit orange button'name='edit' type='2' id="+data.id+" >编辑</button>";
}
reasonname=data.reasonname;
useid=data.userid;
if(!data.teachnicals && !data.teachnical){
teachnical="";
}else{
teachnical=data.teachnical?data.teachnical:data.teachnicals
}
if(!data.workingYears && !data.workingYear){
workingYear="";
}else{
workingYear=data.workingYear?data.workingYear:data.workingYears+"年"
}
//召回
if(data.typename == "召回"){
stateInfo="完结";
}
if(stateInfo == "完结" || stateInfo == "待执行" || stateInfo == "已审核"){
stateStr="<button class='ui edit blue button' name='look' type='1' id="+data.id+">查看</button>";
}
return "<tr data-state="+data.state+"><td>"+(i+1)+"</td>"
+"<td>"+data.structure_name+"</td>"
+"<td>"+data.username+"</td>"
+"<td>"+(useid?useid:"")+"</td>"
+"<td>"+workingYear+"</td>"
+"<td>"+teachnical+"</td>"
+"<td>"+data.typename+"</td>"
+"<td>"+(reasonname?reasonname:"")+"</td>"
+"<td>"+timestampToTime(data.datime)+"</td>"
+"<td>"+timestampToTime(data.leavetime)+"</td>"
+"<td>"+stateInfo+"</td>"
+(needbtn?"<td><div class='ui edit buttons'>"+stateStr+"</div></td>":"");
}