弄报告 考勤 导出数据 导入layui.excel插件
下载layui.excel插件 导出报表
<a class="layui-btn" id="exportbiao"><i class="layui-icon layui-icon-export ad"></i> 导出全部</a>
<button class="layui-btn" type="button" id="chaxunbaogao">
<i class="layui-icon layui-icon-search"></i> 查询
// 导出数据
$("#exportbiao").click(function () {
daochubaogao()
})
function daochubaogao(){
var DeptID = $("#DeptID").val();
var EmpID = $("#EmpID").val();
var TrustDate1 = $("#TrustDate1").val();
var DateTime= $("#TrustDate2").val();
xgweb.ajaxPost(xgweb.apiAdd() + "WorkRecord/selectbydeptIDdate", {
"DeptID": DeptID,
"DateTime": DateTime,
'StartDateTime':TrustDate1,
"EmpID":EmpID,
"Excel":'true'
}, function (ret) {
console.log(ret)
ret.data.unshift({ deptname: '部门名称',empname: '员工姓名',regdate: '日期',empname: '员工姓名',worktype: '工作状态',datetime1:'早上打卡时间'
,datetime2:'下午打卡时间'});
var data = layui.excel.filterExportData( ret.data, {
deptname:'deptname',
empname:'empname',
regdate:'regdate',
regdate:'regdate',
worktype:'worktype',
});
layui.excel.exportExcel({
sheet1:data
}, '考勤流水.xlsx', 'xlsx');
});
}
//查询数据
$("#chaxunbaogao").click(function () {
getbaogao()
})
// var pdfData=ret.data.mPdfDataList[0].pdFListData 获取数据时,通过数组方式导出值并拼接
function getbaogao(){
var DeptID = $("#DeptID").val();
var EmpID = $("#EmpID").val();
var TrustDate1 = $("#TrustDate1").val();
var DateTime= $("#TrustDate2").val();
// var loadup= layer.load(0);
xgweb.ajaxPost(xgweb.apiAdd() + "WorkRecord/selectbydeptIDdate", {
"DeptID": DeptID,
"DateTime": DateTime,
'StartDateTime':TrustDate1,
"EmpID":EmpID,
"Excel":'true'
}, function (ret) {
console.log(ret)
table.render({
elem: '#test'
, title: '考勤流水'
, toolbar: true
, data: ret.data
// , limit: dataJson.length
// ,page:true
,page: {limits:[10,20,30,50,100]}//开启分页
, cols: [
[{
field: 'deptname',
title: '部门名称',
'width': '20%',
align: 'center',
'unresize': true
},
{
field: 'empname',
title: '员工姓名',
align: 'center',
'width': '20%',
'unresize': true
},
{
field: 'regdate',
title: '日期',
align: 'center',
'width': '10%',
'unresize': true
},
{
field: 'datetime1',
title: '早上打卡时间',
'width': '20%',
align: 'center',
'unresize': true,
templet: function (d) {
if (d.datetime1 != null&&d.datetime1!="") {
return ChangeDateFormatsss(d.datetime1);
} else {
return '无';
}
}
}, {
field: 'datetime2',
title: '下午打卡时间',
'width': '20%',
align: 'center',
'unresize': true,
templet: function (d) {
if (d.datetime2 != null&& d.datetime2!="") {
return ChangeDateFormatsss(d.datetime2);
} else {
return '无';
}
}
}, {
field: 'worktype',
title: '工作状态',
align: 'center',
'unresize': true,
templet: function (d) {
if (d.worktype==="休假") {
d.datetime1="无";
d.datetime2="无";
}
return d.worktype;
}
}
]
],
});
});
}