accountsStrategyUpdate.ftl 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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; i<nodes.length; 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. function onLoadSuccessed(){
  95. var zTree = $.fn.zTree.getZTreeObj("orgsTree");
  96. var orgsIdValues = $("#orgIdsList").val().split(",") ;
  97. var orgsName="";
  98. for (var i=0; i<orgsIdValues.length; i++) {
  99. var node = zTree.getNodeByParam("id",orgsIdValues[i] );
  100. if(node != null){
  101. zTree.checkNode(node, true, false);//将指定ID的节点选中
  102. orgsName += node.name + ",";
  103. }
  104. }
  105. $("#orgIdsListName").val(orgsName);
  106. }
  107. $.fn.zTree.init(
  108. $("#"+treeSettings.element), //element
  109. {//json object
  110. check : {
  111. enable : treeSettings.checkbox
  112. },
  113. async : {
  114. enable : true,
  115. url : treeSettings.url,
  116. autoParam : ["id", "name=n", "level=lv"],
  117. dataType : "json",
  118. otherParam : {"otherParam":"zTreeAsyncTest",id:treeSettings.rootId},
  119. dataFilter : function (treeId, parentNode, childNodes) {
  120. if (!childNodes) return null;
  121. for (var i=0, l=childNodes.length; i<l; i++) {
  122. childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
  123. }
  124. return childNodes;
  125. }
  126. },
  127. data : {
  128. simpleData : {
  129. enable : true
  130. }
  131. },
  132. callback: {
  133. onClick : treeSettings.onClick,
  134. onDblClick : treeSettings.onDblClick,
  135. beforeAsync : function(treeId, treeNode){
  136. $.loading();
  137. },
  138. onAsyncSuccess : function(event, treeId, treeNode, msg){
  139. $.unloading();
  140. onLoadSuccessed();
  141. },
  142. //beforeExpand : beforeExpand,
  143. onExpand : function onExpand(event, treeId, treeNode) {
  144. curExpandNode = treeNode;
  145. }
  146. }
  147. }
  148. );//end tree
  149. });
  150. function onBodyDown(event) {
  151. if (!(event.target.id == "menuBtn" || event.target.id == "orgIdsListName" || event.target.id == "orgContent" || $(event.target).parents("#orgContent").length>0)) {
  152. $("#orgContent").fadeOut("fast");
  153. $("body").unbind("mousedown", onBodyDown);
  154. }
  155. }
  156. function showOrgsTree() {
  157. var treeObj = $("#orgIdsListName");
  158. var treeOffset = $("#orgIdsListName").offset();
  159. $("#orgContent").css({left:treeOffset.left + "px", top:treeOffset.top + treeObj.outerHeight() + "px"}).slideDown("fast");
  160. $("body").bind("mousedown", onBodyDown);
  161. }
  162. </script>
  163. </head>
  164. <body>
  165. <form id="actionForm" method="post" type="label" autoclose="true" action="<@base/>/accountsstrategy/update" class="needs-validation" novalidate>
  166. <table border="0" cellpadding="0" cellspacing="0" class="table table-bordered">
  167. <tbody>
  168. <tr>
  169. <th><@locale code="accounts.strategy.id" />:</th>
  170. <td nowrap>
  171. <input id="id" type="text" readonly name="id" class="form-control" value="${model.id}"/>
  172. </td>
  173. </tr>
  174. <tr>
  175. <th><@locale code="accounts.strategy.name" />:</th>
  176. <td nowrap>
  177. <input type="text" id="name" name="name" class="form-control" title="" value="${model.name!}" required="" />
  178. </td>
  179. </tr>
  180. <tr>
  181. <th><@locale code="apps.name"/>:</th>
  182. <td nowrap>
  183. <input class="form-control appId" id="appId" name="appId" value="${model.appId!}" type="hidden" >
  184. <input class="form-control appName" readonly value="${model.appName!}" id="appName" name="appName" type="text" >
  185. </td>
  186. </tr>
  187. <tr>
  188. <th><@locale code="accounts.strategy.mapping" />:</th>
  189. <td nowrap>
  190. <select id="mapping" name="mapping" class="form-control form-select" >
  191. <option value="username" <#if model.mapping?contains("username")>selected</#if> >
  192. <@locale code="userinfo.username" />
  193. </option>
  194. <option value="mobile" <#if model.mapping?contains("mobile")>selected</#if> >
  195. <@locale code="userinfo.mobile" />
  196. </option>
  197. <option value="email" <#if model.mapping?contains("email")>selected</#if> >
  198. <@locale code="userinfo.email" />
  199. </option>
  200. <option value="employeeNumber" <#if model.mapping?contains("employeeNumber")>selected</#if> >
  201. <@locale code="userinfo.employeeNumber" />
  202. </option>
  203. <option value="windowsAccount" <#if model.mapping?contains("windowsAccount")>selected</#if> >
  204. <@locale code="userinfo.windowsAccount" />
  205. </option>
  206. <option value="idCardNo" <#if model.mapping?contains("idCardNo")>selected</#if> >
  207. <@locale code="userinfo.idCardNo" />
  208. </option>
  209. </select>
  210. </td>
  211. </tr>
  212. <tr>
  213. <th><@locale code="accounts.strategy.suffixes" />:</th>
  214. <td nowrap>
  215. <input type="text" id="suffixes" name="suffixes" class="form-control" title="" value="${model.suffixes!}" />
  216. </td>
  217. </tr>
  218. <tr>
  219. <th><@locale code="accounts.strategy.createType" />:</th>
  220. <td nowrap>
  221. <select id="createType" name="createType" class="form-control form-select" >
  222. <option value="manual" <#if model.createType?contains("manual")>selected</#if> >
  223. <@locale code="accounts.strategy.createType.manual" />
  224. </option>
  225. <option value="automatic" <#if model.createType?contains("automatic")>selected</#if> >
  226. <@locale code="accounts.strategy.createType.automatic" />
  227. </option>
  228. </select>
  229. </td>
  230. </tr>
  231. <tr>
  232. <th><@locale code="accounts.strategy.orgidslist" />:</th>
  233. <td nowrap>
  234. <input type="text" id="orgIdsListName" name="orgIdsListName" readonly class="form-control" title="" value="" onclick="showOrgsTree();"/>
  235. <input type="hidden" id="orgIdsList" name="orgIdsList" readonly class="form-control" title="" value="${model.orgIdsList!}" />
  236. </td>
  237. </tr>
  238. <tr>
  239. <th><@locale code="accounts.strategy.filters" />:</th>
  240. <td nowrap>
  241. <textarea id="filters" name="filters" class="form-control" rows="3" cols="20">${model.filters!}</textarea>
  242. </td>
  243. </tr>
  244. <tr>
  245. <th><@locale code="common.text.description" />:</th>
  246. <td nowrap>
  247. <textarea id="description" name="description" class="form-control" rows="2" cols="20">${model.description!}</textarea>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td nowrap colspan="2" class="center">
  252. <input id="_method" type="hidden" name="_method" value="post"/>
  253. <input id="status" type="hidden" name="status" value="1"/>
  254. <input class="button btn btn-primary mr-3" id="submitBtn" type="submit" value="<@locale code="button.text.save" />">
  255. <input class="button btn btn-secondary mr-3" id="closeBtn" type="button" value="<@locale code="button.text.cancel" />">
  256. </td>
  257. </tr>
  258. </tbody>
  259. </table>
  260. </form>
  261. <div id="orgContent" class="menuContent" style="display:none; position: absolute;">
  262. <ul id="orgsTree" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
  263. </div>
  264. </body>
  265. </html>