let layer, table, form, laydate; const bidCode = parent.$('#bidPro').val(); layui.use(['layer', 'table', 'form', 'laydate'], function () { layer = layui.layer; table = layui.table; form = layui.form; laydate = layui.laydate; // 响应成功后的拦截器 $.ajaxSetup({ beforeSend: function(xhr, options) { var originalSuccess = options.success options.success = function(data, textStatus, jqXhr) { data = modifyResponseData(data); // success(data,textStatus, jqXhr); originalSuccess.apply(this, arguments) } } }) //时间范围设置 laydate.render({ elem: '#date1', range: true, type: 'date', range: true, format: 'yyyy-MM-dd', max: Date.parse(new Date()), }); // $('#date1').val(getNowTime() + " - " + getNowTime()) //时间范围设置 laydate.render({ elem: '#date2', range: true, type: 'date', range: true, format: 'yyyy-MM-dd', max: Date.parse(new Date()), }); // $('#date2').val(getNowTime() + " - " + getNowTime()) //今日、当月车辆出入场统计 getVehicleStatistics(); // //今日、当月车辆出入场统计图片 getVehicleStatisticsPhoto("1", "1"); // //今日、当月车辆出入场统计列表 getVehicleStatisticsList(bidCode); // //今日、当月人员出入场统计 getPerStatistics(); // //今日、当月人员出入场统计图片 getPerStatisticsPhoto("1", "1"); // //今日、当月人员出入场统计列表 getPerStatisticsList(bidCode); }); function getVehicleStatistics() { let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/getVehicleStatistics?params=" + montageParam; // url ajaxRequestGet(url, "GET", true, function () { }, function (result) { if (result.code === 200) { if (result.data && result.data.length > 0) { //今日、当月车辆出入场统计 getStatistics(result.data) } else { //今日、当月车辆出入场统计 getStatistics("") } } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }); } }, function (xhr, status, error) { error(xhr, status, error) }, aqEnnable); } function getStatistics(data) { if (data != "") { var jtrNum = handleData(data[0].jtrNum); var jrcNum = handleData(data[0].jrcNum); var dyrNum = handleData2(data[0].dyrNum); var dycNum = handleData2(data[0].dycNum); } else { var jtrNum = "000"; var jrcNum = "000"; var dyrNum = "0000"; var dycNum = "0000"; } const jtrNums = jtrNum.split("").map(Number); document.getElementById("oner").textContent = jtrNums[0]; document.getElementById("twor").textContent = jtrNums[1]; document.getElementById("threer").textContent = jtrNums[2]; const jrcNums = jrcNum.split("").map(Number); document.getElementById("onec").textContent = jrcNums[0]; document.getElementById("twoc").textContent = jrcNums[1]; document.getElementById("threec").textContent = jrcNums[2]; const dyrNums = dyrNum.split("").map(Number); document.getElementById("onesr").textContent = dyrNums[0]; document.getElementById("twosr").textContent = dyrNums[1]; document.getElementById("threesr").textContent = dyrNums[2]; document.getElementById("foursr").textContent = dyrNums[3]; const dycNums = dycNum.split("").map(Number); document.getElementById("onesc").textContent = dycNums[0]; document.getElementById("twosc").textContent = dycNums[1]; document.getElementById("threesc").textContent = dycNums[2]; document.getElementById("foursc").textContent = dycNums[3]; // var s = "../../img/video/voi_photo4.png"; // var htmls = ''; // $('#photo').empty().append(htmls); } // 数据处理 function handleData(value) { if (parseInt(value) > 0 && parseInt(value) < 10) { return '00' + value; } else if (parseInt(value) >= 10 && parseInt(value) < 100) { return '0' + value; } else if (parseInt(value) >= 100 && parseInt(value) < 1000) { return value; } else { return '000'; } } // 数据处理2 function handleData2(value) { if (parseInt(value) > 0 && parseInt(value) < 10) { return '000' + value; } else if (parseInt(value) >= 10 && parseInt(value) < 100) { return '00' + value; } else if (parseInt(value) >= 100 && parseInt(value) < 1000) { return '0' + value; } else if (parseInt(value) >= 1000 && parseInt(value) < 10000) { return value; } else { return '0000'; } } function getVehicleStatisticsPhoto(accessType, timeType) { let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId + '&accessType=' + accessType + '&timeType=' + timeType; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/getVehicleStatisticsPhoto?params=" + montageParam; // url ajaxRequestGet(url, "GET", true, function () { }, function (result) { let html = ''; if (result.code === 200) { if (result.data && result.data.length > 0) { var s = "https://unpkg.com/outeres/demo/carousel/720x360-1.jpg"; var a = "sss"; $.each(result.data, function (index, item) { html += '
'; html += ''; html += '' + a + ''; html += '
'; }) } else { html += '
今日无告警
' // html += '
'; // html += ''; // html += '告警1'; // html += '
'; // // html += '
'; // html += ''; // html += '告警2'; // html += '
'; // // html += '
'; // html += ''; // html += '告警3'; // html += '
'; // // html += '
'; // html += ''; // html += '告警4'; // html += '
'; } } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }); } $('#abnormalAlarm').empty().append(html); }, function (xhr, status, error) { errorFn(xhr, status, error) }, aqEnnable); } function getVehicleStatisticsList(bidCode) { const url = commonUrl + "screen/largeScreen/accessMge/getVehicleStatisticsList"; table.render({ elem: '#demo1', url: url, skin: 'line', page: true, height: 'full-560', headers: { decrypt: "decrypt", "Authorization": token }, where: { bidCode: bidCode, proName: $('#proName1').val(), carNum: $('#carNum1').val(), date: $('#date1').val() }, cols: [[ { type: 'numbers', title: '序号' }, // 添加序号列 { field: 'proName', title: '工程名称', align: 'center', width: '20%' }, { field: 'carNum', title: '车牌号', align: 'center', width: '10%' }, { field: 'userName', title: '司机', align: 'center', width: '10%' }, { field: 'phone', title: '司机电话', align: 'center', width: '20%' }, { field: 'accessType', title: '状态', align: 'center', width: '10%' }, { field: 'accesssTime', title: '时间', align: 'center', width: '30%' } ]], initComplete: function () { // 在表格渲染完成后,重新渲染序号列 var that = this.elem.next(); var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table'); tool.find("tr").each(function (index, item) { $(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1); }); }, done: function (res, curr, count, origin) { console.log(res); } }) } function getPerStatistics() { let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/getPerStatistics?params=" + montageParam; // url ajaxRequestGet(url, "GET", true, function () { }, function (result) { if (result.code === 200) { if (result.data && result.data.length > 0) { getStatisticsPer(result.data) } else { getStatisticsPer("") } } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }); } }, function (xhr, status, error) { errorFn(xhr, status, error) setData(null); }, aqEnnable); } function getStatisticsPer(data) { let jtrNum = null, jrcNum = null, dyrNum = null, dycNum = null; if (data != "") { jtrNum = handleData(data[0].jtrNum); jrcNum = handleData(data[0].jrcNum); dyrNum = handleData2(data[0].dyrNum); dycNum = handleData2(data[0].dycNum); } else { jtrNum = "000"; jrcNum = "000"; dyrNum = "0000"; dycNum = "0000"; } const jtrNums = jtrNum.split("").map(Number); document.getElementById("onerPer").textContent = jtrNums[0]; document.getElementById("tworPer").textContent = jtrNums[1]; document.getElementById("threerPer").textContent = jtrNums[2]; const jrcNums = jrcNum.split("").map(Number); document.getElementById("onecPer").textContent = jrcNums[0]; document.getElementById("twocPer").textContent = jrcNums[1]; document.getElementById("threecPer").textContent = jrcNums[2]; const dyrNums = dyrNum.split("").map(Number); document.getElementById("onesrPer").textContent = dyrNums[0]; document.getElementById("twosrPer").textContent = dyrNums[1]; document.getElementById("threesrPer").textContent = dyrNums[2]; document.getElementById("foursrPer").textContent = dyrNums[3]; const dycNums = dycNum.split("").map(Number); document.getElementById("onescPer").textContent = dycNums[0]; document.getElementById("twoscPer").textContent = dycNums[1]; document.getElementById("threescPer").textContent = dycNums[2]; document.getElementById("fourscPer").textContent = dycNums[3]; // var s = "../../img/video/voi_photo4.png"; // var htmls = ''; // $('#photos').empty().append(htmls); } function getPerStatisticsPhoto(accessType, timeType) { let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId + '&accessType=' + accessType + '&timeType=' + timeType; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/getPerStatisticsPhoto?params=" + montageParam; // url ajaxRequestGet(url, "GET", true, function () { }, function (result) { let html = ''; if (result.code === 200) { if (result.data && result.data.length > 0) { var s = "https://unpkg.com/outeres/demo/carousel/720x360-1.jpg"; var a = "sss"; $.each(result.data, function (index, item) { html += '
'; html += ''; html += '' + a + ''; html += '
'; }) } else { html += '
暂无告警
' // html += '
'; // html += ''; // html += '告警1'; // html += '
'; // // html += '
'; // html += ''; // html += '告警2'; // html += '
'; // // html += '
'; // html += ''; // html += '告警3'; // html += '
'; // // html += '
'; // html += ''; // html += '告警4'; // html += '
'; } } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }); } $('#abnormalAlarms').empty().append(html); }, function (xhr, status, error) { error(xhr, status, error) }, aqEnnable); } function getPerStatisticsList(bidCode) { const url = commonUrl + "screen/largeScreen/accessMge/getPerStatisticsList"; table.render({ elem: '#demo2', url: url, skin: 'line', page: true, height: 'full-560', headers: { decrypt: "decrypt", "Authorization": token }, where: { bidCode: bidCode, proName: $('#proName2').val(), userName: $('#userName').val(), date: $('#date2').val() }, cols: [[ { type: 'numbers', title: '序号', width: '10%' }, // 添加序号列 { field: 'proName', title: '工程名称', align: 'center', width: '20%' }, { field: 'userName', title: '姓名', align: 'center', width: '10%' }, { field: 'userPhone', title: '电话', align: 'center', width: '20%' }, { field: 'accessType', title: '状态', align: 'center', width: '10%' }, { field: 'accesssTime', title: '时间', align: 'center', width: '30%' } ]], initComplete: function () { // 在表格渲染完成后,重新渲染序号列 var that = this.elem.next(); var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table'); tool.find("tr").each(function (index, item) { $(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1); }); }, done: function (res, curr, count, origin) { console.log(res); } }) } function getQueryList(type) { if (type == 1) { getVehicleStatisticsList(bidCode); } else { getPerStatisticsList(bidCode); } } function exportVehicleData() { let proName = $('#proName1').val(); let carNum = $('#carNum1').val(); let date = $('#date1').val(); let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId + '&proName=' + proName + '&carNum=' + carNum + '&date=' + date; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/exportVehicleData?params=" + montageParam; // url ajaxRequestGetExport(url, "GET", true, function () { }, function (blob, status, xhr) { // 创建一个 Blob 对象 var url = window.URL.createObjectURL(blob); // 创建一个隐藏的 标签 var link = document.createElement('a'); link.href = url; link.download = '车辆出入统计.xlsx'; // 设置下载文件的名称,假设是 Excel 文件 // 将 标签添加到文档中 document.body.appendChild(link); // 触发 标签的 click 事件来下载文件 link.click(); // 释放 URL 对象 window.URL.revokeObjectURL(url); // 移除 标签 document.body.removeChild(link); }, function (xhr, status, error) { errorFn(xhr, status, error) }, aqEnnable); } function exportPerData() { let proName = $('#proName2').val(); let userName = $('#userName').val(); let date = $('#date2').val(); let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId + '&proName=' + proName + '&userName=' + userName + '&date=' + date; let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData); const url = commonUrl + "screen/largeScreen/accessMge/exportPerData?params=" + montageParam; // url ajaxRequestGetExport(url, "GET", true, function () { }, function (blob, status, xhr) { // 创建一个 Blob 对象 var url = window.URL.createObjectURL(blob); // 创建一个隐藏的 标签 var link = document.createElement('a'); link.href = url; link.download = '人员出入统计.xlsx'; // 设置下载文件的名称,假设是 Excel 文件 // 将 标签添加到文档中 document.body.appendChild(link); // 触发 标签的 click 事件来下载文件 link.click(); // 释放 URL 对象 window.URL.revokeObjectURL(url); // 移除 标签 document.body.removeChild(link); }, function (xhr, status, error) { errorFn(xhr, status, error) }, aqEnnable); }