yn_hxy_web/hxy-web/js/wireManager/attendance/attendance.js

329 lines
8.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,element;
var tabIndex = 0;
var tableType = 'layui_table1';
var times = getCurrentDateTimeArr();
layui.use(['form','layer','table','laydate','element'], function () {
table = layui.table;
form = layui.form;
laydate = layui.laydate;
element = layui.element;
// 渲染时间选择器
laydate.render({
elem: '#makeMonth',
type: 'month',
format: 'yyyy-MM',
fullPanel: true,
value: times[0] + "-" + times[1]
});
//监听Tab切换以改变地址hash值
element.on('tab(chosenTab)', function(data){
// console.log(data)
tabIndex = data.index;
//切换重置
// $('#search1').val('');
// $('#search2').val('');
// $('#search3').val('');
// $('#month').val('');
if(tabIndex==0){
tableType = 'layui_table1';
initTable1();
}else if(tabIndex==1){
tableType = 'layui_table2';
initTable2();
}else if(tabIndex==2){
tableType = 'layui_table3';
initTable3();
}else{
tableType = 'layui_table1';
initTable1();
}
});
table.on(`tool(${tableType})`, function (obj) {
switch (obj.event) {
case 'detail':
console.log('详情',obj)
checkView(obj)
break;
}
});
initTable1();
});
//查询
function queryClick(){
let userName = $('#userName').val();
let proName = $('#proName').val();
let yjName = $('#yjName').val();
let startMakeMonth = $('#makeMonth').val();
let endMakeMonth = $('#makeMonth').val();
table.reload(tableType, {
where: {
userName: userName,
proName: proName,
yjName: yjName,
startMakeMonth: startMakeMonth,
endMakeMonth: endMakeMonth
}
})
}
//重置
function resetClick(){
$('#userName').val("");
$('#proName').val("");
$('#yjName').val("");
$('#makeMonth').val("");
table.reload(tableType, {
where: {
userName: "",
proName: "",
yjName: "",
startMakeMonth: '',
endMakeMonth: "",
}
})
}
/**
* 初始化数据 全部
*/
function initTable1(){
console.log('全部')
table.render({
id: 'layui_table1',
elem: '#table',
url: PATH_URL + '/attendance/getAllInspectionList',
where: {
startMakeMonth: $('#makeMonth').val(),
endMakeMonth: $('#makeMonth').val()
},
page: true, //开启分页
method:'post',
skin: 'line', // 表格样式
cols: [[
// {
// type: 'checkbox'
// },
{
title: '序号',
field: 'zizeng',
align: 'center',
type: 'numbers'
},
{field:'userName', title: '姓名',align: 'center',},
{field:'idNumber', title: '身份证号',align: 'center',},
{field:'tel', title: '联系电话',align: 'center',},
{field:'makeMonth', title: '月份',align: 'center',},
{field:'allMake', title: '正常巡视(基*次)',align: 'center',},
{field:'special', title: '特巡(天*人)',align: 'center',width:170},
{field:'proName', title: '管辖线路名称',align: 'center',width:170},
{field:'yjName', title: '所属运检站',align: 'center', },
{
title: '操作',
toolbar: '#opeator-bar',
align: 'center',
width: 200
}
]],
done: function(res,curr,count){
//checkPermission();
}
});
}
/**
* 初始化数据 正常巡视统计
*/
function initTable2(){
console.log('正常巡视统计')
// 渲染表格
table.render({
id: 'layui_table2',
elem: '#table',
url: PATH_URL + '/lineProject/getLineProjectList',
where: {
},
page: true, //开启分页
method:'post',
skin: 'line', // 表格样式
cols: [[
// {
// type: 'checkbox'
// },
{
title: '序号',
field: 'zizeng',
align: 'center',
type: 'numbers'
},
{field:'fgsName', title: '分公司',align: 'center',},
{field:'yjName', title: '运检站',align: 'center',},
{field:'proName', title: '线路工程名称',align: 'center',},
{field:'volLevel', title: '电压等级',align: 'center',},
{
title: '单/双回路',
field: '',
align: 'center',
templet: function(d){
let isTwo = d.isTwo;
let html;
if(isTwo == '0' || isTwo == 0){
html = '<span>单回路</span>'
}else{
html = '<span>双回路</span>'
}
// 返回模板内容
return html;
}
},
{field:'powerNum', title: '杆塔数量',align: 'center',},
{field:'lineNum', title: '群众护线员数量',align: 'center',width:170},
{field:'inLinePowerNum', title: '已绑定护线员杆塔数量',align: 'center',width:170},
{field:'unLinePowerNum', title: '未绑定护线员杆塔数量',align: 'center', },
{
title: '操作',
toolbar: '#opeator-bar',
align: 'center',
width: 200
}
]],
done: function(res,curr,count){
//checkPermission();
}
});
}
/**
* 初始化数据 特巡统计
*/
function initTable3(){
console.log('特巡统计')
table.render({
id: 'layui_table3',
elem: '#table',
url: PATH_URL + '/lineProject/getLineProjectList',
where: {
},
page: true, //开启分页
method:'post',
skin: 'line', // 表格样式
cols: [[
// {
// type: 'checkbox'
// },
{
title: '序号',
field: 'zizeng',
align: 'center',
type: 'numbers'
},
{field:'fgsName', title: '分公司',align: 'center',},
{field:'yjName', title: '运检站',align: 'center',},
{field:'proName', title: '线路工程名称',align: 'center',},
{field:'volLevel', title: '电压等级',align: 'center',},
{
title: '单/双回路',
field: '',
align: 'center',
templet: function(d){
let isTwo = d.isTwo;
let html;
if(isTwo == '0' || isTwo == 0){
html = '<span>单回路</span>'
}else{
html = '<span>双回路</span>'
}
// 返回模板内容
return html;
}
},
{field:'powerNum', title: '杆塔数量',align: 'center',},
{field:'lineNum', title: '群众护线员数量',align: 'center',width:170},
{field:'inLinePowerNum', title: '已绑定护线员杆塔数量',align: 'center',width:170},
{field:'unLinePowerNum', title: '未绑定护线员杆塔数量',align: 'center', },
{
title: '操作',
toolbar: '#opeator-bar',
align: 'center',
width: 200
}
]],
done: function(res,curr,count){
//checkPermission();
}
});
}
/**
* 详情
* */
function checkView(obj) {
let height = '98%';
let width = '95%';
$.ajax({
type: 'POST',
url: PATH_URL + '/attendance/getInspectionParticular',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({
makeMonth: $("#makeMonth").val(),
proId: obj.data.proId
}),
success: function (data) {
console.log("dataaaaaa:", data)
var index = layer.open({
title: ['详情'],
type: 2,
content: 'attendanceDetail.html',
area: [width, height],
maxmin: false,
success: function (layero, index) {
// console.log(data);
var myIframe = window[layero.find('iframe')[0]['name']];
var times = obj.data.makeMonth.split("-")
myIframe.init(times[0],times[1]);
myIframe.setData(data); //aaa()为子页面的方法
},
});
}
})
}
//导出
function exportData() {
// let search1 = $('#search1').val();
// let search2 = $('#search2').val();
window.location.href = oiPlanUrl + "/monthlyPlanSubmission/export?token=" + token;
}