tree.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('部门树选择')" />
  5. <th:block th:include="include :: ztree-css" />
  6. </head>
  7. <style>
  8. body{height:auto;font-family: "Microsoft YaHei";}
  9. button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
  10. </style>
  11. <body class="hold-transition box box-main">
  12. <input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
  13. <input id="treeName" name="treeName" type="hidden" th:value="${dept.deptName}"/>
  14. <div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
  15. <label id="btnShow" title="显示搜索" style="display:none;">︾</label>
  16. <label id="btnHide" title="隐藏搜索">︽</label>
  17. </div>
  18. <div class="treeSearchInput" id="search">
  19. <label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
  20. <button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
  21. </div>
  22. <div class="treeExpandCollapse">
  23. <a href="#" onclick="$.tree.expand()">展开</a> /
  24. <a href="#" onclick="$.tree.collapse()">折叠</a>
  25. </div>
  26. <div id="tree" class="ztree treeselect"></div>
  27. </div>
  28. <th:block th:include="include :: footer" />
  29. <th:block th:include="include :: ztree-js" />
  30. <script th:inline="javascript">
  31. var prefix = ctx + "system/dept"
  32. var deptId = [[${deptId}]];
  33. var excludeId = [[${excludeId}]];
  34. $(function() {
  35. var url = $.common.isEmpty(excludeId) ? prefix + "/treeData": prefix + "/treeData/" + excludeId;
  36. var options = {
  37. url: url,
  38. expandLevel: 2,
  39. onClick : zOnClick
  40. };
  41. $.tree.init(options);
  42. });
  43. function zOnClick(event, treeId, treeNode) {
  44. var treeId = treeNode.id;
  45. var treeName = treeNode.name;
  46. $("#treeId").val(treeId);
  47. $("#treeName").val(treeName);
  48. }
  49. </script>
  50. </body>
  51. </html>