add.html 10 KB

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