123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- // 监听浏览器窗口大小的改变,样式进行相应的调整
- var wid = window.screen.width-50;
- $(window).resize(function() {
- var wwww = $(window).width();
- if(wwww <= wid){
- $("html").css({"min-width":wid+"px","height":"100%","overflow":"auto","overflow-x":""});
- }else{
- $("html").css({"width":"100%","height":"100%","overflow":"scroll","overflow-x":"hidden"});
- }
- wwww = null;
- });
- function showSubMenu(){
- var $menu = $(".yj_menu_hover");
- // 鼠标悬停显示下拉菜单
- $($menu).parent().on("mouseenter",function(){
- $(this).find(".yj");
- $(this).find(".yj_menu_hover").css("background-color","#0f4a8b");
- $(this).find(".hover_cont").show();
- });
- $($menu).parent().on("mouseleave",function(){
- $(this).find(".yj_menu_hover").css("background-color","");
- $(this).find(".hover_cont").hide();
-
- });
- $(".hover_cont .nav_li_r a").on("mouseover",function(){
- $(this).css({"background-color":"#ddd"});
- });
- $(".hover_cont .nav_li_r a").on("mouseout",function(){
- $(this).css("background-color","");
- });
- $menu = null;
- }
- function showTime(){
- if($("#time").text()==""){
- $("#time").html("<font size=2pt color=ffffff>"+getDateTime()+"</font>");
- }else{
- $("#time font").text(getDateTime());
- }
- }
- //获得当前系统时间
- function getDateTime(){
- var s="";
- var d = allGetServerTime();
- var vYear = d.getFullYear();
- var vMon = d.getMonth() + 1;
- var vDay = d.getDate();
- var h = d.getHours();
- var m = d.getMinutes();
- var se = d.getSeconds();
- s=vYear+"年"+(vMon<10 ? "0" + vMon : vMon)+"月"+(vDay<10 ? "0"+ vDay : vDay)+"日 "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)+":"+(se<10 ? "0" +se : se);
- // if(se==59){
- // getDBNum();
- // }
- return s;
- }
- function getDBNum(){
- var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var company_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
- var url = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getDBNum';
- $.ajax({
- type: "POST",
- url: url,
- //async: false,
- data: {
- user_id:user_id,
- role_id:role_id,
- company_id:company_id
- },
- success: function(data){
- $("#daibanshu").text(parseInt(data));
- }
- });
- user_id = null;
- company_id = null;
- role_id = null;
- }
- // 初始化加载
- var menu = null;
- function menuInit(roleids) {
- showTime();
-
- $("#close_sys_msg").click(function(){
- $(this).parent().parent().hide();
- });
-
- // 搜索框获取焦点事件
- $("#search_in").live("focus",function(){
- // 获取焦点时,将搜索框清空
- var val = $(this).val("");
- });
- // 点击搜索按钮
- $("#search_img").live("click",search);
- $("#search_in").keydown(function(event){
- if(event.which == "13")
- search();
- });
- //定时器,每秒定时执行
- window.setInterval(function(){
- showTime();
- }, 1000);
-
-
- function search(){
- var searchData = $("#search_in").val();
- if(searchData == ""||searchData == "请输入关键字"){
- $("#frmright").attr("src","/nwyj/page/system/right/SysSearch.jsp");
- //$("#positionMsg").html("<div id='positionTitle1' class=''>全网搜索主页</div>");
- //$("#currPosition").show();
- }else{
- alert($("#search_in").val());
- }
- searchData = null;
- }
-
- // 获取用户功能菜单
- var url = $.pathname() + '/ws/sys/SysCustomMenuService/getShowMenuInfoByRoleIds';
- var params = {
- roleids : roleids
- };
- $.ajax({
- type: "POST",
- url: url,
- // async: false,
- data: params,
- success: function(data){
- // 一级菜单
- menu = data;
- createMenuNav(data);
-
- // 鼠标点击导航栏一级菜单时,显示对应的子菜单
- showSubMenu();
- // 显示时间
- getDBNum();
- },
- error : function(){
- alert("查询菜单失败!");
- }
-
- });
-
- };
- function createMenuNav(data){
- var $cont = $("#list");
- for (var i = 0; i < data.length; i++) {//第一次循环,添加一级菜单
- var menu1Name = data[i].name;
- var menu1Img = data[i].sortno;
- var menuID = data[i].id;
- var $dom1 = $('<li><a href="javascript:;" class="yj_menu_hover"><img src="'+menu1Img+'"><span>'+menu1Name+'</span></a></li>');
- $cont.append($dom1);//将一级菜单添加到容器
- if(menuID==7){
- $dom1.find(".yj_menu_hover").prepend('<a href="javascript:;"><div class="daiban" id="daiban"><span class="daibanshu" id="daibanshu">0</span></div></a>');
- }
- if(menuID==2 || menuID==6){//如果是首页或者是驾驶舱
- $dom1.data("menuData",data[i]);
- $dom1.bind("click",openMenu1);//绑定点击事件
- }
- var MenuChildren1 = data[i].submenu;//二级
- if(MenuChildren1!=undefined && MenuChildren1!=""){
- var $dom2 = $('<div class="hover_cont submenu'+i+'"><div class="nav_cont"></div></div>');
- $dom1.find(".yj_menu_hover").prepend($dom2);//将二级菜单添加到容器
- for(var j=0;j<MenuChildren1.length;j++){//第二次循环,添加二级菜单
- var MenuChildren2 = MenuChildren1[j].submenu;//三级
- if(MenuChildren2!=undefined && MenuChildren2!=""){
- var $dom22 = $('<div class="nav_li"><div class="nav_li_l">'+MenuChildren1[j].name+'</div><div class="nav_li_r"></div></div>');
- $dom2.find(".nav_cont").append($dom22);
- for(var k=0;k<MenuChildren2.length;k++){//第三次循环,添加三级菜单
- var $dom3 = $('<a href="javascript:;">'+MenuChildren2[k].name+'</a>');
- $dom3.data("menuData",MenuChildren2[k]);
- $dom3.bind("click",openMenu3);
- $dom22.find(".nav_li_r").append($dom3);
- };
- };
-
- };
- };
-
-
- };
-
- }
- /***
- * 一级菜单点击事件
- */
- function openMenu1(){
- var data = $(this).data("menuData");
- var menuUri = data.remark;
- var menuID=data.id;
- if(menuUri==""||menuUri==null)
- {
- return
- }else if(menuID==6) {
- // 获取用户部门
- var dept_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- // 获取用户Id
- var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var user_name = top.com.sinosoft.lz.system.user.LoginInfo.getLogin_name();
- //父部门id
- var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
- var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
- var dept_name = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
- menuUri = menuUri+"?dept_id="+dept_id+"&&user_id="+user_id+"&&user_name="+encodeURI(user_name)+"&&dept_name="+encodeURI(dept_name)+"&&parentId="+parentId+"&&role_id="+encodeURI(role_id);
- window.open(menuUri,"_blank","");
-
- } else {
- document.getElementById("frmright").setAttribute("src", menuUri);
- $("#currPosition").hide();
- $(".hover_cont .nav_li_r a").css("color","#0066CC");
- };
- }
- function openMenu3(){
- var data = $(this).data("menuData");
- var menuUri = data.remark;
- var menuId = data.id;
- var menuName3 = data.name;
- var imgurl = data.sortno;
- var imgclass = imgurl.substring(imgurl.lastIndexOf("/")+1,imgurl.indexOf(".png"));
- if(menuUri==""||menuUri==null||menuUri==undefined){
- return;
- }else{
- var iframe = $("#frmright").get(0).contentWindow;
- if("MSIE"==getOs()){
- iframe.src = 'about:Tabs';
- }else{
- iframe.src = 'about:blank';
- }
- if(iframe.CollectGarbage){
- iframe.CollectGarbage();
- }
- iframe.document.write('');
- //iframe.document.clear();
- iframe=null;
- $(".hover_cont .nav_li_r a").css("color","#0066CC");
- $(this).css("color","#9700ad");
-
- //记录用户点击次数
- var loginfojson = eval('(' + top.window.name + ')');//登录用户信息
- var user_id = loginfojson.LoginInfo.user_id;
- loginfojson = null;
- userClickNum (user_id,menuId);
- user_id = null;
- //记录用户点击次数
-
- $("#frmright").attr("src",menuUri+"?menu_id="+menuId+"&&imgclass="+imgclass);
- $("#positionMsg").html("<div id='positionTitle1' class='"+imgclass+"'>"+menuName3+"</div>");
- // 隐藏二三极菜单框
- hideMenu();
- $("#currPosition").show();
- };
-
- }
- function hideMenu(){
- $(".nav_li_r").click(function(){
- $(this).parent().parent().parent().hide();
- });
-
- }
- //判断浏览器的类型
- function getOs(){
- if(navigator.userAgent.indexOf("MSIE")>0) {
- return "MSIE";
- } ;
- if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
- return "Firefox";
- } ;
- if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
- return "Safari";
- } ;
- if(isCamino=navigator.userAgent.indexOf("Camino")>0){
- return "Camino";
- };
- if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
- return "Gecko";
- } ;
- };
|