groupAdd.ftl 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!DOCTYPE HTML>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <#include "../layout/header.ftl"/>
  5. <#include "../layout/common.cssjs.ftl"/>
  6. <style type="text/css">
  7. .table th, .table td {
  8. padding: .2rem;
  9. vertical-align: middle;
  10. }
  11. </style>
  12. <script type="text/javascript">
  13. function onClick (event, treeId, treeNode) {
  14. var zTree = $.fn.zTree.getZTreeObj("orgsTree");
  15. nodes = zTree.getCheckedNodes(true);
  16. var orgsName = "";
  17. var orgsId = "";
  18. for (var i=0, l=nodes.length; i<l; i++) {
  19. orgsName += nodes[i].name + ",";
  20. orgsId += nodes[i].id + ",";
  21. }
  22. $("#orgIdsListName").val(orgsName);
  23. $("#orgIdsList").val(orgsId);
  24. }
  25. $(function () {
  26. var treeSettings={
  27. element : "orgsTree",
  28. rootId : "1",
  29. checkbox : true,
  30. onClick : onClick,
  31. onDblClick : null,
  32. url : "<@base/>/orgs/tree"
  33. };
  34. function singlePath(newNode) {
  35. if (newNode === curExpandNode) return;
  36. if (curExpandNode && curExpandNode.open==true) {
  37. var zTree = $.fn.zTree.getZTreeObj(treeSettings.element);
  38. if (newNode.parentTId === curExpandNode.parentTId) {
  39. zTree.expandNode(curExpandNode, false);
  40. } else {
  41. var newParents = [];
  42. while (newNode) {
  43. newNode = newNode.getParentNode();
  44. if (newNode === curExpandNode) {
  45. newParents = null;
  46. break;
  47. } else if (newNode) {
  48. newParents.push(newNode);
  49. }
  50. }
  51. if (newParents!=null) {
  52. var oldNode = curExpandNode;
  53. var oldParents = [];
  54. while (oldNode) {
  55. oldNode = oldNode.getParentNode();
  56. if (oldNode) {
  57. oldParents.push(oldNode);
  58. }
  59. }
  60. if (newParents.length>0) {
  61. for (var i = Math.min(newParents.length, oldParents.length)-1; i>=0; i--) {
  62. if (newParents[i] !== oldParents[i]) {
  63. zTree.expandNode(oldParents[i], false);
  64. break;
  65. }
  66. }
  67. } else {
  68. zTree.expandNode(oldParents[oldParents.length-1], false);
  69. }
  70. }
  71. }
  72. }
  73. curExpandNode = newNode;
  74. };
  75. function beforeExpand(treeId, treeNode) {
  76. var pNode = curExpandNode ? curExpandNode.getParentNode():null;
  77. var treeNodeP = treeNode.parentTId ? treeNode.getParentNode():null;
  78. var zTree = $.fn.zTree.getZTreeObj(""+treeSettings.element);
  79. for(var i=0, l=!treeNodeP ? 0:treeNodeP.children.length; i<l; i++ ) {
  80. if (treeNode !== treeNodeP.children[i]) {
  81. zTree.expandNode(treeNodeP.children[i], false);
  82. }
  83. }
  84. while (pNode) {
  85. if (pNode === treeNode) {
  86. break;
  87. }
  88. pNode = pNode.getParentNode();
  89. }
  90. if (!pNode) {
  91. singlePath(treeNode);
  92. }
  93. };
  94. $.fn.zTree.init(
  95. $("#"+treeSettings.element), //element
  96. {//json object
  97. check : {
  98. enable : treeSettings.checkbox
  99. },
  100. async : {
  101. enable : true,
  102. url : treeSettings.url,
  103. autoParam : ["id", "name=n", "level=lv"],
  104. otherParam : {"otherParam":"zTreeAsyncTest",id:treeSettings.rootId},
  105. dataFilter : function (treeId, parentNode, childNodes) {
  106. if (!childNodes) return null;
  107. for (var i=0, l=childNodes.length; i<l; i++) {
  108. childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
  109. }
  110. return childNodes;
  111. }
  112. },
  113. data : {
  114. simpleData : {
  115. enable : true
  116. }
  117. },
  118. callback: {
  119. onClick : treeSettings.onClick,
  120. onDblClick : treeSettings.onDblClick,
  121. beforeAsync : function(treeId, treeNode){
  122. $.loading();
  123. },
  124. onAsyncSuccess : function(event, treeId, treeNode, msg){
  125. $.unloading();
  126. },
  127. //beforeExpand : beforeExpand,
  128. onExpand : function onExpand(event, treeId, treeNode) {
  129. curExpandNode = treeNode;
  130. }
  131. }
  132. }
  133. );//end tree
  134. });
  135. function onBodyDown(event) {
  136. if (!(event.target.id == "menuBtn" || event.target.id == "orgIdsListName" || event.target.id == "orgContent" || $(event.target).parents("#orgContent").length>0)) {
  137. $("#orgContent").fadeOut("fast");
  138. $("body").unbind("mousedown", onBodyDown);
  139. }
  140. }
  141. function showOrgsTree() {
  142. var treeObj = $("#orgIdsListName");
  143. var treeOffset = $("#orgIdsListName").offset();
  144. $("#orgContent").css({left:treeOffset.left + "px", top:treeOffset.top + treeObj.outerHeight() + "px"}).slideDown("fast");
  145. $("body").bind("mousedown", onBodyDown);
  146. }
  147. </script>
  148. </head>
  149. <body>
  150. <form id="actionForm" method="post" type="label" autoclose="true" action="<@base/>/groups/add" class="needs-validation" novalidate>
  151. <table border="0" cellpadding="0" cellspacing="0" class="table table-bordered" >
  152. <tbody>
  153. <tr>
  154. <th><@locale code="group.id" />:</th>
  155. <td nowrap>
  156. <input type="text" id="id" name="id" class="form-control" title="" value="" />
  157. </td>
  158. </tr>
  159. <tr>
  160. <th><@locale code="group.name" />:</th>
  161. <td nowrap>
  162. <input type="text" id="name" name="name" class="form-control" title="" value="" required="" />
  163. </td>
  164. </tr>
  165. <tr>
  166. <th><@locale code="group.dynamic" />:</th>
  167. <td nowrap>
  168. <select id="dynamic" name="dynamic" class="form-control">
  169. <option value="0" selected ><@locale code="common.text.no" /></option>
  170. <option value="1" ><@locale code="common.text.yes" /></option>
  171. </select>
  172. </td>
  173. </tr>
  174. <tr>
  175. <th><@locale code="group.resumeTime" />:</th>
  176. <td nowrap>
  177. <input type="text" id="resumeTime" name="resumeTime" class="form-control timepicker" title="" value="" required="" />
  178. </td>
  179. </tr>
  180. <tr>
  181. <th><@locale code="group.suspendTime" />:</th>
  182. <td nowrap>
  183. <input type="text" id="suspendTime" name="suspendTime" class="form-control timepicker" title="" value="" required="" />
  184. </td>
  185. </tr>
  186. <tr>
  187. <th><@locale code="group.orgidslist" />:</th>
  188. <td nowrap>
  189. <input type="text" id="orgIdsListName" name="orgIdsListName" readonly class="form-control" title="" value="" onclick="showOrgsTree();"/>
  190. <input type="hidden" id="orgIdsList" name="orgIdsList" readonly class="form-control" title="" value="" />
  191. </td>
  192. </tr>
  193. <tr>
  194. <th><@locale code="group.filters" />:</th>
  195. <td nowrap>
  196. <textarea id="filters" name="filters" class="form-control" rows="6" cols="20"></textarea>
  197. </td>
  198. </tr>
  199. <tr>
  200. <th><@locale code="common.text.description" />:</th>
  201. <td nowrap>
  202. <textarea id="description" name="description" class="form-control" rows="4" cols="20"></textarea>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td nowrap colspan="2" class="center">
  207. <input id="_method" type="hidden" name="_method" value="post"/>
  208. <input id="status" type="hidden" name="status" value="1"/>
  209. <input class="button btn btn-primary mr-3" id="submitBtn" type="submit" value="<@locale code="button.text.save" />">
  210. <input class="button btn btn-secondary mr-3" id="closeBtn" type="button" value="<@locale code="button.text.cancel" />">
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. </form>
  216. <div id="orgContent" class="menuContent" style="display:none; position: absolute;">
  217. <ul id="orgsTree" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
  218. </div>
  219. </body>
  220. </html>