//iframe自适应 $(window).on('resize', function() { var $content = $('.content'); // $content.height($(this).height() - 112); $content.height($(this).height() - 157); $("#center_Content").height($(this).height() - 184) $content.find('iframe').each(function() { $(this).height($content.height() - 54); }); }).resize(); function menu() { $.ajax({ url: restServerBaseURL + 'sys/menu/nav', // 跳转到 action type: 'post', cache: false, async:false, dataType: 'json', success: function(data) { if(data.code != 0) { return; } window.permissions = data.permissions; // 获得权限 window.appId = data.appId;//获取系统id var MenuHtml = ""; $("#sidebar-menu").html(MenuHtml); var router = new Router(); routerList(router, data.menuList); router.start(); $(".open-left").on("click", function(e) { e.stopPropagation(); openLeftBar(); }); $("#sidebar-menu a").on("click", menuItemClick); $("li.active").parent().parent().addClass('active'); $("li.active").parent().css('display','block').prev().addClass('subdrop').addClass('active'); }, error: function() { } }) } var menuItemClick = function(e) { if(!$("#wrapper").hasClass("enlarged")) { if(!$(this).hasClass("subdrop")) { //收缩所有菜单 $("ul", $(this).parents("ul:first")).slideUp(350); $("a", $(this).parents("ul:first")).removeClass("subdrop"); //展开当前菜单 $(this).next("ul").slideDown(350); if($(this).parent().hasClass("has_sub")) { //父节点未选中 if(!$(this).parent().hasClass("active")) { $(this).addClass("subdrop"); } } else { //子节点点击事件 $(".list-unstyled li").removeClass("active"); $("#sidebar-menu li.has_sub").removeClass("active"); $("#sidebar-menu li.has_sub a.waves-effect").removeClass("active"); $(this).parents("li").addClass("active").removeClass("subdrop"); $(this).removeClass("subdrop"); $(this).parents("li.has_sub").children("a:first").addClass("active"); } } else if($(this).hasClass("subdrop")) { //收缩当前菜单 $(this).removeClass("subdrop"); $(this).next("ul").slideUp(350); } } } var openLeftBar = function() { $("#wrapper").toggleClass("enlarged"); $("#wrapper").addClass("forced"); if($("#wrapper").hasClass("enlarged") && $("body").hasClass("fixed-left")) { $("body").removeClass("fixed-left").addClass("fixed-left-void"); } else if(!$("#wrapper").hasClass("enlarged") && $("body").hasClass("fixed-left-void")) { $("body").removeClass("fixed-left-void").addClass("fixed-left"); } if($("#wrapper").hasClass("enlarged")) { $(".left ul").removeAttr("style"); } else { $(".subdrop").siblings("ul:first").show(); } toggle_slimscroll(".slimscrollleft"); $("body").trigger("resize"); } //替换iframe的url function menuLeafChecked(obj) { //替换导航条文本 $("#shouyeTitle").text($(obj).text()); } //替换iframe的url function menuLeafClick(name){ //替换导航条文本 $("#shouyeTitle").text(name); } function getUser() { $.ajax({ type: "get", url: restServerBaseURL + "org/user/info", async: true, dataType: 'json', success: function(data) { var name = $(".active"); $("#shouyeTitle").text("欢迎页"); //用户头像 var firstImg = ""; if (data.code == 0 && data.user != null) { name.append(data.user.chinesename); if(data.user.photourl != null && data.user.photourl != ""){ var img = ""; $("#userImg").html(img); $("#userImg img").bind('error',function(){ $("#userImg").html(firstImg); }); }else{ $("#userImg").html(firstImg); } menu(); }else{ console.log("[异常]index.js,getUser:",data); if(data.code == 401){ //getToken() } $("#userImg").html(firstImg); } } }); } function updatePassword() { layer.open({ type: 2, skin: 'layui-layer-molv', title: "修改密码", shadeClose: true, area: ["550px", "270px"], content: 'modifypassword.html' }); //openHtmlLayerOfBtn("550px", "270px", "修改密码", "modifypassword", updatePasswordCallback); } function toLoginpage() { var homeUrl = location.origin + baseURL + "admin/index.html"; location.href = casServerUrlPrefix + "/login?service=" + homeUrl; } function logout() { localStorage.removeItem("token"); $.ajax({ type: "POST", url: restServerBaseURL + "sys/logout", dataType: "json", success: function(r) { //删除本地token var homeUrl = location.origin + baseURL + "admin/index.html"; //退出CAS,跳转到登录页面 ifm.location.href = casServerUrlPrefix + "/logout"; setTimeout(toLoginpage,1000); //跳转到登录页面 //location.href = restServerBaseURL + 'admin/login.html'; } }); } function routerList(router, menuList) { var main = baseURL + "admin/modules/sys/main.html" var navTitle = "欢迎页" for(var key in menuList) { var menu = menuList[key]; if(menu.type == 0) { routerList(router, menu.list); } else if(menu.type == 1) { router.add('#' + menu.url, function() { var url = window.location.hash; //替换iframe的url main = url.replace('#', ''); $("#ifm").attr("src", main); $("#menuShow").css("display","none"); }); } } } function getRandomColor(i) { if (i > 7) { i=i-(7*Math.floor(i/7)) } var colorList = ["#CA53B7", "#A2BF59", "#5D73B5", "#0F46C0", "#7FBCE4", "#1D4062", "#AA7A53", "#4AB4B5"] return colorList[i]; } function mainmenu() { $.ajax({ url: restServerBaseURL + 'sys/menu/nav', // 跳转到 action type: 'post', cache: true, dataType: 'json', success: function (data) { var html="
"; var menucount = 0; for (i = 0; i < data.menuList.length; i++) { //下级菜单 //判断一级目录下是否有显示的目录,没有则不显示该菜单模块 alert ykm 2018/12/26 与左侧菜单栏显示一致 var flag = false; var item = data.menuList[i]; if(item.list != null) { for(var s = 0; s < item.list.length; s++) { // if (item.list[s].perms != null && item.list[s].perms != "" && !hasPermission(item.list[s].perms)) { // continue; //没有权限不可见 // } if(item.list[s].perms != null && item.list[s].perms != "") { var perms = item.list[s].perms; var permsList = perms.split(","); for(var p=0;p 6 ? data.menuList[i].list[j].name.substring(0, 6) + "..." : data.menuList[i].list[j].name; var icon = data.menuList[i].list[j].icon != null ? data.menuList[i].list[j].icon : "fa fa-circle-o"; Children += "
  • " + "" + ' ' + name + "
  • "; } Children += ""; var color = getRandomColor(menucount); var style = ""; if (menucount % 2 == 1) { style += "margin-left:1.5%;"; } else { style += "margin-left:9.5%;"; } style += "margin-top:1.5%;"; html += ""; menucount ++; } } html+="
    "; $("#menuShow").html(html) }, error: function () { window.location.reload(); } }) } //页面初始化 $(function() { getUser(); $("#copyrightName").html(copyrightName); $("#title").text("运维监控 - " + systemTitle); }); function getActionUrl() { var search = window.location.hash; var shouyeTitle = ""; if(search != "") { shouyeTitle = search.substring(1,search.length); } return shouyeTitle; }