diff --git a/hxy-web/html/dataStatistics/specialPatrol/specialPatrolList.html b/hxy-web/html/dataStatistics/specialPatrol/specialPatrolList.html
index b641281..ef6ac9f 100644
--- a/hxy-web/html/dataStatistics/specialPatrol/specialPatrolList.html
+++ b/hxy-web/html/dataStatistics/specialPatrol/specialPatrolList.html
@@ -2,15 +2,19 @@
- 工作签证
-
+ 特勤考勤台账
+
+
-
+
+
+
-
+
+
@@ -61,29 +65,29 @@
+
\ No newline at end of file
diff --git a/hxy-web/js/dataStatistics/specialPatrol/specialPatrolList.js b/hxy-web/js/dataStatistics/specialPatrol/specialPatrolList.js
index 1297fb3..49985ef 100644
--- a/hxy-web/js/dataStatistics/specialPatrol/specialPatrolList.js
+++ b/hxy-web/js/dataStatistics/specialPatrol/specialPatrolList.js
@@ -1,156 +1,177 @@
-
+var currentDate = new Date();
+// 获取当前月份的第一天
+var firstDay = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
+// 获取下一个月的第一天
+var nextMonthFirstDay = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1);
+// 获取当前月份的天数 //本月多少天
+var daysInMonth = Math.floor((nextMonthFirstDay.getTime() - firstDay.getTime()) / (24 * 60 * 60 * 1000));
+// console.log(daysInMonth);
var pers = []
-var table,form,laydate
-layui.use(['form','layer','table','laydate'], function () {
- table = layui.table;
- form = layui.form;
- laydate = layui.laydate
+var table, form, laydate,excel;
+var d;
+var excelData=[];
+layui.use(['form', 'layer', 'table', 'laydate','excel'], function() {
+ excel = layui.excel;
+ table = layui.table;
+ form = layui.form;
+ laydate = layui.laydate;
//初始化日期选择框
laydate.render({
- elem: '#dataTime',
- type: 'month',
+ elem: '#makeMonth',
+ type: 'month',
+ value: (new Date()).toISOString().substr(0, 7), // 获取当前日期并转换为'yyyy-MM'格式
+ btns: ['now', 'confirm']
});
- // 触发submit提交 按钮点击或者表单被执行提交时触发
- form.on('submit(query)', function (data) {
- console.log("搜索")
- // 对表格进行重载。id 即 table表格的id
- table.reload('table', {
- // //设定异步数据接口的额外参数
- page:{curr : 1}
- ,where: data.field
- })
- return false; // 阻止表单跳转。如果需要表单跳转,去掉这段即可。
- });
- $("#reset").click(function(){
- console.log("重置")
- $('#search1').val('');
- $('#search2').val('');
- $('#search3').val('');
- let obj = {
- search1:'',
- search2:'',
- search3:''
- }
- // 对表格进行重载。id 即 table表格的id
- table.reload('table', {
- // //设定异步数据接口的额外参数
- page:{curr : 1}
- ,where: obj
- })
- })
-
- init();
+ init();
});
-/* var dataList = [
- {name: '3.1', value: ''}, {name: '3.2', value: ''}, {name: '3.3', value: ''}, {name: '3.4', value: ''}, {name: '3.5', value: ''}, {name: '3.6', value: ''},
- {name: '3.7', value: ''}, {name: '3.8', value: ''}, {name: '3.9', value: ''}, {name: '3.10', value: ''}, {name: '3.11', value: ''}, {name: '3.12', value: ''},
- {name: '3.13', value: ''}, {name: '3.14', value: ''}, {name: '3.15', value: ''}, {name: '3.16', value: ''}, {name: '3.17', value: ''}, {name: '3.18', value: ''},
- {name: '3.19', value: ''}, {name: '3.20', value: ''}, {name: '3.21', value: ''}, {name: '3.22', value: ''}, {name: '3.23', value: ''}, {name: '3.24', value: ''},
- {name: '3.25', value: ''}, {name: '3.26', value: ''}, {name: '3.27', value: ''}, {name: '3.28', value: ''}, {name: '3.29', value: ''}, {name: '3.30', value: ''},
- {name: '3.31', value: ''}
-] */
-// 静态数据
-var tableData = [
- {id: 1, comName: '2024-03', stationName: '±500kV永富直流线', lineName: '300', username: '21', totalDay: '256',
- '3.1': '', '3.2': '√', '3.3': '√', '3.4': '', '3.5': '√', '3.6': '', '3.7': '', '3.8': '', '3.9': '', '3.10': '', '3.11': '', '3.12': '', '3.13': '',
- '3.14': '', '3.15': '', '3.16': '', '3.17': '', '3.18': '', '3.19': '', '3.20': '', '3.21': '', '3.22': '', '3.23': '', '3.24': '', '3.25': '', '3.26': '',
- '3.27': '', '3.28': '', '3.29': '', '3.30': '', '3.31': ''},
- {id: 1, comName: '2024-03', stationName: '±500kV永富直流线', lineName: '300', username: '21', totalDay: '256',
- '3.1': '', '3.2': '√', '3.3': '√', '3.4': '', '3.5': '', '3.6': '', '3.7': '√', '3.8': '√', '3.9': '', '3.10': '', '3.11': '', '3.12': '', '3.13': '',
- '3.14': '', '3.15': '', '3.16': '', '3.17': '', '3.18': '', '3.19': '', '3.20': '', '3.21': '', '3.22': '', '3.23': '', '3.24': '', '3.25': '', '3.26': '',
- '3.27': '', '3.28': '', '3.29': '', '3.30': '', '3.31': ''},
- {id: 1, comName: '2024-03', stationName: '±500kV永富直流线', lineName: '300', username: '21', totalDay: '256',
- '3.1': '', '3.2': '√', '3.3': '√', '3.4': '', '3.5': '√', '3.6': '√', '3.7': '', '3.8': '', '3.9': '', '3.10': '', '3.11': '', '3.12': '', '3.13': '',
- '3.14': '', '3.15': '', '3.16': '', '3.17': '', '3.18': '', '3.19': '', '3.20': '', '3.21': '', '3.22': '', '3.23': '', '3.24': '', '3.25': '', '3.26': '',
- '3.27': '', '3.28': '', '3.29': '', '3.30': '', '3.31': ''},
- {id: 1, comName: '2024-03', stationName: '±500kV永富直流线', lineName: '300', username: '21', totalDay: '256',
- '3.1': '', '3.2': '√', '3.3': '√', '3.4': '', '3.5': '√', '3.6': '', '3.7': '', '3.8': '', '3.9': '', '3.10': '√', '3.11': '', '3.12': '', '3.13': '',
- '3.14': '', '3.15': '', '3.16': '', '3.17': '', '3.18': '', '3.19': '', '3.20': '', '3.21': '', '3.22': '', '3.23': '', '3.24': '', '3.25': '', '3.26': '',
- '3.27': '', '3.28': '', '3.29': '', '3.30': '', '3.31': ''},
- {id: 1, comName: '2024-03', stationName: '±500kV永富直流线', lineName: '300', username: '21', totalDay: '256',
- '3.1': '', '3.2': '√', '3.3': '√', '3.4': '', '3.5': '√', '3.6': '', '3.7': '', '3.8': '', '3.9': '√', '3.10': '', '3.11': '', '3.12': '', '3.13': '',
- '3.14': '', '3.15': '', '3.16': '', '3.17': '', '3.18': '', '3.19': '', '3.20': '', '3.21': '', '3.22': '', '3.23': '', '3.24': '', '3.25': '', '3.26': '',
- '3.27': '', '3.28': '', '3.29': '', '3.30': '', '3.31': ''},
-];
-var col = [
- [
- {
- title: '序号',
- field: 'zizeng',
- align: 'center',
- type: 'numbers',
- },
- {
- field:'comName',
- title: '所属分公司',
- align: 'center',
- width: '10%',
- },
- {
- field:'stationName',
- title: '所属运检站',
- align: 'center',
- width: '15%',
- },
- {
- field:'lineName',
- title: '管辖线路名称',
- align: 'center',
- width: '10%',
- },
- {
- field:'username',
- title: '姓名',
- align: 'center',
- width: '5%',
- },
- {
- field:'totalDay',
- title: '总计(天)',
- align: 'center',
- width: '10%',
- },
+
+function init() {
+ let userName = $('#userName').val();
+ let proName = $('#proName').val();
+ let yjName = $('#yjName').val();
+ let makeMonth = $('#makeMonth').val();
+
+ // 静态数据
+ var tableData = [];
+
+ //保存表头
+ var col = [
+ [{
+ title: '序号',
+ field: 'zizeng',
+ align: 'center',
+ type: 'numbers'
+ },
+ {
+ field: 'userName',
+ title: '姓 名',
+ align: 'center',
+ width: '80'
+ },
+ {
+ field: 'proName',
+ title: '管辖线路名称',
+ align: 'center',
+ width: '200'
+ },
+ {
+ field: 'yjName',
+ title: '所属运检站',
+ align: 'center',
+ width: '200'
+ },
+ {
+ field: 'special',
+ title: '总计(天)',
+ align: 'center',
+ width: '100'
+ },
+ ]
]
-];
-if(tableData != null && tableData!= ''){
- //生成表格列. 以属性个数进行循环,生成表头
- for (var i = 6; i < Object.keys(tableData[0]).length; i++) {
- var key = Object.keys(tableData[0])[i];
- var json = {
- field: key,
- title: key,
- align: 'center',
+
+ $.ajax({
+ type: 'POST',
+ url: PATH_URL + '/attendance/getSpecialPatrolList', // 请求地址
+ data: {
+ "userName": userName,
+ "proName": proName,
+ "yjName": yjName,
+ "makeMonth": makeMonth,
+ "fgsId": "26"
+ }, //获取提交的表单字段
+ success: function(data) {
+ for (var i = 0; i < data.length; i++) {
+ var json = {
+ 'userName': data[i].userName,
+ 'proName': data[i].proName,
+ 'yjName': data[i].yjName,
+ 'special': data[i].special,
+ 'makeMonth': data[i].makeMonth,
+ 'proId': data[i].proId
+ }
+ var spMakeList = data[i].spMakeList;
+ for (var j = 0; j < spMakeList.length; j++) {
+ json[`${ spMakeList[j].currDay }`] = spMakeList[j].isAtt;
+ }
+ tableData.push(json)
+ }
+ console.log('tableData', tableData)
+
+ if (data.length > 0) {
+ for (var i = 0; i < data[0].spMakeList.length; i++) {
+ var spMake = data[0].spMakeList[i];
+ var json = {
+ field: `${ spMake.currDay }`,
+ title: `${ spMake.currDay }`,
+ align: 'center'
+ }
+ col[0].push(json);
+ }
+ }
+ d = table.render({
+ id: 'layui_table',
+ elem: '#table',
+ page: true, //开启分页
+ skin: 'line', // 表格样式
+ cols: col,
+ data: tableData,
+ title: '特勤考勤台账'//导出数据excel的表名称
+ });
+ 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); // 输出结果,检查是否正确
+ },
+ error: function(XMLHttpRequest, textStatus, e) {
+ layer.msg('数据请求发生异常,请稍后重试', {
+ icon: 16,
+ scrollbar: false
+ });
+ top.layer.close(addLoadingMsg); //再执行关闭
}
- col[0].push(json);
+ });
+}
+
+//查询
+function queryClick() {
+ init();
+}
+//重置
+function resetClick() {
+ $('#userName').val("");
+ $('#proName').val("");
+ $('#yjName').val("");
+
+ var today = new Date();
+ var year = today.getFullYear();
+ var month = today.getMonth() + 1;
+ if (month < 10) {
+ month = '0' + month;
}
+ var currentMonth = year + '-' + month;
+ $('#makeMonth').val(currentMonth);
+ init();
}
-
-/**
- * 初始化数据
- */
-function init(){
- // 渲染表格
- table.render({
- elem: '#table',
- // url: "/sys/achievement",
- page: true,
- // skin: 'line', // 表格样式
- border: 1,
- cols: col,
- data: tableData
- });
-
-}
-
-
-
//导出
-function exportData(){
- // let search1 = $('#search1').val();
- // let search2 = $('#search2').val();
- window.location.href = oiPlanUrl + "/monthlyPlanSubmission/export?token=" + token;
+function exportData() {
+ layui.excel.exportExcel(excelData, '特勤考勤台账.xlsx', 'xlsx')
+ // table.exportFile(d.config.id, excelData, 'xlsx');
}
\ No newline at end of file