user.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('用户列表')" />
  5. <th:block th:include="include :: layout-latest-css" />
  6. <th:block th:include="include :: ztree-css" />
  7. </head>
  8. <body class="gray-bg">
  9. <div class="ui-layout-west">
  10. <div class="main-content">
  11. <div class="box box-main">
  12. <div class="box-header">
  13. <div class="box-title">
  14. <i class="fa icon-grid"></i> 组织机构
  15. </div>
  16. <div class="box-tools pull-right">
  17. <a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
  18. <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
  19. <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
  20. <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
  21. </div>
  22. </div>
  23. <div class="ui-layout-content">
  24. <div id="tree" class="ztree"></div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="container-div ui-layout-center">
  30. <div class="row">
  31. <div class="col-sm-12 search-collapse">
  32. <form id="user-form">
  33. <input type="hidden" id="deptId" name="deptId">
  34. <input type="hidden" id="parentId" name="parentId">
  35. <div class="select-list">
  36. <ul>
  37. <li>
  38. 登录名称:<input type="text" name="loginName"/>
  39. </li>
  40. <li>
  41. 手机号码:<input type="text" name="phonenumber"/>
  42. </li>
  43. <li>
  44. 用户状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
  45. <option value="">所有</option>
  46. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  47. </select>
  48. </li>
  49. <li class="select-time">
  50. <label>创建时间: </label>
  51. <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
  52. <span>-</span>
  53. <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
  54. </li>
  55. <li>
  56. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  57. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  58. </li>
  59. </ul>
  60. </div>
  61. </form>
  62. </div>
  63. <div class="btn-group-sm" id="toolbar" role="group">
  64. <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:user:add">
  65. <i class="fa fa-plus"></i> 新增
  66. </a>
  67. <a class="btn btn-primary btn-edit disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:user:edit">
  68. <i class="fa fa-edit"></i> 修改
  69. </a>
  70. <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:user:remove">
  71. <i class="fa fa-remove"></i> 删除
  72. </a>
  73. <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
  74. <i class="fa fa-upload"></i> 导入
  75. </a>
  76. <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export">
  77. <i class="fa fa-download"></i> 导出
  78. </a>
  79. </div>
  80. <div class="col-sm-12 select-table table-striped">
  81. <table id="bootstrap-table" data-mobile-responsive="true"></table>
  82. </div>
  83. </div>
  84. </div>
  85. <th:block th:include="include :: footer" />
  86. <th:block th:include="include :: layout-latest-js" />
  87. <th:block th:include="include :: ztree-js" />
  88. <script th:inline="javascript">
  89. var editFlag = [[${@permission.hasPermi('system:user:edit')}]];
  90. var removeFlag = [[${@permission.hasPermi('system:user:remove')}]];
  91. var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]];
  92. var prefix = ctx + "system/user";
  93. $(function() {
  94. var panehHidden = false;
  95. if ($(this).width() < 769) {
  96. panehHidden = true;
  97. }
  98. $('body').layout({ initClosed: panehHidden, west__size: 185 });
  99. queryUserList();
  100. queryDeptTree();
  101. });
  102. function queryUserList() {
  103. var options = {
  104. url: prefix + "/list",
  105. createUrl: prefix + "/add",
  106. updateUrl: prefix + "/edit/{id}",
  107. removeUrl: prefix + "/remove",
  108. exportUrl: prefix + "/export",
  109. importUrl: prefix + "/importData",
  110. importTemplateUrl: prefix + "/importTemplate",
  111. sortName: "createTime",
  112. sortOrder: "desc",
  113. modalName: "用户",
  114. columns: [{
  115. checkbox: true
  116. },
  117. {
  118. field: 'userId',
  119. title: '用户ID'
  120. },
  121. {
  122. field: 'loginName',
  123. title: '登录名称',
  124. sortable: true
  125. },
  126. {
  127. field: 'userName',
  128. title: '用户名称'
  129. },
  130. {
  131. field: 'dept.deptName',
  132. title: '部门'
  133. },
  134. {
  135. field: 'email',
  136. title: '邮箱',
  137. visible: false
  138. },
  139. {
  140. field: 'phonenumber',
  141. title: '手机'
  142. },
  143. {
  144. visible: editFlag == 'hidden' ? false : true,
  145. title: '用户状态',
  146. align: 'center',
  147. formatter: function (value, row, index) {
  148. return statusTools(row);
  149. }
  150. },
  151. {
  152. field: 'createTime',
  153. title: '创建时间',
  154. sortable: true
  155. },
  156. {
  157. title: '操作',
  158. align: 'center',
  159. formatter: function(value, row, index) {
  160. var actions = [];
  161. actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
  162. actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a> ');
  163. actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="javascript:void(0)" onclick="resetPwd(\'' + row.userId + '\')"><i class="fa fa-key"></i>重置</a>');
  164. return actions.join('');
  165. }
  166. }]
  167. };
  168. $.table.init(options);
  169. }
  170. function queryDeptTree()
  171. {
  172. var url = ctx + "system/dept/treeData";
  173. var options = {
  174. url: url,
  175. expandLevel: 2,
  176. onClick : zOnClick
  177. };
  178. $.tree.init(options);
  179. function zOnClick(event, treeId, treeNode) {
  180. $("#deptId").val(treeNode.id);
  181. $("#parentId").val(treeNode.pId);
  182. $.table.search();
  183. }
  184. }
  185. $('#btnExpand').click(function() {
  186. $._tree.expandAll(true);
  187. $(this).hide();
  188. $('#btnCollapse').show();
  189. });
  190. $('#btnCollapse').click(function() {
  191. $._tree.expandAll(false);
  192. $(this).hide();
  193. $('#btnExpand').show();
  194. });
  195. $('#btnRefresh').click(function() {
  196. queryDeptTree();
  197. });
  198. /* 用户管理-部门 */
  199. function dept() {
  200. var url = ctx + "system/dept";
  201. createMenuItem(url, "部门管理");
  202. }
  203. /* 用户管理-重置密码 */
  204. function resetPwd(userId) {
  205. var url = prefix + '/resetPwd/' + userId;
  206. $.modal.open("重置密码", url, '800', '300');
  207. }
  208. /* 用户状态显示 */
  209. function statusTools(row) {
  210. if (row.status == 1) {
  211. return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
  212. } else {
  213. return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
  214. }
  215. }
  216. /* 用户管理-停用 */
  217. function disable(userId) {
  218. $.modal.confirm("确认要停用用户吗?", function() {
  219. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 1 });
  220. })
  221. }
  222. /* 用户管理启用 */
  223. function enable(userId) {
  224. $.modal.confirm("确认要启用用户吗?", function() {
  225. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
  226. })
  227. }
  228. </script>
  229. </body>
  230. <form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
  231. <div class="col-xs-offset-1">
  232. <input type="file" id="file" name="file"/>
  233. <div class="mt10 pt5">
  234. <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
  235. &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
  236. </div>
  237. <font color="red" class="pull-left mt10">
  238. 提示:仅允许导入“xls”或“xlsx”格式文件!
  239. </font>
  240. </div>
  241. </form>
  242. </html>