easyui框架首页封装

主持右键菜单,Tab操作

var _menus = null;

$(function(){
	InitLeftMenu();
	tabClose();
	tabCloseEven();
	
	$('#tabs').tabs({
        onSelect: function (title) {
            var currTab = $('#tabs').tabs('getTab', title);
            var iframe = $(currTab.panel('options').content);

			var src = iframe.attr('src');
			if(src)
				$('#tabs').tabs('update', { tab: currTab, options: { content: createFrame(src)} });

        }
    });
});


//初始化左侧
function InitLeftMenu() {
	$("#nav").accordion({animate:false});
	
	$.ajax({
		async:false,
		cache:false,
		type: 'POST',
		dataType: "json",
		url: path+'/userlogin/pingMenu',//请求的action路径
		error: function () {//请求失败处理函数
			alert('请求失败');
		},success:function(data){
			 _menus = data;
		}
	});
	
    $.each(_menus, function(i, n) {
		var menulist ='';
		menulist +='<ul>';
        $.each(n.menus, function(j, o) {
			menulist += '<li><div><a ref="'+o.menuid+'" href="#" rel="' + path + o.url + '" ><span class="icon '+o.icon+'" >&nbsp;</span><span class="nav">' + o.menuname + '</span></a></div></li> ';
        });
		menulist += '</ul>';

		$('#nav').accordion('add', {
            title: n.menuname,
            content: menulist,
            iconCls: 'icon ' + n.icon
        });

    });

	$('.easyui-accordion li a').click(function(){
		var tabTitle = $(this).children('.nav').text();

		var url = $(this).attr("rel");
		var menuid = $(this).attr("ref");
		var icon = getIcon(menuid,icon);

		addTab(tabTitle,url,icon);
		$('.easyui-accordion li div').removeClass("selected");
		$(this).parent().addClass("selected");
	}).hover(function(){
		$(this).parent().addClass("hover");
	},function(){
		$(this).parent().removeClass("hover");
	});

	//选中第一个
	var panels = $('#nav').accordion('panels');
	var t = panels[0].panel('options').title;
    $('#nav').accordion('select', t);
}
//获取左侧导航的图标
function getIcon(menuid){
	var icon = 'icon ';
	$.each(_menus, function(i, n) {
		 $.each(n.menus, function(j, o) {
		 	if(o.menuid==menuid){
				icon += o.icon;
			}
		 });
	});

	return icon;
}

function createTab(subtitle,url,icon){
	if(!$('#tabs').tabs('exists',subtitle)){
		$('#tabs').tabs('add',{
			title:subtitle,
			content:createFrame(url),
			closable:true,
			icon:icon
		});
	}else{
		var tab = $('#tabs').tabs('getTab',subtitle);  // get selected panel
		$("#tabs").tabs('update',{
	        tab:tab,
	        options:{
	           title:subtitle,
	           content:createFrame(url),
		       closable:true,
		       fit:true,
		       selected:true,
		       icon:icon
	        }
		});
		
		$('#tabs').tabs('select',subtitle);
	}
}
function createMainTab(subtitle,url,icon){
	
	
	$('#tabs').tabs('add',{
		title:subtitle,
		content:createFrame(url),
		closable:false,
		icon:icon,
	});
	
}
function createFrame(url)
{
	var s = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
	return s;
}

