user.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. 用户状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
  41. <option value="">所有</option>
  42. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  43. </select>
  44. </li>
  45. <li class="select-time">
  46. <label>创建时间: </label>
  47. <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
  48. <span>-</span>
  49. <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
  50. </li>
  51. <li>
  52. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  53. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  54. </li>
  55. </ul>
  56. </div>
  57. </form>
  58. </div>
  59. <div class="btn-group-sm" id="toolbar" role="group">
  60. <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:user:add">
  61. <i class="fa fa-plus"></i> 新增
  62. </a>
  63. <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:user:edit">
  64. <i class="fa fa-edit"></i> 修改
  65. </a>
  66. <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:user:remove">
  67. <i class="fa fa-remove"></i> 删除
  68. </a>
  69. <!--<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">-->
  70. <!--<i class="fa fa-upload"></i> 导入-->
  71. <!--</a>-->
  72. <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export">-->
  73. <!--<i class="fa fa-download"></i> 导出-->
  74. <!--</a>-->
  75. </div>
  76. <div class="col-sm-12 select-table table-striped">
  77. <table id="bootstrap-table"></table>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <th:block th:include="include :: footer" />
  83. <th:block th:include="include :: layout-latest-js" />
  84. <th:block th:include="include :: ztree-js" />
  85. <script th:inline="javascript">
  86. var editFlag = [[${@permission.hasPermi('system:user:edit')}]];
  87. var removeFlag = [[${@permission.hasPermi('system:user:remove')}]];
  88. var resetPwdFlag = [[${@permission.hasPermi('system:user:resetPwd')}]];
  89. var prefix = ctx + "system/user";
  90. $(function() {
  91. var panehHidden = false;
  92. if ($(this).width() < 769) {
  93. panehHidden = true;
  94. }
  95. $('body').layout({ initClosed: panehHidden, west__size: 185 });
  96. queryUserList();
  97. queryDeptTree();
  98. });
  99. function queryUserList() {
  100. var options = {
  101. url: prefix + "/list",
  102. createUrl: prefix + "/add",
  103. updateUrl: prefix + "/edit/{id}",
  104. removeUrl: prefix + "/remove",
  105. exportUrl: prefix + "/export",
  106. importUrl: prefix + "/importData",
  107. importTemplateUrl: prefix + "/importTemplate",
  108. sortName: "createTime",
  109. sortOrder: "desc",
  110. modalName: "用户",
  111. columns: [{
  112. checkbox: true
  113. },
  114. {
  115. field: 'userId',
  116. title: '用户ID',
  117. visible:false
  118. },
  119. {
  120. field: 'userName',
  121. title: '用户姓名'
  122. },
  123. {
  124. field: 'loginName',
  125. title: '登录名称',
  126. sortable: true
  127. },
  128. {
  129. field: 'roleNames',
  130. title: '角色',
  131. },
  132. {
  133. field: 'dept.deptName',
  134. title: '所属机构'
  135. },
  136. {
  137. visible: editFlag == 'hidden' ? false : true,
  138. title: '用户状态',
  139. align: 'center',
  140. formatter: function (value, row, index) {
  141. return statusTools(row);
  142. }
  143. },
  144. {
  145. field: 'createTime',
  146. title: '创建时间',
  147. sortable: true
  148. },
  149. {
  150. title: '操作',
  151. align: 'center',
  152. formatter: function(value, row, index) {
  153. var actions = [];
  154. 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> ');
  155. 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> ');
  156. actions.push("<a class='btn btn-info btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authRole(" + row.userId + ")'><i class='fa fa-check-square-o'></i>分配角色</a> ");
  157. actions.push("<a class='btn btn-warning btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authChild("+row.userId+")'><i class='fa fa-edit'></i>添加子账号</a> ");
  158. actions.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='findChild("+row.userId+")'><i class='fa fa-eye'></i>查看子账号</a>");
  159. return actions.join('');
  160. }
  161. }]
  162. };
  163. $.table.init(options);
  164. }
  165. function queryDeptTree()
  166. {
  167. var url = ctx + "system/user/deptTreeData";
  168. var options = {
  169. url: url,
  170. expandLevel: 2,
  171. onClick : zOnClick
  172. };
  173. $.tree.init(options);
  174. function zOnClick(event, treeId, treeNode) {
  175. $("#deptId").val(treeNode.id);
  176. $("#parentId").val(treeNode.pId);
  177. $.table.search();
  178. }
  179. }
  180. $('#btnExpand').click(function() {
  181. $._tree.expandAll(true);
  182. $(this).hide();
  183. $('#btnCollapse').show();
  184. });
  185. $('#btnCollapse').click(function() {
  186. $._tree.expandAll(false);
  187. $(this).hide();
  188. $('#btnExpand').show();
  189. });
  190. $('#btnRefresh').click(function() {
  191. queryDeptTree();
  192. });
  193. /* 用户管理-机构 */
  194. function dept() {
  195. var url = ctx + "system/dept";
  196. $.modal.openTab("机构管理", url);
  197. }
  198. /* 用户管理-重置密码 */
  199. function resetPwd(userId) {
  200. var url = prefix + '/resetPwd/' + userId;
  201. $.modal.open("修改密码", url, '800', '300');
  202. }
  203. /* 用户管理-分配角色 */
  204. function authRole(userId) {
  205. var url = prefix + '/authRole/' + userId;
  206. $.modal.openTab("用户分配角色", url);
  207. }
  208. /* 用户管理-编辑子账号 */
  209. function authChild(userId) {
  210. var url = prefix + '/authChild/' + userId;
  211. $.modal.open("添加子用户", url,window.width,600);
  212. }
  213. /* 用户管理-查看子账号 */
  214. function findChild(userId) {
  215. var url = prefix + '/findChild/' + userId;
  216. $.modal.open("查看子用户", url,window.width,600);
  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>