authUser.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 search-collapse">
  10. <form id="role-form">
  11. <input type="hidden" id="roleId" name="roleId" th:value="${role.roleId}">
  12. <div class="select-list">
  13. <ul>
  14. <li>
  15. 登录名称:<input type="text" name="loginName"/>
  16. </li>
  17. <li>
  18. 手机号码:<input type="text" name="phonenumber"/>
  19. </li>
  20. <li>
  21. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  22. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  23. </li>
  24. </ul>
  25. </div>
  26. </form>
  27. </div>
  28. <div class="btn-group-sm" id="toolbar" role="group">
  29. <a class="btn btn-success" onclick="selectUser()" shiro:hasPermission="system:role:add">
  30. <i class="fa fa-plus"></i> 添加用户
  31. </a>
  32. <a class="btn btn-danger multiple disabled" onclick="cancelAuthUserAll()" shiro:hasPermission="system:role:remove">
  33. <i class="fa fa-remove"></i> 批量取消授权
  34. </a>
  35. <a class="btn btn-warning" onclick="closeItem()">
  36. <i class="fa fa-reply-all"></i> 关闭
  37. </a>
  38. </div>
  39. <div class="col-sm-12 select-table table-striped">
  40. <table id="bootstrap-table"></table>
  41. </div>
  42. </div>
  43. </div>
  44. <th:block th:include="include :: footer" />
  45. <script th:inline="javascript">
  46. var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
  47. var datas = [[${@dict.getType('sys_normal_disable')}]];
  48. var prefix = ctx + "system/role/authUser";
  49. $(function() {
  50. var options = {
  51. url: prefix + "/allocatedList",
  52. createUrl: prefix + "/add",
  53. updateUrl: prefix + "/edit/{id}",
  54. removeUrl: prefix + "/remove",
  55. exportUrl: prefix + "/export",
  56. importUrl: prefix + "/importData",
  57. importTemplateUrl: prefix + "/importTemplate",
  58. queryParams: queryParams,
  59. sortName: "createTime",
  60. sortOrder: "desc",
  61. modalName: "用户",
  62. columns: [{
  63. checkbox: true
  64. },
  65. {
  66. field: 'userId',
  67. title: '用户ID',
  68. visible: false
  69. },
  70. {
  71. field: 'loginName',
  72. title: '登录名称',
  73. sortable: true
  74. },
  75. {
  76. field: 'userName',
  77. title: '用户名称'
  78. },
  79. {
  80. field: 'email',
  81. title: '邮箱'
  82. },
  83. {
  84. field: 'phonenumber',
  85. title: '手机'
  86. },
  87. {
  88. field: 'status',
  89. title: '用户状态',
  90. align: 'center',
  91. formatter: function (value, row, index) {
  92. return $.table.selectDictLabel(datas, value);
  93. }
  94. },
  95. {
  96. field: 'createTime',
  97. title: '创建时间',
  98. sortable: true
  99. },
  100. {
  101. title: '操作',
  102. align: 'center',
  103. formatter: function(value, row, index) {
  104. var actions = [];
  105. actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="cancelAuthUser(\'' + row.userId + '\')"><i class="fa fa-remove"></i>取消授权</a> ');
  106. return actions.join('');
  107. }
  108. }]
  109. };
  110. $.table.init(options);
  111. });
  112. function queryParams(params) {
  113. var search = $.table.queryParams(params);
  114. search.roleId = $("#roleId").val();
  115. return search;
  116. }
  117. /* 分配用户-选择用户 */
  118. function selectUser() {
  119. var url = prefix + '/selectUser/' + $("#roleId").val();
  120. $.modal.open("选择用户", url);
  121. }
  122. /* 分配用户-批量取消授权 */
  123. function cancelAuthUserAll(userId) {
  124. var rows = $.table.selectFirstColumns();
  125. if (rows.length == 0) {
  126. $.modal.alertWarning("请至少选择一条记录");
  127. return;
  128. }
  129. $.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
  130. var data = { "roleId": $("#roleId").val(), "userIds": rows.join() };
  131. $.operate.submit(prefix + "/cancelAll", "post", "json", data);
  132. });
  133. }
  134. /* 分配用户-取消授权 */
  135. function cancelAuthUser(userId) {
  136. $.modal.confirm("确认要取消该用户角色吗?", function() {
  137. $.operate.post(prefix + "/cancel", { "roleId": $("#roleId").val(), "userId": userId });
  138. })
  139. }
  140. </script>
  141. </body>
  142. </html>