function tabClose()
{
	/*双击关闭TAB选项卡*/
	$(".tabs-inner").dblclick(function(){
		var subtitle = $(this).children(".tabs-closable").text();
		$('#tabs').tabs('close',subtitle);
	});
	/*为选项卡绑定右键*/
	$(".tabs-inner").bind('contextmenu',function(e){
		$('#mm').menu('show', {
			left: e.pageX,
			top: e.pageY
		});

		var subtitle =$(this).children(".tabs-closable").text();

		$('#mm').data("currtab",subtitle);
		$('#tabs').tabs('select',subtitle);
		return false;
	});
}
//绑定右键菜单事件
function tabCloseEven()
{
	//刷新
	/*$('#mm-tabupdate').click(function(){
		var currTab = $('#tabs').tabs('getSelected');
		var url = $(currTab.panel('options').content).attr('src');
		$('#tabs').tabs('update',{
			tab:currTab,
			options:{
				content:createFrame(url)
			}
		})
	})*/
	//关闭当前
	$('#mm-tabclose').click(function(){
		var currtab_title = $('#mm').data("currtab");
		$('#tabs').tabs('close',currtab_title);
	});
	//全部关闭
	$('#mm-tabcloseall').click(function(){
		$('.tabs-inner span').each(function(i,n){
			var t = $(n).text();
			if(t!='首页'){
				$('#tabs').tabs('close',t);
			}
		});
	});
	//关闭除当前之外的TAB
	$('#mm-tabcloseother').click(function(){
		$('#mm-tabcloseright').click();
		$('#mm-tabcloseleft').click();
	});
	//关闭当前右侧的TAB
	$('#mm-tabcloseright').click(function(){
		var nextall = $('.tabs-selected').nextAll();
		if(nextall.length==0){
			//msgShow('系统提示','后边没有啦~~','error');
			alert('后边没有啦~~');
			return false;
		}
		nextall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			if(t!='首页'){
				$('#tabs').tabs('close',t);
			}
		});
		return false;
	});
	//关闭当前左侧的TAB
	$('#mm-tabcloseleft').click(function(){
		var prevall = $('.tabs-selected').prevAll();
		if(prevall.length==0){
			alert('到头了,前边没有啦~~');
			return false;
		}
		prevall.each(function(i,n){
			var t=$('a:eq(0) span',$(n)).text();
			if(t!='首页'){
				$('#tabs').tabs('close',t);
			}
		});
		return false;
	});

	//退出
	$("#mm-exit").click(function(){
		$('#mm').menu('hide');
	});
}

//弹出信息窗口 title:标题 msgString:提示信息 msgType:信息类型 [error,info,question,warning]
function msgShow(title, msgString, msgType) {
	$.messager.alert(title, msgString, msgType);
}

首页页面

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>xxxxxxxxxxxxxxxxx管理系统</title>
	<%@ include file="/jsp/headCommon.jsp"%>
	<style type="text/css">
		a:hover {
			text-decoration: none;
		}
		
		a:link {
			text-decoration: none;
		}
	</style>
	
    <script type="text/javascript"  charset="utf-8">

		
     //设置登录窗口
     function openPwd() {
    	 add('修改密码','<%=path%>/userlogin/doUpwd?id=${login_id}','pencil',400,120);
     }
     
     //选择期号
     function openPeriod() {
    	 openwindow('选择期号','<%=path%>/userlogin/doChoosePeriod',750,400);
     }

     $(function() {
     	var urlPP="<%=path%>";
     	addMainTab("首页",urlPP+"/main/home","icon-cologne-home");
         
         function currentTime(){
         	var d = new Date(),str = '';
         	 str += d.getFullYear()+'年';
         	 str  += d.getMonth() + 1+'月';
         	 str  += d.getDate()+'日';
         	 str += d.getHours()+'时'; 
         	 str  += d.getMinutes()+'分'; 
         	str+= d.getSeconds()+'秒'; 
         	return str;
         	}
         	setInterval(function(){$('#timerSpan').html(currentTime);},1000);
         
         $('#cicon01').click(function() {
             openPwd();
         });

         $('#loginOut').click(function() {
        	 $.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
                 if (r) {
                     location.href = '<%=path%>/loginOut';
                 }
             });
         });
     });
		
    </script>
</head>
<body class="easyui-layout" style="overflow-y: hidden"  scroll="no">

<!--
<noscript>
<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;">
    <img src="images/noscript.gif" alt='抱歉,请开启脚本支持!' />
</div>
</noscript>

