resourcesAddResource.jsp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="com.hotent.platform.model.system.Resources"%>
  2. <%@include file="/commons/include/html_doctype.html"%>
  3. <html>
  4. <head>
  5. <title>资源管理</title>
  6. <%@include file="/commons/include/form.jsp" %>
  7. <f:link href="tree/zTreeStyle.css"></f:link>
  8. <script type="text/javascript" src="${ctx}/js/tree/jquery.ztree.js"></script>
  9. <script type="text/javascript" src="${ctx}/js/lg/plugins/ligerComboBox.js"></script>
  10. <script type="text/javascript" src="${ctx}/js/lg/plugins/ligerWindow.js" ></script>
  11. <script type="text/javascript" src="${ctx}/js/hotent/platform/system/IconDialog.js"></script>
  12. <script type="text/javascript" src="${ctx}/js/hotent/platform/system/Share.js"></script>
  13. <script type="text/javascript" src="${ctx}/servlet/ValidJs?form=resources"></script>
  14. <script type="text/javascript">
  15. /*KILLDIALOG*/
  16. var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
  17. var rootId=0;
  18. //当前访问系统
  19. var systemId=null;
  20. //var winArgs = window.dialogArguments;
  21. var winArgs =dialog.get('params');
  22. $(function(){
  23. $("#defaultUrl").val(winArgs.addUrl);
  24. $("#resName").val(winArgs.name);
  25. //布局
  26. loadLayout();
  27. //加载树
  28. systemId=$("#subSystem").val();
  29. loadTree();
  30. //改变子系统
  31. $("#subSystem").change(function(){
  32. systemId=$("#subSystem").val();
  33. $("#systemId").val(systemId);
  34. loadTree();
  35. });
  36. //-----Center Area
  37. function showRequest(formData, jqForm, options) {
  38. return true;
  39. }
  40. $("#resName").blur(function(){
  41. var obj=$(this);
  42. autoPingin(obj);
  43. });
  44. valid(showRequest,showResponse);
  45. $("a.save").click(function() {
  46. var parentId = $("#parentId").val();
  47. if(!parentId){
  48. $.ligerDialog.warn('请从左边的资源树上选择父节点!');
  49. return;
  50. }
  51. $('#resourcesForm').submit();
  52. });
  53. });
  54. //布局
  55. function loadLayout(){
  56. $("#layout").ligerLayout( {
  57. leftWidth : 300,
  58. height: 550,
  59. onHeightChanged: heightChanged,
  60. allowLeftResize:false
  61. });
  62. //取得layout的高度
  63. var height = $(".l-layout-center").height();
  64. $("#resourcesTree").height(height-90);
  65. };
  66. //布局大小改变的时候通知tab,面板改变大小
  67. function heightChanged(options){
  68. $("#resourcesTree").height(options.middleHeight -90);
  69. };
  70. //树
  71. var resourcesTree;
  72. //加载树
  73. function loadTree(){
  74. var setting = {
  75. async: {enable: false},
  76. data: {
  77. key:{name:"resName"},
  78. simpleData: {
  79. enable: true,
  80. idKey: "resId",
  81. pIdKey: "parentId",
  82. rootPId: <%=Resources.ROOT_PID%>
  83. }
  84. },
  85. view: {
  86. selectedMulti: false
  87. },
  88. callback:{
  89. onClick: zTreeOnLeftClick
  90. }
  91. };
  92. var url="${ctx}/platform/system/resources/getSystemTreeData.ht";
  93. var params={systemId:systemId};
  94. $.post(url,params,function(result){
  95. resourcesTree=$.fn.zTree.init($("#resourcesTree"), setting,result);
  96. resourcesTree.expandAll(true);
  97. });
  98. };
  99. //左击
  100. function zTreeOnLeftClick(event, treeId, treeNode){
  101. var isfolder=treeNode.isFolder;
  102. var msg=$("#msg");
  103. if(isfolder==1){
  104. msg.text('');
  105. }else if(isfolder==0){
  106. msg.text('选择的父节点必须要有权限放子节点!');
  107. return;
  108. }
  109. var resId=treeNode.resId;
  110. $("#parentId").val(resId);
  111. };
  112. //展开收起
  113. function treeExpandAll(type){
  114. resourcesTree = $.fn.zTree.getZTreeObj("resourcesTree");
  115. resourcesTree.expandAll(type);
  116. };
  117. //选择资源节点。
  118. function getSelectNode(){
  119. resourcesTree = $.fn.zTree.getZTreeObj("resourcesTree");
  120. var nodes = resourcesTree.getSelectedNodes();
  121. var node = nodes[0];
  122. return node;
  123. }
  124. //刷新
  125. function reFresh(){
  126. loadTree();
  127. };
  128. //添加完成后调用该函数
  129. function addResource(id,text,icon,isFolder){
  130. var parentNode=getSelectNode();
  131. resourcesTree = $.fn.zTree.getZTreeObj("resourcesTree");
  132. var treeNode= {resId:id,parentId:parentNode.resId,resName:text,icon:icon,isFolder:isFolder};
  133. resourcesTree.addNodes(parentNode,treeNode);
  134. }
  135. //编辑完成后调用该函数。
  136. function editResource(text,icon,isFolder){
  137. var selectNode=getSelectNode();
  138. selectNode.resName=text;
  139. selectNode.icon=icon;
  140. selectNode.isFolder=isFolder;
  141. resourcesTree = $.fn.zTree.getZTreeObj("resourcesTree");
  142. resourcesTree.updateNode(selectNode);
  143. }
  144. function showResponse(responseText){
  145. var json=eval("("+responseText+")");
  146. if(json.result==1){
  147. var resName=$("#resName").val();
  148. var isFolder=$("#isFolder").val();
  149. var icon=$("#icon").val();
  150. addResource(json.resId,resName,icon,isFolder);
  151. $.ligerDialog.alert("添加为菜单成功!",'提示信息',"success",function(rtn){
  152. dialog.close();
  153. });
  154. }
  155. else{
  156. $.ligerDialog.err('出错信息',"查看资源管理失败",json.message);
  157. }
  158. }
  159. function selectIcon(){
  160. IconDialog({callback:function(src){
  161. $("#icon").val(src);
  162. $("#iconImg").attr("src",src);
  163. $("#iconImg").show();
  164. }});
  165. };
  166. function autoPingin(obj){
  167. var value=obj.val();
  168. Share.getPingyin({
  169. input:value,
  170. postCallback:function(data){
  171. $("#alias").val(data.output);
  172. }
  173. });
  174. }
  175. </script>
  176. <style type="text/css">
  177. .tree-title{overflow:hidden;width:8000px;}
  178. .ztree{overflow: auto;}
  179. </style>
  180. </head>
  181. <body>
  182. <div id="layout">
  183. <div id="left" position="left" title="资源管理" >
  184. <div style="width:100%;">
  185. <select id="subSystem" style="width:99.8% !important;">
  186. <c:forEach var="subSystemItem" items="${subSystemList}">
  187. <option value="${subSystemItem.systemId}"
  188. <c:choose>
  189. <c:when test="${subSystemItem.systemId==currentSystemId}">
  190. selected="selected"
  191. </c:when>
  192. </c:choose>>${subSystemItem.sysName}</option>
  193. </c:forEach>
  194. </select>
  195. </div>
  196. <div class="tree-toolbar tree-title" id="pToolbar">
  197. <span class="toolBar">
  198. <div class="group"><a class="link reload" id="treeFresh" href="javascript:reFresh();">刷新</a></div>
  199. <div class="l-bar-separator"></div>
  200. <div class="group"><a class="link expand" id="treeExpandAll" href="javascript:treeExpandAll(true)">展开</a></div>
  201. <div class="l-bar-separator"></div>
  202. <div class="group"><a class="link collapse" id="treeCollapseAll" href="javascript:treeExpandAll(false)">收起</a></div>
  203. </span>
  204. </div>
  205. <ul id="resourcesTree" class="ztree"></ul>
  206. </div>
  207. <div position="center">
  208. <div id="addResourceDiv">
  209. <form id="resourcesForm" method="post" action="save.ht">
  210. <div class="panel">
  211. <div class="panel-top">
  212. <div class="tbar-title">
  213. <span class="tbar-label">添加子系统资</span>
  214. </div>
  215. <div class="panel-toolbar">
  216. <div class="toolBar">
  217. <div class="group"><a class="link save" id="dataFormSave" href="javascript:;"><span></span>保存</a></div>
  218. <div class="l-bar-separator"></div>
  219. <div><span style="margin-left: 50px" class="red" id="msg"></span></div>
  220. </div>
  221. </div>
  222. </div>
  223. <div class="panel-body">
  224. <table id="resourcesTable" class="table-detail" cellpadding="0" cellspacing="0" border="0">
  225. <tr>
  226. <th width="20%">资源名称: <span class="required">*</span></th>
  227. <td><input type="text" id="resName" name="resName" class="inputText"/></td>
  228. </tr>
  229. <tr>
  230. <th width="20%">资源别名: </th>
  231. <td><input type="text" id="alias" name="alias" class="inputText"/></td>
  232. </tr>
  233. <tr>
  234. <th width="20%">资源图标: </th>
  235. <td>
  236. <input type="hidden" id="icon" name="icon" class="inputText"/>
  237. <img id="iconImg" alt="" style="display:none;">
  238. <a class="link detail" href="javascript:selectIcon();">选择</a>
  239. </td>
  240. </tr>
  241. <tr>
  242. <th width="20%">默认地址: </th>
  243. <td><input type="text" id="defaultUrl" name="defaultUrl" style="width:400px" class="inputText" readonly="readonly"/></td>
  244. </tr>
  245. <tr>
  246. <th width="20%">是否有子节点: </th>
  247. <td>
  248. <select id="isFolder" name="isFolder">
  249. <option value="0" >否</option>
  250. <option value="1" >是</option>
  251. </select>
  252. </td>
  253. </tr>
  254. <tr>
  255. <th width="20%">显示到菜单: </th>
  256. <td>
  257. <select id="isDisplayInMenu" name="isDisplayInMenu">
  258. <option value="0" >否</option>
  259. <option value="1" selected="selected" >是</option>
  260. </select>
  261. </td>
  262. </tr>
  263. <tr>
  264. <th width="20%">默认打开: </th>
  265. <td>
  266. <select id="isOpen" name="isOpen">
  267. <option value="0" >否</option>
  268. <option value="1" selected="selected" >是</option>
  269. </select>
  270. </td>
  271. </tr>
  272. <tr style="display: none;">
  273. <th width="20%">同级排序: </th>
  274. <td><input type="text" id="sn" name="sn" value="1" class="inputText"/></td>
  275. </tr>
  276. <tr style="display: none;">
  277. <th width="20%">父ID: </th>
  278. <td><input type="text" id="parentId" name="parentId" class="inputText"/></td>
  279. </tr>
  280. <tr style="display: none;">
  281. <th width="20%">systemId: </th>
  282. <td><input type="text" id="systemId" name="systemId" class="inputText" value="${currentSystemId}"/></td>
  283. </tr>
  284. <input type="hidden" id="resId" name="resId" />
  285. </table>
  286. </div>
  287. </div>
  288. </form>
  289. </div>
  290. </div>
  291. </div>
  292. </body>
  293. </html>