var element, form; var indexUrl = ""; let inde1url = '../compreDisplay/compreDisplay.html'; let inde2url = '../compreDisplay/cityHome.html'; let inde3url = '../compreDisplay/dutyHome.html'; layui.use(['layer', 'form', 'element'], function () { var $ = layui.jquery; element = layui.element; form = layui.form; // 审计日志定时查询 /*capacityTips() setInterval( async function () { capacityTips() }, 1*60*60*1000); */ initMenu();//初始化菜单 element.render();//渲染 form.on('submit(formData)', function (data) { submitData(data); }); form.on('submit(formDatas)', function (data) { bgData(data); }); // 默认首页 // $('#iframeMain').attr('src', '../compreDisplay/compreDisplay.html'); var user = JSON.parse(decrypt(us)); getWzXx(user.orgId); window.setTimeout(function () { getWzXx(user.orgId); }, 6000 * 3); if (user.isSup != 3) { $("#dtaxt").css("display", "none"); } if (user.isSup == 3) { getIsBg(user.orgId); } var org = user.unitName; if (typeof (org) == "undefined") { org = "建设分公司"; } $("#use-org").text(user.roleName + "/" + org); $("#dtaxt").click(function (e) { $("#indexIframe").show(); $("#layui-tab").hide(); var url = "../dutyTask/violationStatistics.html"; $('#indexIframe').attr('src', url); }) //点击事件 $("dd>a,li>a").click(function (e) { if ($(this).next('dl').length === 0) { e.preventDefault(); $('ul li').each(function () { if ($(this).hasClass('layui-that') || $(this).hasClass('layui-this')) { $(this).removeClass('layui-that') $(this).removeClass('layui-this') } }) $(this).parents('.layui-nav-child').removeClass('layui-show'); $(this).parents('.layui-nav-item').addClass('layui-that'); console.log($(this).attr("href")); let indexUrls = $(this).attr("href"); if (indexUrls == inde1url || indexUrls == inde2url || indexUrls == inde3url) { if (indexUrls == inde2url || indexUrls == inde3url) {//地市+值长 $('#html').css("background", 'url("../../img/cityHome/city_home_back.png") no-repeat 0 0 / 100% 100% transparent'); } else if (indexUrls == inde1url) { $('#html').css("background", 'url("../../img/back.png") no-repeat 0 0 / 100% 100% transparent'); } $("#ifr-box ").css("background-image", ""); $('#indexIframe').attr('src', indexUrls); $("#indexIframe").show(); $("#layui-tab").hide(); } else { if ($(".layui-tab-title li[lay-id='" + $(this).attr('idx') + "']").length > 0) { $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#indexIframe").hide(); $("#layui-tab").show(); element.tabChange('menu-tab', $(this).attr('idx')); } else { $("#indexIframe").hide(); element.tabAdd('menu-tab', { title: $(this).text(), content: "" , id: $(this).attr('idx') }) $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#layui-tab").show(); element.tabChange('menu-tab', $(this).attr('idx')); } var tabr = $(".layui-tab-title").find("li"); let close = tabr.eq(tabr.length - 1).children("i"); close.on('click', function (e) { //绑定关闭事件 }) } //关闭事件监听 $(".layui-tab-close").click(function (e) { var tabr = $(".layui-tab-title").find("li"); var length = tabr.length; if (length == 0) {//全部关闭了则返回首页 $("#menu-childer").empty(); $("#indexIframe").show(); $("#menu-content").empty(); $("#layui-tab").hide(); $("#ifr-box ").css("background-image", ""); let nowsrc = $('#indexIframe').attr("src"); let imea = "0"; if (nowsrc == inde1url) {//综合暂时 imea = "0"; } else if (nowsrc == inde2url) {//地市首页 imea = "1"; } else if (nowsrc == inde3url) {//地市首页 imea = "2"; } $(".layui-nav-item").each(function () { $(this).removeClass('layui-that'); $(this).removeClass('layui-this'); console.log($(this).text()); console.log($(this).attr("idx")) if ($(this).text() == '综合展示' && imea == 0) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } else if ($(this).text().indexOf('首页') != '-1' && imea == 1) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } else if ($(this).text().indexOf('值长') != '-1' && imea == 2) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } }) } }) } }); //$("#layui-tab-title").niceScroll({cursorborder:"",cursorcolor:"#c0c4cc",boxzoom:true}); }) /** * 初始化菜单 */ function initMenu() { var user = JSON.parse(decrypt(us)); var menus = user.menus; if (menus.length > 0 && menus != '[]') { var num = 0; var allMenus = ""; var userMenus = ""; var ul = '" $("#menu-title").empty(); $("#menu-title").append(ul + allMenus + dul); $("#menu-user").empty(); $("#menu-user").append(userMenus); } } /*日期动态展示*/ showTime(); setInterval("showTime()", 1000);//间隔多少毫秒执行一次 function showTime() { let dateTime = new Date(); let year = dateTime.getFullYear(); //获取年份 let month = dateTime.getMonth() + 1; //获取月份 month = month < 10 ? "0" + month : month; //月份小于10则前面加个"0" let date = dateTime.getDate(); //获取日 date = date < 10 ? "0" + date : date; let hour = dateTime.getHours(); //获取小时 hour = hour < 10 ? "0" + hour : hour; let minute = dateTime.getMinutes(); //获取分钟 minute = minute < 10 ? "0" + minute : minute; let second = dateTime.getSeconds(); //获取秒 second = second < 10 ? "0" + second : second; let day = dateTime.getDay() //年月日时分秒赋值给dateTime dateTime = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; $('#currentTime').html(dateTime); } /** * 退出登录 * 记录日志需要调用后端 */ /*function logout() { localStorage.setItem("tokens", ""); localStorage.setItem("us", ""); $.ajax({ url: dataUrl + 'auth/loginOut', type: 'post', beforeSend:function(xhr){ xhr.setRequestHeader("Authorization",token) }, success: function (res) { window.location.href = "../../../login.html"; } }); }*/ //url function gotofx() { window.open(jj_jc_url); } function getIsBg(orgId) { console.log("orgId==" + orgId) $.ajax({ url: dataUrl + 'proteam/pot/home/getIsBg?token=' + token, headers: { "encrypt": sm3(JSON.stringify({ orgId: orgId })) }, data: { orgId: orgId, }, type: 'post', async: true, success: function (result) { console.log(result); if (result.data < 1) {//为报岗则进行报岗 openBg(); } }, }); } function getWzXx(orgId) { $.ajax({ url: dataUrl + 'proteam/pot/home/getWzXx?token=' + token, headers: { "encrypt": sm3(JSON.stringify({ orgId: orgId })) }, data: { orgId: orgId, }, type: 'post', async: true, success: function (result) { if (result.data > 0) { var text = "您有" + result.data + "条违章信息,请及时处理!"; $("#dtaxt").text(text); } else { $("#dtaxt").empty(); } }, }); } function notice() { if ($(".layui-tab-title li[lay-id='99999999999999']").length > 0) { $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#indexIframe").hide(); $("#layui-tab").show(); element.tabChange('menu-tab', '99999999999999'); } else { $("#indexIframe").hide(); element.tabAdd('menu-tab', { title: '消息通知', content: "" , id: '99999999999999' }) $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#layui-tab").show(); element.tabChange('menu-tab', '99999999999999'); //关闭事件监听 $(".layui-tab-close").click(function (e) { let tabr = $(".layui-tab-title").find("li"); let length = tabr.length; if (length === 0) {//全部关闭了则返回首页 $("#menu-childer").empty(); $("#indexIframe").show(); $("#menu-content").empty(); $("#layui-tab").hide(); $("#ifr-box ").css("background-image", ""); } }) } } function openNewTab(url, id, title) { if ($(".layui-tab-title li[lay-id='" + id + "']").length > 0) { $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#indexIframe").hide(); $("#layui-tab").show(); element.tabChange('menu-tab', id); } else { $("#indexIframe").hide(); element.tabAdd('menu-tab', { title: title, content: "" , id: id }) $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#layui-tab").show(); element.tabChange('menu-tab', id); } //关闭事件监听 $(".layui-tab-close").click(function (e) { var tabr = $(".layui-tab-title").find("li"); var length = tabr.length; if (length == 0) {//全部关闭了则返回首页 $("#menu-childer").empty(); $("#indexIframe").show(); $("#menu-content").empty(); $("#layui-tab").hide(); $("#ifr-box ").css("background-image", ""); let nowsrc = $('#indexIframe').attr("src"); let imea = "0"; if (nowsrc == inde1url) {//综合暂时 imea = "0"; } else if (nowsrc == inde2url) {//地市首页 imea = "1"; } else if (nowsrc == inde3url) {//地市首页 imea = "2"; } $(".layui-nav-item").each(function () { $(this).removeClass('layui-that'); $(this).removeClass('layui-this'); console.log($(this).text()); console.log($(this).attr("idx")) if ($(this).text() == '综合展示' && imea == 0) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } else if ($(this).text().indexOf('首页') != '-1' && imea == 1) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } else if ($(this).text().indexOf('值长') != '-1' && imea == 2) { $(this).addClass('layui-that'); $(this).addClass('layui-this'); } }) } }) } function closePage(){ element.tabDelete('menu-tab', '160000'); element.tabDelete('menu-tab', '190000'); } function test() { $("#indexIframe").hide(); element.tabAdd('menu-tab', { title: '消息通知', content: "" , id: '99999999999999' }) $("#ifr-box ").css("background-image", "url('../../img/tableback.jpg')"); $("#layui-tab").show(); element.tabChange('menu-tab', '99999999999999'); //关闭事件监听 $(".layui-tab-close").click(function (e) { let tabr = $(".layui-tab-title").find("li"); let length = tabr.length; if (length === 0) {//全部关闭了则返回首页 $("#menu-childer").empty(); $("#indexIframe").show(); $("#menu-content").empty(); $("#layui-tab").hide(); $("#ifr-box ").css("background-image", ""); } }) }