edit.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 :: select2-css" />
  6. </head>
  7. <body>
  8. <div class="form-content">
  9. <form class="form-horizontal" id="form-user-edit" th:object="${user}">
  10. <input name="userId" type="hidden" th:field="*{userId}" />
  11. <input name="deptId" type="hidden" th:field="*{deptId}" id="treeId"/>
  12. <h4 class="form-header h4">基本信息</h4>
  13. <div class="row">
  14. <div class="col-sm-6">
  15. <div class="form-group">
  16. <label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户名称:</label>
  17. <div class="col-sm-8">
  18. <input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="col-sm-6">
  23. <div class="form-group">
  24. <label class="col-sm-4 control-label"><span style="color: red; ">*</span>归属部门:</label>
  25. <div class="col-sm-8">
  26. <div class="input-group">
  27. <input class="form-control" type="text" name="deptName" onclick="selectDeptTree()" id="treeName" th:field="*{dept.deptName}" required>
  28. <span class="input-group-addon"><i class="fa fa-search"></i></span>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="row">
  35. <div class="col-sm-6">
  36. <div class="form-group">
  37. <label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码:</label>
  38. <div class="col-sm-8">
  39. <input name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" th:field="*{phonenumber}" required>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="col-sm-6">
  44. <div class="form-group">
  45. <label class="col-sm-4 control-label"><span style="color: red; ">*</span>邮箱:</label>
  46. <div class="col-sm-8">
  47. <input name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" th:field="*{email}" >
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="row">
  53. <div class="col-sm-6">
  54. <div class="form-group">
  55. <label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号:</label>
  56. <div class="col-sm-8">
  57. <input class="form-control" type="text" readonly="true" th:field="*{loginName}"/>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="col-sm-6">
  62. <div class="form-group">
  63. <label class="col-sm-4 control-label">用户状态:</label>
  64. <div class="col-sm-8">
  65. <label class="toggle-switch switch-solid">
  66. <input type="checkbox" id="status" th:checked="${user.status == '0' ? true : false}">
  67. <span></span>
  68. </label>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="row">
  74. <div class="col-sm-6">
  75. <div class="form-group">
  76. <label class="col-sm-4 control-label">岗位:</label>
  77. <div class="col-sm-8">
  78. <select id="post" class="form-control select2-multiple" multiple>
  79. <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>
  80. </select>
  81. </div>
  82. </div>
  83. </div>
  84. <div class="col-sm-6">
  85. <div class="form-group">
  86. <label class="col-sm-4 control-label">用户性别:</label>
  87. <div class="col-sm-8">
  88. <div class="input-group" style="width: 100%">
  89. <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
  90. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
  91. </select>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="row">
  98. <div class="col-sm-12">
  99. <div class="form-group">
  100. <label class="col-xs-2 control-label">角色:</label>
  101. <div class="col-xs-10">
  102. <label th:each="role:${roles}" class="check-box">
  103. <input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}">
  104. </label>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. <h4 class="form-header h4">其他信息</h4>
  110. <div class="row">
  111. <div class="col-sm-12">
  112. <div class="form-group">
  113. <label class="col-xs-2 control-label">备注:</label>
  114. <div class="col-xs-10">
  115. <textarea name="remark" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </form>
  121. </div>
  122. <div class="row">
  123. <div class="col-sm-offset-5 col-sm-10">
  124. <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
  125. <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
  126. </div>
  127. </div>
  128. <th:block th:include="include :: footer" />
  129. <th:block th:include="include :: select2-js" />
  130. <script type="text/javascript">
  131. var prefix = ctx + "system/user";
  132. $("#form-user-edit").validate({
  133. onkeyup: false,
  134. rules:{
  135. email:{
  136. email:true,
  137. remote: {
  138. url: prefix + "/checkEmailUnique",
  139. type: "post",
  140. dataType: "json",
  141. data: {
  142. "userId": function() {
  143. return $("#userId").val();
  144. },
  145. "email": function() {
  146. return $.common.trim($("#email").val());
  147. }
  148. },
  149. dataFilter: function (data, type) {
  150. return $.validate.unique(data);
  151. }
  152. }
  153. },
  154. phonenumber:{
  155. isPhone:true,
  156. remote: {
  157. url: prefix + "/checkPhoneUnique",
  158. type: "post",
  159. dataType: "json",
  160. data: {
  161. "userId": function() {
  162. return $("#userId").val();
  163. },
  164. "phonenumber": function() {
  165. return $.common.trim($("#phonenumber").val());
  166. }
  167. },
  168. dataFilter: function (data, type) {
  169. return $.validate.unique(data);
  170. }
  171. }
  172. },
  173. },
  174. messages: {
  175. "email": {
  176. remote: "Email已经存在"
  177. },
  178. "phonenumber":{
  179. remote: "手机号码已经存在"
  180. }
  181. },
  182. focusCleanup: true
  183. });
  184. function submitHandler() {
  185. if ($.validate.form()) {
  186. var data = $("#form-user-edit").serializeArray();
  187. var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
  188. var roleIds = $.form.selectCheckeds("role");
  189. var postIds = $.form.selectSelects("post");
  190. data.push({"name": "status", "value": status});
  191. data.push({"name": "roleIds", "value": roleIds});
  192. data.push({"name": "postIds", "value": postIds});
  193. $.operate.saveTab(prefix + "/edit", data);
  194. }
  195. }
  196. /*用户管理-修改-选择部门树*/
  197. function selectDeptTree() {
  198. var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
  199. var url = ctx + "system/dept/selectDeptTree/" + deptId;
  200. var options = {
  201. title: '选择部门',
  202. width: "380",
  203. url: url,
  204. callBack: doSubmit
  205. };
  206. $.modal.openOptions(options);
  207. }
  208. function doSubmit(index, layero){
  209. var tree = layero.find("iframe")[0].contentWindow.$._tree;
  210. if ($.tree.notAllowParents(tree)) {
  211. var body = layer.getChildFrame('body', index);
  212. $("#treeId").val(body.find('#treeId').val());
  213. $("#treeName").val(body.find('#treeName').val());
  214. layer.close(index);
  215. }
  216. }
  217. </script>
  218. </body>
  219. </html>