-->
<style type="text/css">
		*{margin:0;padding:0}
		body{ position:relative;overflow-x:hidden;}
		.headerit{overflow: hidden;height:90px; background:url(<%=path%>/images/lhp_headbg.jpg) no-repeat center top; line-height: 0px; color: rgb(255, 255, 255); font-family: Verdana, 微软雅黑, 黑体; width:1440px}
		.optionit{display:block;height:80px;line-height: 70px;float:right;width:300px;padding-right:20px}
		#cicon01{display:block;float:right;width:50px;height:70px;text-indent:-44444px;background:url(<%=path%>/images/lhp_ico01_04.png) no-repeat 0 0;margin-left:10px;}
		#cicon01:hover{background-image:url(<%=path%>/images/lhp_ico01_on_04.png);}
		#editpass{display:block;float:right;width:65px;height:74px;text-indent:-44444px;background:url(<%=path%>/images/c_icon02.png) no-repeat 0 0;margin-top:10px;margin-left:20px;}
		#editpass:hover{background-image:url(<%=path%>/images/c_icon02-on.png);}
		#loginOut{display:block;float:right;width:50px;height:60px;text-indent:-44444px;background:url(<%=path%>/images/lhp_ico02_04.png) no-repeat 0 0;margin-left:10px;}
		#loginOut:hover{background-image:url(<%=path%>/images/lhp_ico02_on_04.png);}
		.by_txt{font-size:12px; font-family:"宋体"; font-weight:100; padding-left:70px; float:left; display:inline}
	</style>
	
    
    <div region="north" split="true" border="false" class="layout-body panel-body panel-body-noheader panel-body-noborder headerit" title="">
        <span class="optionit">
        <span class="by_txt"></span>
	        <a href="#" id="loginOut">退出</a>
	        <a href="#" id="cicon01">修改密码</a>
	    </span>
        <span style="font-size: 16px; ">
	        <img src="<%=path%>/images/lhp_logo_02.jpg" align="absmiddle" alt="xxxxxxxx业务技术平台" />
        </span>
    </div>
    
    <style>
    .top-bar { position: absolute; width: 100%; height: 22px; top: 0; left: 0; }
	.top-bar-left { position: absolute; width: 500px; height: 22px; }
	.top-bar-right { position: absolute; width: 400px; height: 22px; right: 0; }
	.top-bar-right #timerSpan { position: absolute; padding-top: 5px; right: 10px; }
	.top-bar-right #periodSpan { position: absolute; padding-top: 5px; right: 10px; }
	.top-bar-right #themeSpan { position: absolute; width: 350px; top: 24px; right: 5px; text-align: right; }
	
	.top-toolbar { position: absolute; font-weight: normal; padding: 0; width: 100%; height: 28px; top: 60px; left: 0; border-top-width: 1px; border-bottom-width: 0; z-index: 100; }
	.top-toolbar-topmost { top: 0px; height: 27px; border-top-width: 0px; border-bottom-width: 1px; }
	.top-toolbar #infobar { position: absolute; height: 26px; line-height: 26px; left: 10px; }
	.top-toolbar #searchbar { position: absolute; height: 26px; left: 400px; padding-top: 1px; }
	.top-toolbar #buttonbar { position: absolute; height: 26px; right: 5px; padding-top: 1px; text-align: right; }
	</style>
    
     	<div id="toolbar" class="panel-header panel-header-noborder top-toolbar">
                <div id="infobar">
                    <span class="icon-cologne-customers" style="padding-left: 25px; background-position: left ;float:left;">
                        	&nbsp;欢迎登录:&nbsp;${name}
                    
                    </span>
                    <div id="periodSpan" style="float:left;margin-left:18px;">
                    	当前培训期号:<font color="red">${period.number }</font>
                    	<a href="javascript:openPeriod();" class="easyui-linkbutton" iconCls="icon-cologne-milestone" plain="true">切换</a>
                    </div>
                	<div id="timerSpan" style="float:left;margin-left:18px;"></div>
                </div>
                
            </div>
    

<!--  -->
        <div region="south" split="true" style="height:40px;overflow:hidden; background: #D2E0F2; ">
        <div class="footer"  style="height: 40px;line-height: 30px; background: #D2E0F2; ">Copyright © 2014 xxxxxxx有限公司 电话:0797-xxxxxxxxxxxxxxx</div>
    </div>
    
    <div region="west" hide="true" split="true" title="&nbsp;" style="width:220px;" id="west">
	<div id="nav" class="easyui-accordion" fit="true" border="false">
		<!--  导航内容 --> 
				
			</div>

    </div>
    
    <div id="mainPanle" region="center" style="background: #eee; overflow-y:hidden">
        <div id="tabs" class="easyui-tabs"  fit="true" border="false" >
        <!-- 
			<div title="系统首页" style="padding:20px;overflow:hidden; color:red; " >
			</div>
			 -->
		</div>
    </div>

	<div id="mm" class="easyui-menu" style="width:150px;">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>

</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄宝康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值