indexJs.jsp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
  2. <%@include file="/WEB-INF/commons/commonInclude.jsp" %>
  3. <script>
  4. // 设置jQuery Ajax全局的参数
  5. $.ajaxSetup({
  6. type: "POST",
  7. error: function(jqXHR, textStatus, errorThrown){
  8. isLogin();
  9. switch (jqXHR.status){
  10. case(500):
  11. $.ligerDialog.error("服务器系统内部错误");
  12. break;
  13. case(401):
  14. $.ligerDialog.error("未登录");
  15. break;
  16. case(403):
  17. $.ligerDialog.error("无权限执行此操作");
  18. break;
  19. case(408):
  20. $.ligerDialog.error("请求超时");
  21. break;
  22. default:
  23. $.ligerDialog.error("未知错误");
  24. }
  25. }
  26. });
  27. //判断是否登录
  28. function isLogin(){
  29. $.ajax({ //获取是否
  30. type: "POST",
  31. url : "${contextRoot}/system/isLogin",
  32. dataType : "json",
  33. cache:false,
  34. success :function(data){
  35. if(!data.successFlg) {
  36. location.href = "${contextRoot}/loginPage";
  37. }
  38. },
  39. error :function(data){
  40. location.href = "${contextRoot}/loginPage";
  41. }
  42. });
  43. }
  44. var indexPage = {
  45. localNav:[],
  46. init:function(){
  47. var me = this;
  48. //主布局
  49. $("#divIndexMain").ligerLayout({
  50. space:0,
  51. topHeight:120,
  52. leftWidth:220,
  53. allowLeftCollapse:false,
  54. allowLeftResize:false,
  55. allowTopResize:false
  56. });
  57. $(".l-layout-left").css({background:"#dce6f0"})
  58. //菜单列表
  59. var menu = [
  60. {id: 1, text: '数据源配置',icon:'${staticRoot}/images/index/menu1_icon.png', url: '${contextRoot}/system/dataSource'},
  61. {id: 2, text: '采集标准',icon:'${staticRoot}/images/index/menu2_icon.png', url: '${contextRoot}/datacollect/stdManager'},
  62. {id: 3, text: '任务跟踪',icon:'${staticRoot}/images/index/menu3_icon.png', url: '${contextRoot}/datacollect/trackJob'},
  63. {id: 4, text: '任务补采',icon:'${staticRoot}/images/index/menu4_icon.png', url: '${contextRoot}/datacollect/repeatJob'},
  64. {id: 5, text: '系统参数',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/system/paramManager'}
  65. ];
  66. me.menuTree = $('#ulTree').ligerTree({
  67. data: menu,
  68. idFieldName: 'id',
  69. parentIDFieldName: 'pid',
  70. checkbox: false,
  71. treeLine: false,
  72. autoCheckboxEven: false,
  73. needCancel: false,
  74. btnClickToToggleOnly: false,
  75. slide: false,
  76. nodeDraggable: false,
  77. isExpand: false,
  78. childIcon:true,
  79. nodeWidth:176,
  80. onSelect: function (obj) {
  81. if(obj.data.url!=undefined)
  82. {
  83. me.openMenu(obj);
  84. }
  85. }
  86. });
  87. $('#btnIndexLogout').click(function(){
  88. $.ligerDialog.confirm('是否确认退出!', function (yes)
  89. {
  90. if(yes)
  91. {
  92. $.ajax({ //获取表的字段列表
  93. type: "POST",
  94. url : "${contextRoot}/system/logoutAction",
  95. dataType : "json",
  96. cache:false,
  97. success :function(data){
  98. if(data.successFlg) {
  99. location.href = "${contextRoot}/loginPage";
  100. }
  101. else{
  102. $.ligerDialog.error(data.message);
  103. }
  104. },
  105. error :function(data){
  106. location.href = "${contextRoot}/loginPage";
  107. }
  108. });
  109. }
  110. });
  111. });
  112. //打开默认菜单
  113. me.openMenuByText("数据源配置");
  114. },
  115. //加载中
  116. loading:function(){
  117. $('#divIndexContent').html("loading...");
  118. },
  119. //刷新当前位置栏
  120. localRender:function(){
  121. try {
  122. var me = this;
  123. var html = "";
  124. if (me.localNav.length > 0) {
  125. for (var i = 0; i < me.localNav.length; i++) {
  126. var text = me.localNav[i].text;
  127. var url = me.localNav[i].url;
  128. if (i == me.localNav.length - 1) //最后一个节点
  129. {
  130. html += text;
  131. }
  132. else {
  133. html += "<a class='localNavBtn' href='javascripr:void(0)' url='" + url + "' onclick='indexPage.openMenu()'>" + text + "</a>&nbsp;>&nbsp;";
  134. }
  135. }
  136. }
  137. $('#indexNav').html(html);
  138. }
  139. catch(e)
  140. {
  141. return;
  142. }
  143. },
  144. //打开菜单(暂不考虑多级菜单)
  145. openMenu:function(obj){
  146. try {
  147. var me = this;
  148. var id = obj.data.id;
  149. var text = obj.data.text;
  150. var url = obj.data.url;
  151. me.localNav = [];
  152. me.localNav.push({id: id, text: text, url: url});
  153. //父亲节点
  154. me.localRender();
  155. if (obj.data.targetType == "1") {
  156. me.loadIframePage(url);
  157. }
  158. else if (obj.data.targetType == "2") {
  159. window.open(url);
  160. }
  161. else {
  162. me.loadPage(url);
  163. }
  164. }
  165. catch(e)
  166. {
  167. return;
  168. }
  169. },
  170. //打开子功能页面
  171. openChildPage:function(text,url,targetType,data,fun){
  172. try {
  173. var me = this;
  174. me.localNav.push({text: text, url: url, data: data, fun: fun});
  175. me.localRender();
  176. if (targetType == "1") {
  177. me.loadIframePage(url, data, fun);
  178. }
  179. else if (targetType == "2") {
  180. window.open(url);
  181. }
  182. else {
  183. me.loadPage(url, data, fun);
  184. }
  185. }
  186. catch(e)
  187. {
  188. return;
  189. }
  190. },
  191. //加载页面
  192. loadPage:function(url,data,fun){
  193. try {
  194. var me = this;
  195. me.loading();
  196. var div = $("<div class='m-index-content'></div>").load(url, data, function () {
  197. if (fun != undefined && typeof fun == 'function') {
  198. fun();
  199. }
  200. });
  201. $('#divIndexContent').html(div);
  202. }
  203. catch(e)
  204. {
  205. return;
  206. }
  207. },
  208. //加载iframe页面
  209. loadIframePage:function(url,data,fun){
  210. try {
  211. var me = this;
  212. $('#divIndexContent').html("<iframe style='height:98%;width:100%' frameborder='0' src='" + url + "' allowTransparency='true'></iframe>");
  213. }
  214. catch(e)
  215. {
  216. return;
  217. }
  218. },
  219. //通过text打开菜单
  220. openMenuByText:function(text){
  221. try {
  222. var me = this;
  223. me.menuTree.queryByText(text);
  224. }
  225. catch(e)
  226. {
  227. return;
  228. }
  229. },
  230. //刷新当前页面
  231. refresh:function(){
  232. try {
  233. var me = this;
  234. if (me.localNav.length > 0) {
  235. var text = me.localNav[me.localNav.length - 1].text;
  236. me.openMenuByText(text);
  237. }
  238. }
  239. catch(e)
  240. {
  241. return;
  242. }
  243. }
  244. }
  245. $(function () {
  246. isLogin();
  247. indexPage.init();
  248. });
  249. </script>