var menuUtil=function(swidth,strJsonMenu,strJsonParam,webPath){ this.leftTip=$("#main_menu_left"); this.rightTip=$("#main_menu_right"); this.leftTipShow=false; //是否显示左边的菜单条 this.rightTipShow=false; //是否显示左边的菜单条 this.menuBody=$("#main_menu_body");//菜单的对象 this.menuItemBody=$("#main_top_menu_info"); this.logoWidth=180; this.sysWidth=140; this.titleHight=60;//当前一级菜单的高度 this.titleWidth=90;//当前一级菜单的宽度 this.secondeWidth=140;//二级菜单的宽度 this.menuData=[];//菜单数据 this.menuWidth=swidth;//当前的宽带 this.menuLength=0;//当前一级菜单的长度 this.menuShowSartIndex=0;//当前显示一级菜单的开始位置 this.menuMayShowNumber;//当前显示一级菜单的结束位置 this.menuItem=[];//当前一级菜单对象 this.mentuJson=null;//当前菜单的JSON this.curMayShowNumber=0;//当前可显示的条数 this.curSelectIndex=-1;//当前选中的位置 this.curSelectItem=null; this.webPath=webPath; // this.initMenu(); this.addHomePageClick(); this.mentuJson=JSON.parse(strJsonMenu); this.menuLength=this.mentuJson.length; this.urlparm=JSON.parse(strJsonParam); this.initMenuItem(); this.initMenuItemCheckFunciton(); this.initMenuShowTip(); this.initMenuShowTipCheckFunction(); this.initWindowResize(); // this.resizeFirstPageBody(); this.loadUserInfo(); }; menuUtil.prototype.addHomePageClick=function(){ var tempMenuUtil=this; //增加返回首页 $("#main_logo").click(function(){ AsControl.OpenView("/Tenwa/HomePage/DefaultHome/HomePage.jsp","","right"); }) //增显示用户信息 $("#main_sys_exitout").click(function(){ if(!confirm(getMessageText("AWEW1014"))) return; // 你确实要退出吗? AsControl.OpenComp("/AppMain/SignOut.jsp","","_top"); }) $("#main_top").click(function(){ tempMenuUtil.hideSelectShowMenuItem(); }); $("#main_menu").click(function(event){ event.stopPropagation(); }); } menuUtil.prototype.initMenu=function(){ //加载菜单的数据 var strMenuJson=$.ajax({ type:"GET", url:"../data/mainmenu.txt", dataType:"txt", contentType: "application/x-www-form-urlencoded; charset=utf-8", async: false}).responseText; if(strMenuJson==""){ this.menuLength=0; }else{ this.mentuJson=JSON.parse(strMenuJson); this.menuLength=this.mentuJson.length; } } menuUtil.prototype.initMenuItem=function(){ var curMenuWidth=this.loadMenuWidth(); this.menuMayShowNumber=parseInt(curMenuWidth/ this.titleWidth); if(this.menuMayShowNumber=this.menuMayShowNumber){showType='style="display:none"';} var tempItem=$('

  • '+this.mentuJson[i].menuname+'
  • ') this.menuItem.push(tempItem) this.menuBody.append(tempItem); } } menuUtil.prototype.loadMenuWidth=function(){ var curMenuWidth=this.menuWidth-this.logoWidth- this.sysWidth; return curMenuWidth; } menuUtil.prototype.initMenuItemCheckFunciton=function(){ var tempMenuUtil=this; $('#main_menu li').click(function (event) { tempMenuUtil.setMenuItemSeleced($(this)); var curSelect=$(this); tempMenuUtil.curSelectIndex=curSelect.attr("cindex"); var menuid=curSelect.attr("menuid"); var url=""; if(tempMenuUtil.urlparm[curSelect.attr("menuid")]){ url=tempMenuUtil.urlparm[curSelect.attr("menuid")].url||""; } if(url.length<2){ var subSize=tempMenuUtil.loadSubItems(); tempMenuUtil.showMenuChildItem(subSize); }else{ tempMenuUtil.hideSelectShowMenuItem(); tempMenuUtil.openMenu(curSelect); } }); }; /** * 显示修改二级菜单位置 * @param subSize */ menuUtil.prototype.showMenuChildItem=function(subSize){ if(subSize>0){ var curWindowWidth=$(window).width(); var centerPoint=this.logoWidth+(this.curSelectIndex-this.menuShowSartIndex)* this.titleWidth+(this.titleWidth/2); if(this.leftTip.css("display")=="block"){ centerPoint=centerPoint+25; } if((centerPoint-(this.titleWidth/2)+this.menuItemBody.width())0){ this.menuItemBody.css("left",(centerPoint+(this.titleWidth/2))-this.menuItemBody.width()+"px"); }else{ this.menuItemBody.css("left",curWindowWidth-this.menuItemBody.width()+"px"); } } } this.menuItemBody.show(); if($("#main_menu_back")){ $("#main_menu_back").remove(); } var menubackDiv = $(""); var curMenu=this; $(document.body).append(menubackDiv); menubackDiv.click(function(){ curMenu.menuItemBody.hide(); $("#main_menu li[class='main_menuf']").removeClass("main_menuf"); menubackDiv.remove(); }); }else{ this.menuItemBody.hide(); $("#main_menu_back").remove(); } } /** * 显示一级菜单上面的左或右边的按钮 */ menuUtil.prototype.initMenuShowTip=function(){ if(this.menuMayShowNumber==0){ this.leftTipShow=false; this.rightTipShow=false; } if(this.menuMayShowNumber>=this.menuLength){ this.leftTipShow=false; this.rightTipShow=false; }else{ if((this.menuShowSartIndex+this.menuMayShowNumber)==this.menuLength){ this.leftTipShow=true; this.rightTipShow=false; }else{ if(this.menuShowSartIndex==0){ this.leftTipShow=false; this.rightTipShow=true; }else{ this.leftTipShow=true; this.rightTipShow=true; if((this.menuShowSartIndex+this.menuMayShowNumber)==this.menuLength){ this.leftTipShow=true; this.rightTipShow=false; }else{ this.leftTipShow=true; this.rightTipShow=true; } } } } if(this.leftTipShow){this.leftTip.show();}else{this.leftTip.hide();} if(this.rightTipShow){ this.rightTip.show()}else{this.rightTip.hide();} if(this.leftTipShow){ this.menuBody.css("margin-left",25); this.leftTip.show(); if(this.rightTipShow){ this.rightTip.css("margin-left", this.titleWidth*this.menuMayShowNumber+25); } } else{ this.leftTip.hide() this.menuBody.css("margin-left",0); if(this.rightTipShow){ this.rightTip.css("margin-left", this.titleWidth*this.menuMayShowNumber); } } } menuUtil.prototype.setMenuItemSeleced=function(item){ $("#main_menu li[class='main_menuf']").removeClass("main_menuf"); item.addClass("main_menuf"); this.curSelectItem=item; } menuUtil.prototype.initMenuShowTipCheckFunction=function(){ var tempMenuUtil=this; this.leftTip.mousedown(function(){ $(this).removeClass("main_menu_left"); $(this).addClass("main_menu_left_selected"); }); this.leftTip.mouseup(function(){ $(this).removeClass("main_menu_left_selected"); $(this).addClass("main_menu_left"); }); this.rightTip.mousedown(function(){ $(this).removeClass("main_menu_right"); $(this).addClass("main_menu_right_selected"); }); this.rightTip.mouseup(function(){ $(this).removeClass("main_menu_right_selected"); $(this).addClass("main_menu_right"); }); this.leftTip.click(function (){ tempMenuUtil.moveMenuItemLeft(); }); this.rightTip.click(function(){ tempMenuUtil.moveMenuItemRight(); }); } menuUtil.prototype.moveMenuItemLeft=function(){ if((this.menuShowSartIndex+this.menuMayShowNumber-1)=0){this.menuItem[this.menuShowSartIndex].show()}; this.hideSelectShowMenuItem(); this.initMenuShowTip(); } menuUtil.prototype.moveMenuItemRight=function(){ if(this.menuShowSartIndex>=0){this.menuItem[this.menuShowSartIndex].hide();} this.menuShowSartIndex+=1; if((this.menuShowSartIndex+this.menuMayShowNumber-1)"); var rowHightIndex={}; var leveShowNumber=0; if(Items.length>0){ this.menuItemBody.empty(); var tempSubLi=[]; for(var i=0;i"+oneItems.menuname+""); var tempUl=$("
      "); tempUl.append(tempSubLi); var menuDiv=this.getMenuItemDiv(cindex); menuDiv.append(tempUl) parentDiv.append(menuDiv); rowHightIndex[cindex]=tempSubLi.length; tempSubLi=[]; }else{ if(nodetype=="root"){ if(tempSubLi.length>0){ cindex+=1; var tempUl=$("
        "); tempUl.append(tempSubLi); var menuDiv=this.getMenuItemDiv(cindex); menuDiv.append(tempUl) parentDiv.append(menuDiv); rowHightIndex[cindex]=tempSubLi.length; tempSubLi=[]; } cindex+=1; var tempUl=$("
          "); tempUl.append(""); var subItems=oneItems.submenu||[]; for(var j=0;j"+subItems[j].menuname+""); } var menuDiv=this.getMenuItemDiv(cindex); rowHightIndex[cindex]=subItems.length+1; menuDiv.append(tempUl) parentDiv.append(menuDiv); }else{ tempSubLi.push(""); } } } //设置显示的宽度 var d=5; if(cindex>=5){d=5;}else{d=cindex} var curWindowWidth=$(window).width(); if((curWindowWidth)<(d*this.secondeWidth+(d-1))){ d=parseInt((curWindowWidth-40)/this.secondeWidth); leveShowNumber=d; }else{ leveShowNumber=d; } parentDiv.width(leveShowNumber*this.secondeWidth+(leveShowNumber-1)+"px"); this.menuItemBody.append(parentDiv); this.menuItemBody.width(leveShowNumber* this.secondeWidth+(leveShowNumber)+"px"); } //计算每一层的高度 var maxIndex=0; var maxHeightIndex=0; for(tindex in rowHightIndex){ if(rowHightIndex[tindex]>maxIndex){ maxIndex=rowHightIndex[tindex]; } if(tindex%leveShowNumber==0 ||tindex==cindex ){ var before=0; if(tindex<=leveShowNumber){ before=1; }else{ if(tindex%leveShowNumber==0){before=tindex-leveShowNumber+1;} else{ if(tindex==cindex){before=tindex-tindex%leveShowNumber+1;} } } for(var j=before ;j<=tindex;j++){rowHightIndex[j]=maxIndex;} maxHeightIndex=maxHeightIndex+maxIndex; maxIndex=0; } } this.menuItemBody.find("div").each(function(index,elemnt){ if(index>0){ if((index-1)%leveShowNumber==0){ $(this).removeClass("main_menuitem_boder"); } $(this).height(rowHightIndex[index]*35+5); }else{ $(this).height(maxHeightIndex*35)+10; } }); var curWindowHeight=$(window).height()-this.titleHight; if(curWindowHeight1){ return $(""); }else{ return $("
          "); } } menuUtil.prototype.openMenu=function(curselect){ var url=this.urlparm[curselect.attr("menuid")].url; var param=this.urlparm[curselect.attr("menuid")].param; var tabid=$(window.frames["right"].document).find("#tabs_button_T01"); var title=curselect.text(); var sParas = param+"&_SYSTEM_MENU_FALG=0"; if(tabid.length==0){ AsControl.OpenView("/AppMain/MenuTabContainer.jsp", "isAddMain=true&Title="+title+"&ToDestroyAllComponent=N&Url="+url+"&Paras="+param, "right"); }else{ var tWin=window.frames["right"]; if(typeof tWin.addTabItem == "function"){ var text=title; var sURL=url; var sPara=sParas; tWin.addTabItem(text, sURL,sPara); } } } menuUtil.prototype.loadUserInfo=function(){ var userHtmlDiv=$(""); var userHtmlTable=$("
          "); var userInfo=getUserHTMLJson(); var userData=getUserInfo(); for(var i=0;i:"; temp+=""; userHtmlTable.append($(temp)); } userHtmlTable.append($("   ")); userHtmlTable.append($("语言:英文   中文")); userHtmlDiv.append(userHtmlTable); $("#main_sys_user").append(userHtmlDiv); var curMenu=this $("#main_sys_user").mouseover(function(){ //关闭显示的二级菜单 curMenu.menuItemBody.hide(); $("#main_menu li[class='main_menuf']").removeClass("main_menuf"); $("#main_user_info").show(); }); $("#main_sys_user").mouseout(function(){ $("#main_user_info").hide(); }); } function saveUserInfo(){ var email = $("#email").val(); var mobile = $("#mobile").val(); var comptel = $("#comptel").val(); if(email && !/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/.test(email)){ alert(getMessageText("AWES2051")); // Email填写错误! restoreUserInfo(); return; } if(mobile && !/^[1][3|5][0-9]{9}$/.test(mobile)){ alert(getMessageText("AWES2052")); // 手机号填写错误! restoreUserInfo(); return; } if(comptel && !/^([0-9]{1,3}-)?([0-9]{2,4}-)?[0-9]{7,11}(-[0-9]{1,5})?$/.test(comptel)){ alert(getMessageText("AWES2053")); // 办公电话填写错误! restoreUserInfo(); return; } var sReturn = AsControl.RunJsp("/AppConfig/ControlCenter/ChangeContactInfo.jsp", "Email="+email+"&Mobile="+mobile+"&Comptel="+comptel); if(sReturn){ alert(sReturn); }else{ alert("操作成功!"); } } function restoreUserInfo(){ var result =AsControl.RunJsp("/AppConfig/ControlCenter/restoreUserInfo.jsp",""); var $result = $(result); var param = $result.filter("span").html(); var o = param.split(","); $("#email").val(o[0]); $("#mobile").val(o[2]); $("#comptel").val(o[1]); } var mainBodyResize=function(){ this.resizeFirstPageBody(); this.initWindowResize(); } mainBodyResize.prototype.initWindowResize=function(){ var tempMenuUtil=this; $(window).resize(function() { tempMenuUtil.resizeFirstPageBody(); }); } mainBodyResize.prototype.resizeFirstPageBody=function(){ var curHight=$(document.body)[0].clientHeight; var curWidth=$(window).width(); var worktiwidth=(curWidth)*3/5; worktiwidth=worktiwidth.toFixed(2); var worktipHight=(curHight)*1/2+5; $("#main_worktip_title_body").width(worktiwidth+"px"); $("#main_worktip_title_body").height(worktipHight+"px"); //设置公告信息的宽度和高度 $("#main_noticetitle_body").width((worktiwidth-360)+"px"); //$("#main_calendartitle_body").width((worktiwidth-5-(worktiwidth-350))+"px"); var otherHight=(curHight-worktipHight-100); $("#main_noticetitle_body").height((otherHight-20)+"px"); $("#main_calendartitle_body").height((otherHight)+"px"); //设置报表的高度 var reportLeft=parseFloat(worktiwidth)+30; //$("#main_body_right").css("margin-left",reportLeft+"px"); var reportWidth=(curWidth-50-worktiwidth)+"px"; $("#main_body_right").width(reportWidth); var reportHeight=(worktipHight-4)/2; $("#report01").height(reportHeight+"px"); // $("#report01").width(reportWidth); $("#report02").height(reportHeight+"px"); $("#report02").css("margin-top","10px"); // $("#report02").width(reportWidth); $("#report03").height(otherHight-20+"px"); $("#report03").css("margin-top","10px"); // $("#report03").width(reportWidth); // $("#main_body").css("overflow","visible"); } function changeLang(sLang){ alert(sLang); AsControl.RunJsp("/Frame/page/sys/tools/ChangeLang.jsp", "Lang="+sLang); self.location.reload(); }