indexJs.jsp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. {id: 6, text: '接口配置',icon:'${staticRoot}/images/index/menu5_icon.png', url: '${contextRoot}/dataAcquisition/dataAcquisitionManager'}
  66. ];
  67. me.menuTree = $('#ulTree').ligerTree({
  68. data: menu,
  69. idFieldName: 'id',
  70. parentIDFieldName: 'pid',
  71. checkbox: false,
  72. treeLine: false,
  73. autoCheckboxEven: false,
  74. needCancel: false,
  75. btnClickToToggleOnly: false,
  76. slide: false,
  77. nodeDraggable: false,
  78. isExpand: false,
  79. childIcon:true,
  80. nodeWidth:176,
  81. onSelect: function (obj) {
  82. if(obj.data.url!=undefined)
  83. {
  84. me.openMenu(obj);
  85. }
  86. }
  87. });
  88. $('#btnIndexLogout').click(function(){
  89. $.ligerDialog.confirm('是否确认退出!', function (yes)
  90. {
  91. if(yes)
  92. {
  93. $.ajax({ //获取表的字段列表
  94. type: "POST",
  95. url : "${contextRoot}/system/logoutAction",
  96. dataType : "json",
  97. cache:false,
  98. success :function(data){
  99. if(data.successFlg) {
  100. location.href = "${contextRoot}/loginPage";
  101. }
  102. else{
  103. $.ligerDialog.error(data.message);
  104. }
  105. },
  106. error :function(data){
  107. location.href = "${contextRoot}/loginPage";
  108. }
  109. });
  110. }
  111. });
  112. });
  113. //打开默认菜单
  114. me.openMenuByText("数据源配置");
  115. },
  116. //加载中
  117. loading:function(){
  118. $('#divIndexContent').html("loading...");
  119. },
  120. //刷新当前位置栏
  121. localRender:function(){
  122. try {
  123. var me = this;
  124. var html = "";
  125. if (me.localNav.length > 0) {
  126. for (var i = 0; i < me.localNav.length; i++) {
  127. var text = me.localNav[i].text;
  128. var url = me.localNav[i].url;
  129. if (i == me.localNav.length - 1) //最后一个节点
  130. {
  131. html += text;
  132. }
  133. else {
  134. html += "<a class='localNavBtn' href='javascripr:void(0)' url='" + url + "' onclick='indexPage.openMenu()'>" + text + "</a>&nbsp;>&nbsp;";
  135. }
  136. }
  137. }
  138. $('#indexNav').html(html);
  139. }
  140. catch(e)
  141. {
  142. return;
  143. }
  144. },
  145. //打开菜单(暂不考虑多级菜单)
  146. openMenu:function(obj){
  147. try {
  148. var me = this;
  149. var id = obj.data.id;
  150. var text = obj.data.text;
  151. var url = obj.data.url;
  152. me.localNav = [];
  153. me.localNav.push({id: id, text: text, url: url});
  154. //父亲节点
  155. me.localRender();
  156. if (obj.data.targetType == "1") {
  157. me.loadIframePage(url);
  158. }
  159. else if (obj.data.targetType == "2") {
  160. window.open(url);
  161. }
  162. else {
  163. me.loadPage(url);
  164. }
  165. }
  166. catch(e)
  167. {
  168. return;
  169. }
  170. },
  171. //打开子功能页面
  172. openChildPage:function(text,url,targetType,data,fun){
  173. try {
  174. var me = this;
  175. me.localNav.push({text: text, url: url, data: data, fun: fun});
  176. me.localRender();
  177. if (targetType == "1") {
  178. me.loadIframePage(url, data, fun);
  179. }
  180. else if (targetType == "2") {
  181. window.open(url);
  182. }
  183. else {
  184. me.loadPage(url, data, fun);
  185. }
  186. }
  187. catch(e)
  188. {
  189. return;
  190. }
  191. },
  192. //加载页面
  193. loadPage:function(url,data,fun){
  194. try {
  195. var me = this;
  196. me.loading();
  197. var div = $("<div class='m-index-content'></div>").load(url, data, function () {
  198. if (fun != undefined && typeof fun == 'function') {
  199. fun();
  200. }
  201. });
  202. $('#divIndexContent').html(div);
  203. }
  204. catch(e)
  205. {
  206. return;
  207. }
  208. },
  209. //加载iframe页面
  210. loadIframePage:function(url,data,fun){
  211. try {
  212. var me = this;
  213. $('#divIndexContent').html("<iframe style='height:98%;width:100%' frameborder='0' src='" + url + "' allowTransparency='true'></iframe>");
  214. }
  215. catch(e)
  216. {
  217. return;
  218. }
  219. },
  220. //通过text打开菜单
  221. openMenuByText:function(text){
  222. try {
  223. var me = this;
  224. me.menuTree.queryByText(text);
  225. }
  226. catch(e)
  227. {
  228. return;
  229. }
  230. },
  231. //刷新当前页面
  232. refresh:function(){
  233. try {
  234. var me = this;
  235. if (me.localNav.length > 0) {
  236. var text = me.localNav[me.localNav.length - 1].text;
  237. me.openMenuByText(text);
  238. }
  239. }
  240. catch(e)
  241. {
  242. return;
  243. }
  244. }
  245. }
  246. $(function () {
  247. isLogin();
  248. indexPage.init();
  249. });
  250. </script>