edit.html 8.9 KB

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