edit.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('修改部门')" />
  5. </head>
  6. <body class="white-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  8. <form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
  9. <input name="deptId" type="hidden" th:field="*{deptId}" />
  10. <input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
  11. <div class="form-group">
  12. <label class="col-sm-3 control-label ">上级部门:</label>
  13. <div class="col-sm-8">
  14. <div class="input-group">
  15. <input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parentName}">
  16. <span class="input-group-addon"><i class="fa fa-search"></i></span>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="form-group">
  21. <label class="col-sm-3 control-label">部门名称:</label>
  22. <div class="col-sm-8">
  23. <input class="form-control" type="text" name="deptName" th:field="*{deptName}" id="deptName" required>
  24. </div>
  25. </div>
  26. <div class="form-group">
  27. <label class="col-sm-3 control-label">显示排序:</label>
  28. <div class="col-sm-8">
  29. <input class="form-control" type="text" name="orderNum" th:field="*{orderNum}" required>
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-sm-3 control-label">负责人:</label>
  34. <div class="col-sm-8">
  35. <input class="form-control" type="text" name="leader" th:field="*{leader}">
  36. </div>
  37. </div>
  38. <div class="form-group">
  39. <label class="col-sm-3 control-label">联系电话:</label>
  40. <div class="col-sm-8">
  41. <input class="form-control" type="text" name="phone" th:field="*{phone}">
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label class="col-sm-3 control-label">邮箱:</label>
  46. <div class="col-sm-8">
  47. <input class="form-control" type="text" name="email" th:field="*{email}">
  48. </div>
  49. </div>
  50. <div class="form-group">
  51. <label class="col-sm-3 control-label">部门状态:</label>
  52. <div class="col-sm-8">
  53. <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
  54. <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
  55. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  56. </div>
  57. </div>
  58. </div>
  59. </form>
  60. </div>
  61. <th:block th:include="include :: footer" />
  62. <script type="text/javascript">
  63. var prefix = ctx + "system/dept";
  64. $("#form-dept-edit").validate({
  65. onkeyup: false,
  66. rules:{
  67. deptName:{
  68. remote: {
  69. url: prefix + "/checkDeptNameUnique",
  70. type: "post",
  71. dataType: "json",
  72. data: {
  73. "deptId": function() {
  74. return $("#deptId").val();
  75. },
  76. "parentId": function() {
  77. return $("input[name='parentId']").val();
  78. },
  79. "deptName": function() {
  80. return $.common.trim($("#deptName").val());
  81. }
  82. },
  83. dataFilter: function(data, type) {
  84. return $.validate.unique(data);
  85. }
  86. }
  87. },
  88. orderNum:{
  89. digits:true
  90. },
  91. email:{
  92. email:true,
  93. },
  94. phone:{
  95. isPhone:true,
  96. },
  97. },
  98. messages: {
  99. "deptName": {
  100. remote: "部门已经存在"
  101. }
  102. },
  103. focusCleanup: true
  104. });
  105. function submitHandler() {
  106. if ($.validate.form()) {
  107. $.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
  108. }
  109. }
  110. /*部门管理-修改-选择部门树*/
  111. function selectDeptTree() {
  112. var deptId = $("#treeId").val();
  113. if(deptId > 0) {
  114. var options = {
  115. title: '部门选择',
  116. width: "380",
  117. url: prefix + "/selectDeptTree/" + $("#treeId").val(),
  118. callBack: doSubmit
  119. };
  120. $.modal.openOptions(options);
  121. } else {
  122. $.modal.alertError("父部门不能选择");
  123. }
  124. }
  125. function doSubmit(index, layero){
  126. var tree = layero.find("iframe")[0].contentWindow.$._tree;
  127. if ($.tree.notAllowLastLevel(tree)) {
  128. var body = layer.getChildFrame('body', index);
  129. $("#treeId").val(body.find('#treeId').val());
  130. $("#treeName").val(body.find('#treeName').val());
  131. layer.close(index);
  132. }
  133. }
  134. </script>
  135. </body>
  136. </html>