123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
- <%@include file="/WEB-INF/commons/commonInclude.jsp" %>
- <script>
- // 设置jQuery Ajax全局的参数
- $.ajaxSetup({
- type: "POST",
- error: function(jqXHR, textStatus, errorThrown){
- isLogin();
- switch (jqXHR.status){
- case(500):
- $.ligerDialog.error("服务器系统内部错误");
- break;
- case(401):
- $.ligerDialog.error("未登录");
- break;
- case(403):
- $.ligerDialog.error("无权限执行此操作");
- break;
- case(408):
- $.ligerDialog.error("请求超时");
- break;
- default:
- $.ligerDialog.error("未知错误");
- }
- }
- });
- //判断是否登录
- function isLogin(){
- $.ajax({ //获取是否
- type: "POST",
- url : "${contextRoot}/system/isLogin",
- dataType : "json",
- cache:false,
- success :function(data){
- if(!data.successFlg) {
- location.href = "${contextRoot}/loginPage";
- }
- },
- error :function(data){
- location.href = "${contextRoot}/loginPage";
- }
- });
- }
- var indexPage = {
- localNav:[],
- init:function(){
- var me = this;
- //主布局
- $("#divIndexMain").ligerLayout({
- space:0,
- topHeight:120,
- leftWidth:220,
- allowLeftCollapse:false,
- allowLeftResize:false,
- allowTopResize:false
- });
- $(".l-layout-left").css({background:"#dce6f0"})
- //菜单列表
- var menu = [
- {id: 1, text: '数据源配置',icon:'${staticRoot}/images/index/menu1_icon.png', url: '${contextRoot}/system/dataSource'},
- {id: 2, text: '采集标准',icon:'${staticRoot}/images/index/menu2_icon.png', url: '${contextRoot}/datacollect/stdManager'},
- {id: 3, text: '任务跟踪',icon:'${staticRoot}/images/index/menu3_icon.png', url: '${contextRoot}/datacollect/trackJob'},
- {id: 4, text: '任务补采',icon:'${staticRoot}/images/index/menu4_icon.png', url: '${contextRoot}/datacollect/repeatJob'},
- {id: 5, text: '系统参数',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/system/paramManager'}
- ];
- me.menuTree = $('#ulTree').ligerTree({
- data: menu,
- idFieldName: 'id',
- parentIDFieldName: 'pid',
- checkbox: false,
- treeLine: false,
- autoCheckboxEven: false,
- needCancel: false,
- btnClickToToggleOnly: false,
- slide: false,
- nodeDraggable: false,
- isExpand: false,
- childIcon:true,
- nodeWidth:176,
- onSelect: function (obj) {
- if(obj.data.url!=undefined)
- {
- me.openMenu(obj);
- }
- }
- });
- $('#btnIndexLogout').click(function(){
- $.ligerDialog.confirm('是否确认退出!', function (yes)
- {
- if(yes)
- {
- $.ajax({ //获取表的字段列表
- type: "POST",
- url : "${contextRoot}/system/logoutAction",
- dataType : "json",
- cache:false,
- success :function(data){
- if(data.successFlg) {
- location.href = "${contextRoot}/loginPage";
- }
- else{
- $.ligerDialog.error(data.message);
- }
- },
- error :function(data){
- location.href = "${contextRoot}/loginPage";
- }
- });
- }
- });
- });
- //打开默认菜单
- me.openMenuByText("数据源配置");
- },
- //加载中
- loading:function(){
- $('#divIndexContent').html("loading...");
- },
- //刷新当前位置栏
- localRender:function(){
- try {
- var me = this;
- var html = "";
- if (me.localNav.length > 0) {
- for (var i = 0; i < me.localNav.length; i++) {
- var text = me.localNav[i].text;
- var url = me.localNav[i].url;
- if (i == me.localNav.length - 1) //最后一个节点
- {
- html += text;
- }
- else {
- html += "<a class='localNavBtn' href='javascripr:void(0)' url='" + url + "' onclick='indexPage.openMenu()'>" + text + "</a> > ";
- }
- }
- }
- $('#indexNav').html(html);
- }
- catch(e)
- {
- return;
- }
- },
- //打开菜单(暂不考虑多级菜单)
- openMenu:function(obj){
- try {
- var me = this;
- var id = obj.data.id;
- var text = obj.data.text;
- var url = obj.data.url;
- me.localNav = [];
- me.localNav.push({id: id, text: text, url: url});
- //父亲节点
- me.localRender();
- if (obj.data.targetType == "1") {
- me.loadIframePage(url);
- }
- else if (obj.data.targetType == "2") {
- window.open(url);
- }
- else {
- me.loadPage(url);
- }
- }
- catch(e)
- {
- return;
- }
- },
- //打开子功能页面
- openChildPage:function(text,url,targetType,data,fun){
- try {
- var me = this;
- me.localNav.push({text: text, url: url, data: data, fun: fun});
- me.localRender();
- if (targetType == "1") {
- me.loadIframePage(url, data, fun);
- }
- else if (targetType == "2") {
- window.open(url);
- }
- else {
- me.loadPage(url, data, fun);
- }
- }
- catch(e)
- {
- return;
- }
- },
- //加载页面
- loadPage:function(url,data,fun){
- try {
- var me = this;
- me.loading();
- var div = $("<div class='m-index-content'></div>").load(url, data, function () {
- if (fun != undefined && typeof fun == 'function') {
- fun();
- }
- });
- $('#divIndexContent').html(div);
- }
- catch(e)
- {
- return;
- }
- },
- //加载iframe页面
- loadIframePage:function(url,data,fun){
- try {
- var me = this;
- $('#divIndexContent').html("<iframe style='height:98%;width:100%' frameborder='0' src='" + url + "' allowTransparency='true'></iframe>");
- }
- catch(e)
- {
- return;
- }
- },
- //通过text打开菜单
- openMenuByText:function(text){
- try {
- var me = this;
- me.menuTree.queryByText(text);
- }
- catch(e)
- {
- return;
- }
- },
- //刷新当前页面
- refresh:function(){
- try {
- var me = this;
- if (me.localNav.length > 0) {
- var text = me.localNav[me.localNav.length - 1].text;
- me.openMenuByText(text);
- }
- }
- catch(e)
- {
- return;
- }
- }
- }
- $(function () {
- isLogin();
- indexPage.init();
- });
- </script>
|