indexJs.jsp 17 KB

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