巡视计划
This commit is contained in:
parent
4c3a9a28d6
commit
abc560cbaa
Binary file not shown.
|
After Width: | Height: | Size: 464 B |
|
|
@ -7,11 +7,15 @@ var nextMonthFirstDay = new Date(currentDate.getFullYear(), currentDate.getMonth
|
||||||
var daysInMonth = Math.floor((nextMonthFirstDay.getTime() - firstDay.getTime()) / (24 * 60 * 60 * 1000));
|
var daysInMonth = Math.floor((nextMonthFirstDay.getTime() - firstDay.getTime()) / (24 * 60 * 60 * 1000));
|
||||||
// console.log(daysInMonth);
|
// console.log(daysInMonth);
|
||||||
var pers = []
|
var pers = []
|
||||||
var table, form, laydate,excel;
|
var table, form, laydate, excel;
|
||||||
var d;
|
|
||||||
var excelData=[];
|
|
||||||
|
|
||||||
layui.use(['form', 'layer', 'table', 'laydate','excel'], function() {
|
var excelData = [];
|
||||||
|
|
||||||
|
var cols = [],
|
||||||
|
tableDatas = [];
|
||||||
|
|
||||||
|
|
||||||
|
layui.use(['form', 'layer', 'table', 'laydate', 'excel'], function() {
|
||||||
excel = layui.excel;
|
excel = layui.excel;
|
||||||
table = layui.table;
|
table = layui.table;
|
||||||
form = layui.form;
|
form = layui.form;
|
||||||
|
|
@ -117,27 +121,29 @@ function init() {
|
||||||
page: true, //开启分页
|
page: true, //开启分页
|
||||||
skin: 'line', // 表格样式
|
skin: 'line', // 表格样式
|
||||||
cols: col,
|
cols: col,
|
||||||
data: tableData,
|
data: tableData,
|
||||||
title: '特勤考勤台账'//导出数据excel的表名称
|
title: '特勤考勤台账' //导出数据excel的表名称
|
||||||
});
|
});
|
||||||
console.log("col",col)
|
console.log("col", col)
|
||||||
console.log("tableData",tableData)
|
console.log("tableData", tableData)
|
||||||
|
cols = col[0]
|
||||||
excelData.push(['特勤考勤台账']);
|
tableDatas = tableData;
|
||||||
// 使用 cols 和 data 构造一个包含表头的新数组
|
// // 使用 cols 和 data 构造一个包含表头的新数组
|
||||||
excelData.push(col[0].map(function(item) { return item.title; })); // 构建表头行
|
// excelData.push(col[0].map(function(item) {
|
||||||
tableData.forEach(function(row, index) {
|
// return item.title;
|
||||||
var newRow = [];
|
// })); // 构建表头行
|
||||||
col[0].forEach(function(colItem) {
|
// tableData.forEach(function(row, index) {
|
||||||
if (colItem.type === 'numbers') {
|
// var newRow = [];
|
||||||
newRow.push(index + 1); // 序号从 1 开始
|
// col[0].forEach(function(colItem) {
|
||||||
} else {
|
// if (colItem.type === 'numbers') {
|
||||||
newRow.push(row[colItem.field]); // 添加对应字段的值
|
// newRow.push(index + 1); // 序号从 1 开始
|
||||||
}
|
// } else {
|
||||||
});
|
// newRow.push(row[colItem.field]); // 添加对应字段的值
|
||||||
excelData.push(newRow); // 将新行添加到 excelData
|
// }
|
||||||
});
|
// });
|
||||||
console.log(excelData); // 输出结果,检查是否正确
|
// excelData.push(newRow); // 将新行添加到 excelData
|
||||||
|
// });
|
||||||
|
// console.log(excelData); // 输出结果,检查是否正确
|
||||||
},
|
},
|
||||||
error: function(XMLHttpRequest, textStatus, e) {
|
error: function(XMLHttpRequest, textStatus, e) {
|
||||||
layer.msg('数据请求发生异常,请稍后重试', {
|
layer.msg('数据请求发生异常,请稍后重试', {
|
||||||
|
|
@ -172,6 +178,53 @@ function resetClick() {
|
||||||
|
|
||||||
//导出
|
//导出
|
||||||
function exportData() {
|
function exportData() {
|
||||||
layui.excel.exportExcel(excelData, '特勤考勤台账.xlsx', 'xlsx')
|
const XLSX = window.XLSX;
|
||||||
|
|
||||||
|
// 创建一个新的工作簿
|
||||||
|
var workbook = XLSX.utils.book_new();
|
||||||
|
// 创建一个新的工作表
|
||||||
|
var worksheet = XLSX.utils.aoa_to_sheet([
|
||||||
|
['特勤考勤台账'], // 标题行
|
||||||
|
cols.map(function(item) {
|
||||||
|
return item.title;
|
||||||
|
}), // 表头行
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 添加数据行
|
||||||
|
tableDatas.forEach(function(row, index) {
|
||||||
|
var newRow = [];
|
||||||
|
cols.forEach(function(colItem) {
|
||||||
|
if (colItem.type === 'numbers') {
|
||||||
|
newRow.push(index + 1); // 序号从 1 开始
|
||||||
|
} else {
|
||||||
|
newRow.push(row[colItem.field]); // 添加对应字段的值
|
||||||
|
}
|
||||||
|
});
|
||||||
|
XLSX.utils.sheet_add_aoa(worksheet, [newRow], {
|
||||||
|
origin: -1
|
||||||
|
}); // 添加数据行
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置合并单元格
|
||||||
|
worksheet['!merges'] = [{
|
||||||
|
s: {
|
||||||
|
r: 0,
|
||||||
|
c: 0,
|
||||||
|
},
|
||||||
|
e: {
|
||||||
|
r: 0,
|
||||||
|
c: cols.length - 1,
|
||||||
|
}
|
||||||
|
} // 合并 A1 到 E1 单元格
|
||||||
|
];
|
||||||
|
|
||||||
|
// 添加工作表到工作簿
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
|
||||||
|
|
||||||
|
// 导出 Excel 文件
|
||||||
|
XLSX.writeFile(workbook, '特勤考勤台账.xlsx');
|
||||||
|
|
||||||
|
// console.log(XLSX);
|
||||||
|
// layui.excel.exportExcel(excelData, '特勤考勤台账.xlsx', 'xlsx')
|
||||||
// table.exportFile(d.config.id, excelData, 'xlsx');
|
// table.exportFile(d.config.id, excelData, 'xlsx');
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
||||||
|
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue