65c9ea204c8ea9d1d70414c58b7b73ea51387c13.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // 监听浏览器窗口大小的改变,样式进行相应的调整
  2. var wid = window.screen.width-50;
  3. $(window).resize(function() {
  4. var wwww = $(window).width();
  5. if(wwww <= wid){
  6. $("html").css({"min-width":wid+"px","height":"100%","overflow":"auto","overflow-x":""});
  7. }else{
  8. $("html").css({"width":"100%","height":"100%","overflow":"scroll","overflow-x":"hidden"});
  9. }
  10. wwww = null;
  11. });
  12. function showSubMenu(){
  13. var $menu = $(".yj_menu_hover");
  14. // 鼠标悬停显示下拉菜单
  15. $($menu).parent().on("mouseenter",function(){
  16. $(this).find(".yj");
  17. $(this).find(".yj_menu_hover").css("background-color","#0f4a8b");
  18. $(this).find(".hover_cont").show();
  19. });
  20. $($menu).parent().on("mouseleave",function(){
  21. $(this).find(".yj_menu_hover").css("background-color","");
  22. $(this).find(".hover_cont").hide();
  23. });
  24. $(".hover_cont .nav_li_r a").on("mouseover",function(){
  25. $(this).css({"background-color":"#ddd"});
  26. });
  27. $(".hover_cont .nav_li_r a").on("mouseout",function(){
  28. $(this).css("background-color","");
  29. });
  30. $menu = null;
  31. }
  32. function showTime(){
  33. if($("#time").text()==""){
  34. $("#time").html("<font size=2pt color=ffffff>"+getDateTime()+"</font>");
  35. }else{
  36. $("#time font").text(getDateTime());
  37. }
  38. }
  39. //获得当前系统时间
  40. function getDateTime(){
  41. var s="";
  42. var d = allGetServerTime();
  43. var vYear = d.getFullYear();
  44. var vMon = d.getMonth() + 1;
  45. var vDay = d.getDate();
  46. var h = d.getHours();
  47. var m = d.getMinutes();
  48. var se = d.getSeconds();
  49. 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);
  50. // if(se==59){
  51. // getDBNum();
  52. // }
  53. return s;
  54. }
  55. function getDBNum(){
  56. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  57. var company_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  58. var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  59. var url = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getDBNum';
  60. $.ajax({
  61. type: "POST",
  62. url: url,
  63. //async: false,
  64. data: {
  65. user_id:user_id,
  66. role_id:role_id,
  67. company_id:company_id
  68. },
  69. success: function(data){
  70. $("#daibanshu").text(parseInt(data));
  71. }
  72. });
  73. user_id = null;
  74. company_id = null;
  75. role_id = null;
  76. }
  77. // 初始化加载
  78. var menu = null;
  79. function menuInit(roleids) {
  80. showTime();
  81. $("#close_sys_msg").click(function(){
  82. $(this).parent().parent().hide();
  83. });
  84. // 搜索框获取焦点事件
  85. $("#search_in").live("focus",function(){
  86. // 获取焦点时,将搜索框清空
  87. var val = $(this).val("");
  88. });
  89. // 点击搜索按钮
  90. $("#search_img").live("click",search);
  91. $("#search_in").keydown(function(event){
  92. if(event.which == "13")
  93. search();
  94. });
  95. //定时器,每秒定时执行
  96. window.setInterval(function(){
  97. showTime();
  98. }, 1000);
  99. function search(){
  100. var searchData = $("#search_in").val();
  101. if(searchData == ""||searchData == "请输入关键字"){
  102. $("#frmright").attr("src","/nwyj/page/system/right/SysSearch.jsp");
  103. //$("#positionMsg").html("<div id='positionTitle1' class=''>全网搜索主页</div>");
  104. //$("#currPosition").show();
  105. }else{
  106. alert($("#search_in").val());
  107. }
  108. searchData = null;
  109. }
  110. // 获取用户功能菜单
  111. var url = $.pathname() + '/ws/sys/SysCustomMenuService/getShowMenuInfoByRoleIds';
  112. var params = {
  113. roleids : roleids
  114. };
  115. $.ajax({
  116. type: "POST",
  117. url: url,
  118. // async: false,
  119. data: params,
  120. success: function(data){
  121. // 一级菜单
  122. menu = data;
  123. createMenuNav(data);
  124. // 鼠标点击导航栏一级菜单时,显示对应的子菜单
  125. showSubMenu();
  126. // 显示时间
  127. getDBNum();
  128. },
  129. error : function(){
  130. alert("查询菜单失败!");
  131. }
  132. });
  133. };
  134. function createMenuNav(data){
  135. var $cont = $("#list");
  136. for (var i = 0; i < data.length; i++) {//第一次循环,添加一级菜单
  137. var menu1Name = data[i].name;
  138. var menu1Img = data[i].sortno;
  139. var menuID = data[i].id;
  140. var $dom1 = $('<li><a href="javascript:;" class="yj_menu_hover"><img src="'+menu1Img+'"><span>'+menu1Name+'</span></a></li>');
  141. $cont.append($dom1);//将一级菜单添加到容器
  142. if(menuID==7){
  143. $dom1.find(".yj_menu_hover").prepend('<a href="javascript:;"><div class="daiban" id="daiban"><span class="daibanshu" id="daibanshu">0</span></div></a>');
  144. }
  145. if(menuID==2 || menuID==6){//如果是首页或者是驾驶舱
  146. $dom1.data("menuData",data[i]);
  147. $dom1.bind("click",openMenu1);//绑定点击事件
  148. }
  149. var MenuChildren1 = data[i].submenu;//二级
  150. if(MenuChildren1!=undefined && MenuChildren1!=""){
  151. var $dom2 = $('<div class="hover_cont submenu'+i+'"><div class="nav_cont"></div></div>');
  152. $dom1.find(".yj_menu_hover").prepend($dom2);//将二级菜单添加到容器
  153. for(var j=0;j<MenuChildren1.length;j++){//第二次循环,添加二级菜单
  154. var MenuChildren2 = MenuChildren1[j].submenu;//三级
  155. if(MenuChildren2!=undefined && MenuChildren2!=""){
  156. var $dom22 = $('<div class="nav_li"><div class="nav_li_l">'+MenuChildren1[j].name+'</div><div class="nav_li_r"></div></div>');
  157. $dom2.find(".nav_cont").append($dom22);
  158. for(var k=0;k<MenuChildren2.length;k++){//第三次循环,添加三级菜单
  159. var $dom3 = $('<a href="javascript:;">'+MenuChildren2[k].name+'</a>');
  160. $dom3.data("menuData",MenuChildren2[k]);
  161. $dom3.bind("click",openMenu3);
  162. $dom22.find(".nav_li_r").append($dom3);
  163. };
  164. };
  165. };
  166. };
  167. };
  168. }
  169. /***
  170. * 一级菜单点击事件
  171. */
  172. function openMenu1(){
  173. var data = $(this).data("menuData");
  174. var menuUri = data.remark;
  175. var menuID=data.id;
  176. if(menuUri==""||menuUri==null)
  177. {
  178. return
  179. }else if(menuID==6) {
  180. // 获取用户部门
  181. var dept_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  182. // 获取用户Id
  183. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  184. var user_name = top.com.sinosoft.lz.system.user.LoginInfo.getLogin_name();
  185. //父部门id
  186. var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
  187. var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  188. var dept_name = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
  189. 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);
  190. window.open(menuUri,"_blank","");
  191. } else {
  192. document.getElementById("frmright").setAttribute("src", menuUri);
  193. $("#currPosition").hide();
  194. $(".hover_cont .nav_li_r a").css("color","#0066CC");
  195. };
  196. }
  197. function openMenu3(){
  198. var data = $(this).data("menuData");
  199. var menuUri = data.remark;
  200. var menuId = data.id;
  201. var menuName3 = data.name;
  202. var imgurl = data.sortno;
  203. var imgclass = imgurl.substring(imgurl.lastIndexOf("/")+1,imgurl.indexOf(".png"));
  204. if(menuUri==""||menuUri==null||menuUri==undefined){
  205. return;
  206. }else{
  207. var iframe = $("#frmright").get(0).contentWindow;
  208. if("MSIE"==getOs()){
  209. iframe.src = 'about:Tabs';
  210. }else{
  211. iframe.src = 'about:blank';
  212. }
  213. if(iframe.CollectGarbage){
  214. iframe.CollectGarbage();
  215. }
  216. iframe.document.write('');
  217. //iframe.document.clear();
  218. iframe=null;
  219. $(".hover_cont .nav_li_r a").css("color","#0066CC");
  220. $(this).css("color","#9700ad");
  221. //记录用户点击次数
  222. var loginfojson = eval('(' + top.window.name + ')');//登录用户信息
  223. var user_id = loginfojson.LoginInfo.user_id;
  224. loginfojson = null;
  225. userClickNum (user_id,menuId);
  226. user_id = null;
  227. //记录用户点击次数
  228. $("#frmright").attr("src",menuUri+"?menu_id="+menuId+"&&imgclass="+imgclass);
  229. $("#positionMsg").html("<div id='positionTitle1' class='"+imgclass+"'>"+menuName3+"</div>");
  230. // 隐藏二三极菜单框
  231. hideMenu();
  232. $("#currPosition").show();
  233. };
  234. }
  235. function hideMenu(){
  236. $(".nav_li_r").click(function(){
  237. $(this).parent().parent().parent().hide();
  238. });
  239. }
  240. //判断浏览器的类型
  241. function getOs(){
  242. if(navigator.userAgent.indexOf("MSIE")>0) {
  243. return "MSIE";
  244. } ;
  245. if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
  246. return "Firefox";
  247. } ;
  248. if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
  249. return "Safari";
  250. } ;
  251. if(isCamino=navigator.userAgent.indexOf("Camino")>0){
  252. return "Camino";
  253. };
  254. if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
  255. return "Gecko";
  256. } ;
  257. };