edit.html 10 KB

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