巡视计划

This commit is contained in:
lSun 2024-08-21 13:21:52 +08:00
parent 4c3a9a28d6
commit abc560cbaa
6 changed files with 130 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

View File

@ -8,9 +8,13 @@ var daysInMonth = Math.floor((nextMonthFirstDay.getTime() - firstDay.getTime())
// console.log(daysInMonth);
var pers = []
var table, form, laydate, excel;
var d;
var excelData = [];
var cols = [],
tableDatas = [];
layui.use(['form', 'layer', 'table', 'laydate', 'excel'], function() {
excel = layui.excel;
table = layui.table;
@ -122,22 +126,24 @@ function init() {
});
console.log("col", col)
console.log("tableData", tableData)
excelData.push(['特勤考勤台账']);
// 使用 cols 和 data 构造一个包含表头的新数组
excelData.push(col[0].map(function(item) { return item.title; })); // 构建表头行
tableData.forEach(function(row, index) {
var newRow = [];
col[0].forEach(function(colItem) {
if (colItem.type === 'numbers') {
newRow.push(index + 1); // 序号从 1 开始
} else {
newRow.push(row[colItem.field]); // 添加对应字段的值
}
});
excelData.push(newRow); // 将新行添加到 excelData
});
console.log(excelData); // 输出结果,检查是否正确
cols = col[0]
tableDatas = tableData;
// // 使用 cols 和 data 构造一个包含表头的新数组
// excelData.push(col[0].map(function(item) {
// return item.title;
// })); // 构建表头行
// tableData.forEach(function(row, index) {
// var newRow = [];
// col[0].forEach(function(colItem) {
// if (colItem.type === 'numbers') {
// newRow.push(index + 1); // 序号从 1 开始
// } else {
// newRow.push(row[colItem.field]); // 添加对应字段的值
// }
// });
// excelData.push(newRow); // 将新行添加到 excelData
// });
// console.log(excelData); // 输出结果,检查是否正确
},
error: function(XMLHttpRequest, textStatus, e) {
layer.msg('数据请求发生异常,请稍后重试', {
@ -172,6 +178,53 @@ function resetClick() {
//导出
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');
}

File diff suppressed because one or more lines are too long

View File

@ -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