user.html 10 KB

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