user.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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-bordered">
  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. uniqueId: 'userId',
  120. modalName: "用户",
  121. columns: [
  122. {
  123. title: "序号",
  124. align: 'center',
  125. formatter: function (value, row, index) {
  126. return $.table.serialNumber(index);
  127. }
  128. },
  129. {
  130. field: 'loginName',
  131. title: '登录名称',
  132. align: 'center',
  133. sortable: true
  134. },
  135. {
  136. field: 'userName',
  137. title: '用户名称',
  138. align: 'center'
  139. },
  140. {
  141. visible: editFlag == 'hidden' ? false : true,
  142. title: '用户状态',
  143. align: 'center',
  144. formatter: function (value, row, index) {
  145. return statusTools(row);
  146. }
  147. },
  148. {
  149. field: 'createTime',
  150. title: '创建时间',
  151. align: 'center',
  152. sortable: true
  153. },
  154. {
  155. title: '操作',
  156. align: 'center',
  157. formatter: function(value, row, index) {
  158. if (row.userId != 1) {
  159. var actions = [];
  160. 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> ');
  161. /*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> ');*/
  162. var more = [];
  163. 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> ");
  164. /*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>");*/
  165. 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>');
  166. return actions.join('');
  167. } else {
  168. return "";
  169. }
  170. }
  171. }]
  172. };
  173. $.table.init(options);
  174. }
  175. function queryDeptTree()
  176. {
  177. var url = ctx + "system/dept/treeData";
  178. var options = {
  179. url: url,
  180. expandLevel: 2,
  181. onClick : zOnClick
  182. };
  183. $.tree.init(options);
  184. function zOnClick(event, treeId, treeNode) {
  185. $("#deptId").val(treeNode.id);
  186. $("#parentId").val(treeNode.pId);
  187. $.table.search();
  188. }
  189. }
  190. $('#btnExpand').click(function() {
  191. $._tree.expandAll(true);
  192. $(this).hide();
  193. $('#btnCollapse').show();
  194. });
  195. $('#btnCollapse').click(function() {
  196. $._tree.expandAll(false);
  197. $(this).hide();
  198. $('#btnExpand').show();
  199. });
  200. $('#btnRefresh').click(function() {
  201. queryDeptTree();
  202. });
  203. /* 用户管理-部门 */
  204. function dept() {
  205. var url = ctx + "system/dept";
  206. $.modal.openTab("部门管理", url);
  207. }
  208. /* 用户管理-重置密码 */
  209. function resetPwd(userId) {
  210. var url = prefix + '/resetPwd/' + userId;
  211. $.modal.open("重置密码", url, '800', '300');
  212. }
  213. /* 用户管理-分配角色 */
  214. function authRole(userId) {
  215. var url = prefix + '/authRole/' + userId;
  216. $.modal.openTab("用户分配角色", url);
  217. }
  218. /* 用户状态显示 */
  219. function statusTools(row) {
  220. if (row.status == 1) {
  221. return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
  222. } else {
  223. return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
  224. }
  225. }
  226. /* 用户管理-停用 */
  227. function disable(userId) {
  228. $.modal.confirm("确认要停用用户吗?", function() {
  229. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 1 });
  230. })
  231. }
  232. /* 用户管理启用 */
  233. function enable(userId) {
  234. $.modal.confirm("确认要启用用户吗?", function() {
  235. $.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
  236. })
  237. }
  238. </script>
  239. </body>
  240. <!-- 导入区域 -->
  241. <script id="importTpl" type="text/template">
  242. <form enctype="multipart/form-data" class="mt20 mb10">
  243. <div class="col-xs-offset-1">
  244. <input type="file" id="file" name="file"/>
  245. <div class="mt10 pt5">
  246. <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
  247. &nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
  248. </div>
  249. <font color="red" class="pull-left mt10">
  250. 提示:仅允许导入“xls”或“xlsx”格式文件!
  251. </font>
  252. </div>
  253. </form>
  254. </script>
  255. </html>