// 监听浏览器窗口大小的改变,样式进行相应的调整
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(""+getDateTime()+"");
}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("
全网搜索主页
");
//$("#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 = $('');
$cont.append($dom1);//将一级菜单添加到容器
if(menuID==7){
$dom1.find(".yj_menu_hover").prepend('0
');
}
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 = $('');
$dom1.find(".yj_menu_hover").prepend($dom2);//将二级菜单添加到容器
for(var j=0;j'+MenuChildren1[j].name+'
');
$dom2.find(".nav_cont").append($dom22);
for(var k=0;k'+MenuChildren2[k].name+'');
$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(""+menuName3+"
");
// 隐藏二三极菜单框
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";
} ;
};