user.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 fa-sitemap"></i> 组织机构
  14. </div>
  15. <div class="box-tools pull-right">
  16. <a type="button" class="btn btn-box-tool" href="javascript:void(0)" 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="resetPre()"><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, resizeWithWindow: false });
  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. viewUrl: prefix + "/view/{id}",
  114. createUrl: prefix + "/add",
  115. updateUrl: prefix + "/edit/{id}",
  116. removeUrl: prefix + "/remove",
  117. exportUrl: prefix + "/export",
  118. importUrl: prefix + "/importData",
  119. importTemplateUrl: prefix + "/importTemplate",
  120. sortName: "createTime",
  121. sortOrder: "desc",
  122. modalName: "用户",
  123. columns: [{
  124. checkbox: true
  125. },
  126. {
  127. field: 'userId',
  128. title: '用户ID'
  129. },
  130. {
  131. field: 'loginName',
  132. title: '登录名称',
  133. sortable: true,
  134. formatter: function (value, row, index) {
  135. return '<a href="javascript:void(0)" onclick="$.operate.view(\'' + row.userId + '\')">' + value + '</a>';
  136. }
  137. },
  138. {
  139. field: 'userName',
  140. title: '用户名称'
  141. },
  142. {
  143. field: 'dept.deptName',
  144. title: '部门'
  145. },
  146. {
  147. field: 'email',
  148. title: '邮箱',
  149. visible: false
  150. },
  151. {
  152. field: 'phonenumber',
  153. title: '手机'
  154. },
  155. {
  156. visible: editFlag == 'hidden' ? false : true,
  157. title: '用户状态',
  158. align: 'center',
  159. formatter: function (value, row, index) {
  160. return statusTools(row);
  161. }
  162. },
  163. {
  164. field: 'createTime',
  165. title: '创建时间',
  166. sortable: true
  167. },
  168. {
  169. title: '操作',
  170. align: 'center',
  171. formatter: function(value, row, index) {
  172. if (row.userId != 1) {
  173. var actions = [];
  174. 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> ');
  175. 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> ');
  176. var more = [];
  177. 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> ");
  178. 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>");
  179. 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>');
  180. return actions.join('');
  181. } else {
  182. return "";
  183. }
  184. }
  185. }]
  186. };
  187. $.table.init(options);
  188. }
  189. function queryDeptTree()
  190. {
  191. var url = ctx + "system/user/deptTreeData";
  192. var options = {
  193. url: url,
  194. expandLevel: 2,
  195. onClick : zOnClick
  196. };
  197. $.tree.init(options);
  198. function zOnClick(event, treeId, treeNode) {
  199. $("#deptId").val(treeNode.id);
  200. $("#parentId").val(treeNode.pId);
  201. $.table.search();
  202. }
  203. }
  204. $('#btnExpand').click(function() {
  205. $._tree.expandAll(true);
  206. $(this).hide();
  207. $('#btnCollapse').show();
  208. });
  209. $('#btnCollapse').click(function() {
  210. $._tree.expandAll(false);
  211. $(this).hide();
  212. $('#btnExpand').show();
  213. });
  214. $('#btnRefresh').click(function() {
  215. queryDeptTree();
  216. });
  217. /* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
  218. function resetPre() {
  219. resetDate();
  220. $("#user-form")[0].reset();
  221. $("#deptId").val("");
  222. $("#parentId").val("");
  223. $(".curSelectedNode").removeClass("curSelectedNode");
  224. $.table.search();
  225. }
  226. /* 用户管理-部门 */
  227. function dept() {
  228. var url = ctx + "system/dept";
  229. $.modal.openTab("部门管理", url);
  230. }
  231. /* 用户管理-重置密码 */
  232. function resetPwd(userId) {
  233. var url = prefix + '/resetPwd/' + userId;
  234. $.modal.open("重置密码", url, '800', '300');
  235. }
  236. /* 用户管理-分配角色 */
  237. function authRole(userId) {
  238. var url = prefix + '/authRole/' + userId;
  239. $.modal.openTab("用户分配角色", url);
  240. }
  241. /* 用户状态显示 */
  242. function statusTools(row) {
  243. if (row.status == 1) {
  244. return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
  245. } else {
  246. return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
  247. }
  248. }
  249. /* 用户管理-停用 */
  250. function disable(userId) {
  251. $.modal.confirm("确认要停用用户吗?", function() {
  252. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 1 });
  253. })
  254. }
  255. /* 用户管理启用 */
  256. function enable(userId) {
  257. $.modal.confirm("确认要启用用户吗?", function() {
  258. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
  259. })
  260. }
  261. </script>
  262. </body>
  263. <!-- 导入区域 -->
  264. <script id="importTpl" type="text/template">
  265. <form enctype="multipart/form-data" class="mt20 mb10">
  266. <div class="col-xs-offset-1">
  267. <input type="file" id="file" name="file"/>
  268. <div class="mt10 pt5">
  269. <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
  270. &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
  271. </div>
  272. <font color="red" class="pull-left mt10">
  273. 提示:仅允许导入“xls”或“xlsx”格式文件!
  274. </font>
  275. </div>
  276. </form>
  277. </script>
  278. </html>