dictionaryTree.jsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="com.hotent.platform.model.system.GlobalType"%>
  2. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  3. <%@taglib prefix="f" uri="http://www.jee-soft.cn/functions" %>
  4. <c:set var="ctx" value="${pageContext.request.contextPath}" />
  5. <%@include file="/commons/include/html_doctype.html" %>
  6. <html>
  7. <head>
  8. <title>数据字典</title>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  10. <%@include file="/commons/include/form.jsp" %>
  11. <f:link href="Aqua/css/ligerui-all.css"></f:link>
  12. <f:link href="tree/zTreeStyle.css"></f:link>
  13. <f:link href="web.css" ></f:link>
  14. <script type="text/javascript" src="${ctx}/js/tree/jquery.ztree.js"></script>
  15. <script type="text/javascript" src="${ctx}/js/tree/jquery.ztree.js"></script>
  16. <script type="text/javascript" src="${ctx}/js/hotent/platform/form/GlobalType.js"></script>
  17. <script type="text/javascript" src="${ctx}/js/hotent/platform/system/GlobalMenu.js"></script>
  18. <script type="text/javascript">
  19. var catKey="<%=GlobalType.CAT_DIC%>";
  20. var menuMenu;
  21. var dictTree;
  22. var dicMenu=new DicMenu();
  23. var curMenu;
  24. var selectDictionaryId=0;
  25. var globalType=new GlobalType(catKey,"glTypeTree",
  26. {
  27. onClick:zTreeOnLeftClick,
  28. onRightClick:catRightClick,
  29. expandByDepth:0
  30. }
  31. );
  32. $(function(){
  33. layout();
  34. globalType.loadGlobalTree();
  35. });
  36. //布局
  37. function layout(){
  38. $("#layout").ligerLayout( {leftWidth : 210,height: '100%', onHeightChanged: heightChanged});
  39. //取得layout的高度
  40. var height = $(".l-layout-center").height();
  41. $("#glTypeTree").height(height-60);
  42. };
  43. //布局大小改变的时候通知tab,面板改变大小
  44. function heightChanged(options){
  45. //$("#glTypeTree").height(options.middleHeight - 60);
  46. };
  47. function hiddenMenu(){
  48. if(curMenu){
  49. curMenu.hide();
  50. }
  51. if(menuMenu){
  52. menuMenu.hide();
  53. }
  54. }
  55. function handler(item){
  56. hiddenMenu();
  57. var txt=item.text;
  58. switch(txt){
  59. case "增加字典分类":
  60. globalType.openGlobalTypeDlg(true);
  61. break;
  62. case "编辑分类":
  63. globalType.openGlobalTypeDlg(false);
  64. break;
  65. case "排序":
  66. globalType.sortNode();
  67. break;
  68. case "删除":
  69. globalType.delNode();
  70. break;
  71. }
  72. }
  73. /**
  74. * 树右击事件
  75. */
  76. function catRightClick(event, treeId, treeNode) {
  77. hiddenMenu();
  78. if (treeNode) {
  79. globalType.currentNode=treeNode;
  80. globalType.glTypeTree.selectNode(treeNode);
  81. curMenu=dicMenu.getMenu(treeNode, handler);
  82. if(curMenu){
  83. justifyRightClickPosition(event);
  84. curMenu.show({ top: event.pageY, left: event.pageX });
  85. }
  86. }
  87. };
  88. //左击
  89. function zTreeOnLeftClick(treeNode){
  90. if(treeNode.isRoot==undefined){
  91. loadDictByTypeId();
  92. }
  93. };
  94. //展开收起
  95. function treeExpandAll(type){
  96. globalType.treeExpandAll(type);
  97. };
  98. /**
  99. *获取选择的节点。
  100. */
  101. function getSelectNode(){
  102. dictTree = $.fn.zTree.getZTreeObj("dictTree");
  103. var nodes = dictTree.getSelectedNodes();
  104. if(nodes){
  105. selectDictionaryId=nodes[0].dicId;
  106. return nodes[0];
  107. }
  108. return null;
  109. }
  110. //加载数据字典
  111. function loadDictByTypeId(){
  112. var selectNode=globalType.currentNode;
  113. if(!selectNode){
  114. $.ligerDialog.warn('没有选择节点');
  115. return;
  116. }
  117. var dropInner=selectNode.type==1;
  118. var typeId=selectNode.typeId;
  119. var setting = {
  120. edit: {
  121. drag: {
  122. prev: true,
  123. inner: dropInner,
  124. next: true,
  125. isMove:true
  126. },
  127. enable: true,
  128. showRemoveBtn: false,
  129. showRenameBtn: false
  130. },
  131. data: {
  132. key : {name: "itemName"},
  133. simpleData: {enable: true,idKey: "dicId",pIdKey: "parentId"}
  134. },
  135. view: {selectedMulti: false},
  136. callback:{onRightClick: dictRightClick,
  137. onDrop: onDrop,beforeDrop:onBeforeDrop }
  138. };
  139. var url="${ctx}/platform/system/dictionary/getByTypeId.ht";
  140. var params={typeId:typeId};
  141. $.post(url,params,function(result){
  142. updDicRootNode(result);
  143. dictTree=$.fn.zTree.init($("#dictTree"), setting,result);
  144. var expandDepth = 0;
  145. if(expandDepth!=0)
  146. {
  147. dictTree.expandAll(false);
  148. var nodes = dictTree.getNodesByFilter(function(node){
  149. return (node.level < expandDepth);
  150. });
  151. if(nodes.length>0){
  152. for(var i=0;i<nodes.length;i++){
  153. dictTree.expandNode(nodes[i],true,false);
  154. }
  155. }
  156. }
  157. if(selectDictionaryId>0){
  158. var node = dictTree.getNodeByParam("dicId", selectDictionaryId, null);
  159. dictTree.selectNode(node);
  160. }
  161. });
  162. }
  163. function onBeforeDrop(treeId, treeNodes, targetNode, moveType){
  164. if(targetNode.isRoot==1 && moveType!="inner"){
  165. return false;
  166. }
  167. return true;
  168. }
  169. function onDrop(event, treeId, treeNodes, targetNode, moveType) {
  170. if(targetNode==null || targetNode==undefined) return false;
  171. var targetId=targetNode.dicId;
  172. var dragId=treeNodes[0].dicId;
  173. var url=__ctx + "/platform/system/dictionary/move.ht";
  174. var params={targetId:targetId,dragId:dragId,moveType:moveType};
  175. $.post(url,params,function(result){});
  176. }
  177. //标记根节点。
  178. function updDicRootNode(result){
  179. for(var i=0;i<result.length;i++){
  180. var node=result[i];
  181. if(node.parentId==0){
  182. node.isRoot=1;
  183. node.parentId==0;
  184. node.icon=__ctx + "/styles/default/images/icon/root.png";
  185. break;
  186. }
  187. }
  188. }
  189. //编辑字典数据
  190. function editDict(){
  191. var selectNode=getSelectNode();
  192. var dicId=selectNode.dicId;
  193. if(selectNode.isRoot==1){
  194. return ;
  195. }
  196. var url="${ctx}/platform/system/dictionary/edit.ht?dicId=" + dicId +"&isAdd=0";
  197. var winArgs="dialogWidth=450px;dialogHeight=200px;help=no;status=no;scroll=no;center=yes";
  198. var conf={callBack:function(){
  199. loadDictByTypeId();
  200. }};
  201. hiddenMenu();
  202. url=url.getNewUrl();
  203. //var rtn=window.showModalDialog(url,conf,winArgs);
  204. /*KILLDIALOG*/
  205. DialogUtil.open({
  206. height:250,
  207. width: 450,
  208. title : '字典数据',
  209. url: url,
  210. isResize: true,
  211. //自定义参数
  212. conf: conf
  213. });
  214. }
  215. function dictRightClick(e, treeId, treeNode){
  216. if (treeNode) {
  217. dictTree.selectNode(treeNode);
  218. hiddenMenu();
  219. menuMenu = getDictMenu(treeNode);
  220. if(menuMenu){
  221. justifyRightClickPosition(e);
  222. menuMenu.show({ top: e.pageY, left: e.pageX });
  223. }
  224. }
  225. }
  226. var men1,men2,men3;
  227. function getDictMenu(treeNode){
  228. //var items=new Array();
  229. if(treeNode.isRoot==1){
  230. if(!men1)
  231. men1=$.ligerMenu({ top: 100, left: 100, width: 120, items:
  232. [{ text: '增加字典项', click:addDict },
  233. { text: '排序', click:sortDict }]
  234. });
  235. return men1;
  236. }
  237. else{
  238. if(treeNode.type==1){
  239. if(!men2)
  240. men2=$.ligerMenu({ top: 100, left: 100, width: 120, items:
  241. [{ text: '增加字典项', click:addDict },
  242. { text: '编辑字典项', click:editDict},
  243. { text: '排序', click:sortDict} ,
  244. {text: '删除', click:delDict } ,]});
  245. return men2;
  246. }else{
  247. if(!men3)
  248. men3=$.ligerMenu({ top: 100, left: 100, width: 120, items:
  249. [{ text: '增加字典项', click:addDict },
  250. { text: '编辑字典项', click:editDict},
  251. { text: '排序', click:sortDict} ,
  252. {text: '删除', click:delDict } ,]});
  253. return men3;
  254. }
  255. }
  256. // menuMenu=$.ligerMenu({ top: 100, left: 100, width: 120, items:items});
  257. return menuMenu;
  258. }
  259. //增加字典
  260. function addDict(){
  261. var selectNode=getSelectNode();
  262. var dicId=selectNode.dicId;
  263. var url="${ctx}/platform/system/dictionary/edit.ht?dicId=" + dicId +"&isAdd=1";
  264. if(selectNode.isRoot){
  265. url+="&isRoot=1";
  266. }
  267. var winArgs="dialogWidth=450px;dialogHeight=200px;help=no;status=no;scroll=no;center=yes";
  268. var conf={callBack:function(){
  269. loadDictByTypeId();
  270. }};
  271. hiddenMenu();
  272. url=url.getNewUrl();
  273. //var rtn=window.showModalDialog(url,conf,winArgs);
  274. /*KILLDIALOG*/
  275. DialogUtil.open({
  276. height:260,
  277. width: 450,
  278. title : '增加字典',
  279. url: url,
  280. isResize: true,
  281. //自定义参数
  282. conf: conf
  283. });
  284. }
  285. //数字字典排序
  286. function sortDict(){
  287. var selectNode=getSelectNode();
  288. var dicId=selectNode.dicId;
  289. var url="${ctx}/platform/system/dictionary/sortList.ht?parentId=" + dicId;
  290. var winArgs="dialogWidth=450px;dialogHeight=300px;help=no;status=no;scroll=no;center=yes";
  291. var conf={callBack:function(){
  292. loadDictByTypeId();
  293. }};
  294. hiddenMenu();
  295. url=url.getNewUrl();
  296. /* var rtn=window.showModalDialog(url,conf,winArgs);
  297. loadDictByTypeId(); */
  298. /*KILLDIALOG TODO*/
  299. DialogUtil.open({
  300. height:350,
  301. width: 450,
  302. title : '数字字典排序',
  303. url: url,
  304. isResize: true,
  305. //自定义参数
  306. conf: conf,
  307. sucCall:function(rtn){
  308. loadDictByTypeId();
  309. }
  310. });
  311. }
  312. //删除字典
  313. function delDict(){
  314. var callback=function(rtn){
  315. if(!rtn) return;
  316. var selectNode=getSelectNode();
  317. var dicId=selectNode.dicId;
  318. selectDictionaryId=selectNode.getParentNode().dicId;
  319. var url="${ctx}/platform/system/dictionary/del.ht";
  320. var params={dicId:dicId };
  321. $.post(url,params,function(responseText){
  322. var obj=new com.hotent.form.ResultMessage(responseText);
  323. if(obj.isSuccess()){
  324. $.ligerDialog.success("删除字典项成功!","提示信息",function(){
  325. loadDictByTypeId();
  326. });
  327. }
  328. else{
  329. $.ligerDialog.error("删除字典项失败!","提示信息");
  330. }
  331. });
  332. };
  333. $.ligerDialog.confirm('将删除该字典项及下面的所有字典项目,确认删除吗?','提示信息',callback);
  334. }
  335. </script>
  336. <style type="text/css">
  337. .ztree{overflow: auto;clear: both;}
  338. html,body{ padding:0px; margin:0; width:100%;height:100%;overflow: hidden;}
  339. </style>
  340. </head>
  341. <body>
  342. <div id="layout">
  343. <div position="left" title="数据字典分类">
  344. <div class="tree-toolbar">
  345. <span class="toolBar">
  346. <div class="group"><a class="link reload" id="treeFresh" href="javascript:loadTree();" ></a></div>
  347. <div class="l-bar-separator"></div>
  348. <div class="group"><a class="link expand" id="treeExpandAll" href="javascript:treeExpandAll(true)" ></a></div>
  349. <div class="l-bar-separator"></div>
  350. <div class="group"><a class="link collapse" id="treeCollapseAll" href="javascript:treeExpandAll(false)" ></a></div>
  351. </span>
  352. </div>
  353. <div id="glTypeTree" class="ztree"></div>
  354. </div>
  355. <div position="center" title="数据字典管理(点击右键操作,可以使用鼠标进行拖动)" style=" overflow:scroll">
  356. <div id="dictTree" class="ztree" ></div>
  357. </div>
  358. </div>
  359. </body>
  360. </html>