add.html 11 KB

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