user_edit.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>编辑内容</title>
  7. </head>
  8. <body layout:fragment="content">
  9. <article class="page-container">
  10. <form class="form form-horizontal" id="form-content-edit">
  11. <input type="hidden" th:name="id" th:id="uid" th:value="${user.id}"/>
  12. <div class="row cl">
  13. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账号:</label>
  14. <div class="formControls col-xs-8 col-sm-9">
  15. <input type="text" class="input-text" th:value="${user.nick_name}" th:id="nick_name"
  16. placeholder="请输入用户名" th:name="nick_name"/>
  17. </div>
  18. </div>
  19. <!--<div class="row cl">-->
  20. <!--<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>邮箱地址:</label>-->
  21. <!--<div class="formControls col-xs-8 col-sm-9">-->
  22. <!--<input type="text" class="input-text" value="" th:value="${user.email}" placeholder="请输入邮箱地址"-->
  23. <!--th:name="email"/>-->
  24. <!--</div>-->
  25. <!--</div>-->
  26. <div class="row cl">
  27. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>联系人:</label>
  28. <div class="formControls col-xs-8 col-sm-9">
  29. <input type="text" class="input-text" value="" th:value="${user.user_name}" placeholder="请输入联系人"
  30. th:name="user_name"/>
  31. </div>
  32. </div>
  33. <div class="row cl">
  34. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>联系电话:</label>
  35. <div class="formControls col-xs-8 col-sm-9">
  36. <input type="text" class="input-text" placeholder="请输入联系电话" th:value="${user.phone}"
  37. th:name="phone"/>
  38. </div>
  39. </div>
  40. <div class="row cl">
  41. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>用户类型:</label>
  42. <div class="formControls col-xs-8 col-sm-9">
  43. <span class="select-box">
  44. <select th:id="user_type" class="select" th:name="user_type" required onchange="controlShow(this);">
  45. <option value="">--请选择--</option>
  46. <option value="0" th:selected="${user.user_type==0}" >政府用户</option>
  47. <option value="4" th:selected="${user.user_type==4}" >街道用户</option>
  48. <option value="1" th:selected="${user.user_type==1}" >园区用户</option>
  49. </select>
  50. </span>
  51. </div>
  52. </div>
  53. <div class="row cl select_role_government" th:if="${user.user_type==0}" >
  54. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色:</label>
  55. <div class="formControls col-xs-8 col-sm-9">
  56. <select id="select_role_government" class="roleSelect" th:name="roleIds" multiple="multiple">
  57. <option th:each="item : ${governmentRoles}" th:value="${item.id}">
  58. [[*{item.name}]]
  59. </option>
  60. </select>
  61. </div>
  62. </div>
  63. <div class="row cl select_role_street" th:if="${user.user_type==4}">
  64. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色:</label>
  65. <div class="formControls col-xs-8 col-sm-9">
  66. <select id="select_role_street" class="roleSelect" th:name="roleIds" multiple="multiple">
  67. <option th:each="item : ${streetRoles}" th:value="${item.id}" >
  68. [[*{item.name}]]
  69. </option>
  70. </select>
  71. </div>
  72. </div>
  73. <div th:hidden="${user.user_type==1}" >
  74. <div class="row cl select_department_id" th:hidden="${user.user_type==4}" >
  75. <label class="form-label col-xs-4 col-sm-2">所属部门:</label>
  76. <div class="formControls col-xs-8 col-sm-9">
  77. <select id="department_select" th:name="department_id" class="input-text">
  78. <option value="">--请选择--</option>
  79. <option th:each="item : ${departments}" th:selected="${user.department_id==item.id}"
  80. th:value="${item.id}">
  81. [[*{item.name}]]
  82. </option>
  83. </select>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="row cl select_street_id" th:hidden="${user.user_type==0}">
  88. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属街道:</label>
  89. <div class="formControls col-xs-8 col-sm-9">
  90. <span class="select-box">
  91. <select th:id="select_street_id" class="select" th:name="street_id"
  92. onchange="selectStreet(this);">
  93. <option value="">--请选择--</option>
  94. <option value="" th:unless="${item.is_start}" disabled th:selected="*{item.id==user.street_id}" th:each="item : ${streets}" th:value="${item.id}" th:text="${item.name}">
  95. <option value="" th:if="${item.is_start}" th:selected="*{item.id==user.street_id}" th:each="item : ${streets}" th:value="${item.id}" th:text="${item.name}">
  96. </select>
  97. <input name="street_name" id="select_street_name" type="hidden" th:value="${user.street_name}"/>
  98. </span>
  99. </div>
  100. </div>
  101. <div class="row cl select_build_id" th:hidden="!${user.user_type==1}">
  102. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属园区:</label>
  103. <div class="formControls col-xs-8 col-sm-9">
  104. <span class="select-box">
  105. <select th:id="select_build_id" class="select" th:name="build_id"
  106. onchange="selectBuild(this);">
  107. <option value="">--请选择--</option>
  108. <option value="" th:unless="${item.is_start}" disabled th:each="item : ${builds}" th:selected="*{item.id==user.build_id}" th:value="${item.id}" th:text="${item.name}">
  109. <option value="" th:if="${item.is_start}" th:each="item : ${builds}" th:selected="*{item.id==user.build_id}" th:value="${item.id}" th:text="${item.name}">
  110. </select>
  111. <input name="build_name" id="select_build_name" th:value="${user.build_name}" type="hidden"/>
  112. </span>
  113. </div>
  114. </div>
  115. <div class="row cl">
  116. <label class="form-label col-xs-4 col-sm-2"><span>是否管理员:</span></label>
  117. <div class="formControls col-xs-8 col-sm-9">
  118. <input type="radio" name="is_admin" th:checked="${user.is_admin==false }" value="false">否</input>
  119. <input type="radio" name="is_admin" th:checked="${user.is_admin==true }" value="true">是</input>
  120. </div>
  121. </div>
  122. <div class="row cl">
  123. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  124. <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i>保存</button>
  125. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  126. </div>
  127. </div>
  128. </form>
  129. </article>
  130. <script type="text/javascript" th:src="@{/js/super/user/user_edit.js}"></script>
  131. <script th:inline="javascript">
  132. /**
  133. * 取消
  134. */
  135. function removeIframe() {
  136. var index = parent.layer.getFrameIndex(window.name);
  137. parent.layer.close(index);
  138. }
  139. function controlShow(obj) {
  140. //政府用户0,街道用户4,园区用户1
  141. var val = $.trim($(obj).val());
  142. $("#select_build_name").val('');
  143. $("#select_build_id").val('');
  144. $("#select_street_name").val('');
  145. $("#select_street_id").val('');
  146. $("#select_street_id").attr("required", false);
  147. $("#select_build_id").attr("required", false);
  148. $(".select_role_government").hide();
  149. $(".select_role_street").hide();
  150. if (val == 4) {
  151. $("#select_street_id").attr("required", true);
  152. $(".select_street_id").show();
  153. $(".select_build_id").hide();
  154. $(".select_department_id").hide();
  155. $(".select_role_street").show();
  156. } else if (val == 0 || val == '') {
  157. $(".select_street_id").hide();
  158. $(".select_build_id").hide();
  159. $(".select_department_id").show();
  160. $(".select_role_government").show();
  161. } else if (val == 1) {
  162. $("#select_street_id").attr("required", true);
  163. $("#select_build_id").attr("required", true);
  164. $(".select_street_id").show();
  165. $(".select_build_id").show();
  166. var html = '';
  167. html += "<option value=''>--请选择--</option>";
  168. $("#select_build_id").html(html);
  169. }
  170. }
  171. function selectStreet(obj) {
  172. $("#select_street_name").val('');
  173. $("#select_build_name").val('');
  174. $("#select_street_name").val($(obj).find("option:selected").html());
  175. $("#select_build_id").html("");
  176. if($("#user_type").val()==1){
  177. var html = '';
  178. html += "<option value=''>--请选择--</option>";
  179. if ($(obj).val()) {
  180. $.ajax({
  181. type: "GET",
  182. dataType: "json",
  183. url: pagePath + "/admin/user/findBuildsByStreet/" + $(obj).val(),
  184. success: function (result) {
  185. if (result.success) {
  186. $.each(result.obj, function (index, item) {
  187. if(item.is_start){
  188. html += "<option value=" + item.id + ">" + item.name + "</option>";
  189. }else{
  190. html += "<option disabled value=" + item.id + ">" + item.name + "</option>";
  191. }
  192. });
  193. $("#select_build_id").html(html);
  194. } else {
  195. errorMessage(result.message);
  196. }
  197. },
  198. error: function () {
  199. errorMessage('系统错误!');
  200. }
  201. });
  202. }else{
  203. $("#select_build_id").html(html);
  204. }
  205. }
  206. }
  207. function selectBuild(obj) {
  208. $("#select_build_name").val($(obj).find("option:selected").html());
  209. }
  210. $(window).load(function () {
  211. initDepartmentSelect();
  212. initRoleSelect();
  213. });
  214. function initDepartmentSelect() {
  215. $("#department_select").select2({
  216. width: '100%',
  217. language: {
  218. noResults: function (params) {
  219. return "暂无数据";
  220. }
  221. }
  222. });
  223. }
  224. function initRoleSelect() {
  225. $("#select_role_street").select2({
  226. width: '100%',
  227. language: {
  228. noResults: function (params) {
  229. return "暂无数据";
  230. }
  231. }
  232. });
  233. $("#select_role_government").select2({
  234. width: '100%',
  235. language: {
  236. noResults: function (params) {
  237. return "暂无数据";
  238. }
  239. }
  240. });
  241. var userType = [[${user.user_type}]];
  242. if(userType == "4"){
  243. $("#select_role_street").val([[${user.roleIds}]]).trigger("change");
  244. }else{
  245. $("#select_role_government").val([[${user.roleIds}]]).trigger("change");
  246. }
  247. }
  248. </script>
  249. </body>
  250. </html>