indexJs.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/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. homeUrl:"${contextRoot}/homePage",
  47. init:function(){
  48. var me = this;
  49. //主布局
  50. $("#divIndexMain").ligerLayout({
  51. space:0,
  52. topHeight:120,
  53. leftWidth:220,
  54. allowLeftCollapse:false,
  55. allowLeftResize:false,
  56. allowTopResize:false
  57. });
  58. $(".l-layout-left").css({background:"#dce6f0"})
  59. //菜单列表
  60. var menu = [
  61. //任务管理
  62. {id: 1, text: '任务管理',icon:'${staticRoot}/images/index/menu2_icon.png'},
  63. {id: 11, pid: 1, text: '任务跟踪', url: '${contextRoot}/datacollect/trackJob',targetType:'1'},
  64. {id: 12, pid: 1, text: '任务补采', url: '${contextRoot}/datacollect/repeatDatacollect'},
  65. {id: 13, pid: 1, text: '任务配置', url: '${contextRoot}/datacollect/configJob'},
  66. {id: 14, pid: 1, text: '任务编排', url: '${contextRoot}/crawler/jobLayout'},
  67. //标准管理
  68. //标准规范中心
  69. {id: 2, text: '标准管理',icon:'${staticRoot}/images/index/menu3_icon.png'},
  70. {id: 21, pid: 2, text: '集成标准', url: '${contextRoot}/integration/initial/standard'},
  71. {id: 22, pid: 2, text: '应用标准', url: '${contextRoot}/integration/initial/application'},
  72. {id: 23, pid: 2, text: '适配方案', url: '${contextRoot}/adapterPlan/initial'},
  73. //资源管理
  74. {id: 3, text: '资源管理',icon:'${staticRoot}/images/index/menu4_icon.png'},
  75. {id: 31, pid: 3, text: '资源注册', url: '${contextRoot}/resource/resource/initial'},
  76. {id: 32, pid: 3, text: '资源浏览', url: '${contextRoot}/resource/resourcePage'},
  77. {id: 34, pid: 3, text: '资源分类', url: '${contextRoot}/resource/rsCategory/initial'},
  78. {id: 35, pid: 3, text: '业务资源', url: '${contextRoot}/resourceRest/initial'},
  79. //维度管理
  80. {id: 4, text: '维度管理',icon:'${staticRoot}/images/index/menu5_icon.png'},
  81. {id: 41, pid: 4, text: '维度配置', url: '${contextRoot}/dimension/dimension'},
  82. {id: 42, pid: 4, text: '维度类别配置', url: '${contextRoot}/dimension/dimensioncatetory'},
  83. //系统配置
  84. {id: 9, text: '系统配置',icon:'${staticRoot}/images/index/menu6_icon.png'},
  85. {id: 91, pid: 9, text: '机构配置', url: '${contextRoot}/org/initial'},
  86. {id: 92, pid: 9, text: '数据源配置', url: '${contextRoot}/datasource/configSources'},
  87. {id: 93, pid: 9, text: '菜单配置', url: '${contextRoot}/menu/initial'},
  88. {id: 100, pid: 9, text: '菜单按钮配置', url: '${contextRoot}/menu/menuAction/initial'},
  89. {id: 94, pid: 9, text: '用户管理', url: '${contextRoot}/user/initial'},
  90. {id: 95, pid: 9, text: '角色管理', url: '${contextRoot}/role/initial'},
  91. {id: 96, pid: 9, text: '权限管理', url: '${contextRoot}/authority/initial'},
  92. {id: 97, pid: 9, text: '字典管理', url: '${contextRoot}/dict/initial' },
  93. {id: 98, pid: 9, text: '系统参数', url: '${contextRoot}/param/initial'},
  94. {id: 99, pid: 9, text: '<spring:message code="title.app.manage"/>', url: '${contextRoot}/app/initial'}
  95. ];
  96. me.menuTree = $('#ulTree').ligerTree({
  97. data: menu,
  98. idFieldName: 'id',
  99. parentIDFieldName: 'pid',
  100. checkbox: false,
  101. treeLine: false,
  102. autoCheckboxEven: false,
  103. needCancel: false,
  104. btnClickToToggleOnly: false,
  105. slide: false,
  106. nodeDraggable: false,
  107. isExpand: false,
  108. parentIcon:true,
  109. nodeWidth:176,
  110. onSelect: function (obj) {
  111. if(obj.data.url!=undefined)
  112. {
  113. me.openMenu(obj);
  114. }
  115. },
  116. //一级节点不可选中
  117. onAfterAppend:function(){
  118. $.each($("#ulTree li[outlinelevel='1']"),function(index,item){
  119. $(item).addClass("l-unselectable");
  120. });
  121. }
  122. });
  123. //首页按钮
  124. $('#btnIndexHome').bind('click',function(){
  125. me.openHome();
  126. });
  127. //退出按钮
  128. $('#btnIndexLogout').click(function(){
  129. $.ligerDialog.confirm('是否确认退出!', function (yes)
  130. {
  131. if(yes)
  132. {
  133. $.ajax({ //获取表的字段列表
  134. type: "POST",
  135. url : "${contextRoot}/system/logoutAction",
  136. dataType : "json",
  137. cache:false,
  138. success :function(data){
  139. if(data.successFlg) {
  140. location.href = "${contextRoot}/loginPage";
  141. }
  142. else{
  143. $.ligerDialog.error(data.message);
  144. }
  145. },
  146. error :function(data){
  147. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  148. }
  149. });
  150. }
  151. });
  152. });
  153. $('#btnIndexPassword').click(function(){
  154. me.dialog= $.ligerDialog.open({
  155. height: 300,
  156. width: 600,
  157. title: "修改密码",
  158. url: '${contextRoot}/user/renewPassword',
  159. });
  160. });
  161. //me.openHome();
  162. //打开默认菜单
  163. me.openMenuByText("任务跟踪");
  164. },
  165. //加载中
  166. loading:function(){
  167. $('#divIndexContent').html("loading...");
  168. },
  169. //首页按钮选择/取消
  170. clickHomeBtn:function(isClick){
  171. try {
  172. var btn = $("#btnIndexHome");
  173. if (!isClick) {
  174. btn.removeClass('m-index-menu-top-over');
  175. }
  176. else {
  177. btn.addClass('m-index-menu-top-over');
  178. }
  179. }
  180. catch(e)
  181. {
  182. return;
  183. }
  184. },
  185. //打开首页
  186. openHome:function(){
  187. try {
  188. var me = this;
  189. me.localNav = [];
  190. me.localNav.push({text: "主页", url: me.homeUrl});
  191. me.localRender();
  192. me.clickHomeBtn(true);
  193. //取消菜单选中
  194. $('#ulTree .l-body.l-selected').removeClass("l-selected");
  195. me.loading();
  196. $('#divIndexContent').load(me.homeUrl);
  197. }
  198. catch(e)
  199. {
  200. return;
  201. }
  202. },
  203. //刷新当前位置栏
  204. localRender:function(){
  205. try {
  206. var me = this;
  207. var html = "";
  208. if (me.localNav.length > 0) {
  209. for (var i = 0; i < me.localNav.length; i++) {
  210. var text = me.localNav[i].text;
  211. var url = me.localNav[i].url;
  212. if (i == me.localNav.length - 1) //最后一个节点
  213. {
  214. html += text;
  215. }
  216. else {// html += "<a class='localNavBtn' href='javascripr:void(0)' url='"+url+"' onclick='indexPage.openMenu()'>"+text + "</a>&nbsp;>&nbsp;";
  217. html += "<a class='localNavBtn' href='javascripr:void(0)' url='" + url + "' onclick='indexPage.openMenu()'>" + text + "</a>";
  218. }
  219. }
  220. }
  221. $('#indexNav').html(html);
  222. }
  223. catch(e)
  224. {
  225. return;
  226. }
  227. },
  228. //打开菜单(暂不考虑多级菜单)
  229. openMenu:function(obj){
  230. try {
  231. var me = this;
  232. var id = obj.data.id;
  233. var text = obj.data.text;
  234. var url = obj.data.url;
  235. me.localNav = [];
  236. me.localNav.push({id: id, text: text, url: url});
  237. //父亲节点
  238. me.localRender();
  239. me.clickHomeBtn(false);
  240. if (obj.data.targetType == "1") {
  241. me.loadIframePage(url);
  242. }
  243. else if (obj.data.targetType == "2") {
  244. window.open(url);
  245. }
  246. else {
  247. me.loadPage(url);
  248. }
  249. }
  250. catch(e)
  251. {
  252. return;
  253. }
  254. },
  255. //弹窗返回
  256. dialogSuccess:function(message){
  257. this.dialog.close();
  258. $.ligerDialog.success(message);
  259. },
  260. //打开子功能页面
  261. openChildPage:function(text,url,targetType,data,fun){
  262. try {
  263. var me = this;
  264. me.localNav.push({text: text, url: url, data: data, fun: fun});
  265. me.localRender();
  266. if (targetType == "1") {
  267. me.loadIframePage(url, data, fun);
  268. }
  269. else if (targetType == "2") {
  270. window.open(url);
  271. }
  272. else {
  273. me.loadPage(url, data, fun);
  274. }
  275. }
  276. catch(e)
  277. {
  278. return;
  279. }
  280. },
  281. //加载页面
  282. loadPage:function(url,data,fun){
  283. try {
  284. var me = this;
  285. me.loading();
  286. var div = $("<div class='m-index-content'></div>").load(url, data, function () {
  287. if (fun != undefined && typeof fun == 'function') {
  288. fun();
  289. }
  290. });
  291. $('#divIndexContent').html(div);
  292. }
  293. catch(e)
  294. {
  295. return;
  296. }
  297. },
  298. //加载iframe页面
  299. loadIframePage:function(url,data,fun){
  300. try {
  301. var me = this;
  302. $('#divIndexContent').html("<iframe style='height:98%;width:100%' frameborder='0' src='" + url + "' allowTransparency='true'></iframe>");
  303. }
  304. catch(e)
  305. {
  306. return;
  307. }
  308. },
  309. //通过text打开菜单
  310. openMenuByText:function(text,params,select){
  311. try {
  312. var me = this;
  313. if(select==false) {
  314. var nodeText = $("span", me.menuTree.tree);
  315. var url = "";
  316. $.each($("div[class='l-body l-selected']", me.menuTree.tree),function(){
  317. $(this).removeClass("l-selected");
  318. });
  319. debugger
  320. for (var i = 0; i < nodeText.length; i++) {
  321. if ($(nodeText[i]).text().indexOf(text) >= 0) {
  322. var id = $(nodeText[i]).closest("li").attr("id");
  323. url = $(nodeText[i]).closest("li").attr("url");
  324. me.menuTree.expandNode(id);
  325. $(nodeText[i]).closest("li").find("div[class='l-body']").addClass("l-selected");
  326. break;
  327. }
  328. }
  329. //当前位置栏
  330. me.localNav = [];
  331. me.localNav.push({id: id, text: text, url: url});
  332. me.localRender();
  333. me.clickHomeBtn(false);
  334. //打开页面
  335. me.loadPage(url,params);
  336. }
  337. else{
  338. //选择节点
  339. me.menuTree.queryByText(text,select);
  340. }
  341. }
  342. catch(e)
  343. {
  344. return;
  345. }
  346. },
  347. //刷新当前页面
  348. refresh:function(){
  349. try {
  350. var me = this;
  351. if (me.localNav.length > 0) {
  352. var text = me.localNav[me.localNav.length - 1].text;
  353. me.openMenuByText(text);
  354. }
  355. }
  356. catch(e)
  357. {
  358. return;
  359. }
  360. }
  361. }
  362. $(function () {
  363. isLogin();
  364. indexPage.init();
  365. });
  366. </script>