authUser.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. queryParams: queryParams,
  53. sortName: "createTime",
  54. sortOrder: "desc",
  55. columns: [{
  56. checkbox: true
  57. },
  58. {
  59. field: 'userId',
  60. title: '用户ID',
  61. visible: false
  62. },
  63. {
  64. field: 'loginName',
  65. title: '登录名称',
  66. sortable: true
  67. },
  68. {
  69. field: 'userName',
  70. title: '用户名称'
  71. },
  72. {
  73. field: 'email',
  74. title: '邮箱'
  75. },
  76. {
  77. field: 'phonenumber',
  78. title: '手机'
  79. },
  80. {
  81. field: 'status',
  82. title: '用户状态',
  83. align: 'center',
  84. formatter: function (value, row, index) {
  85. return $.table.selectDictLabel(datas, value);
  86. }
  87. },
  88. {
  89. field: 'createTime',
  90. title: '创建时间',
  91. sortable: true
  92. },
  93. {
  94. title: '操作',
  95. align: 'center',
  96. formatter: function(value, row, index) {
  97. var actions = [];
  98. 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> ');
  99. return actions.join('');
  100. }
  101. }]
  102. };
  103. $.table.init(options);
  104. });
  105. function queryParams(params) {
  106. var search = $.table.queryParams(params);
  107. search.roleId = $("#roleId").val();
  108. return search;
  109. }
  110. /* 分配用户-选择用户 */
  111. function selectUser() {
  112. var url = prefix + '/selectUser/' + $("#roleId").val();
  113. $.modal.open("选择用户", url);
  114. }
  115. /* 分配用户-批量取消授权 */
  116. function cancelAuthUserAll(userId) {
  117. var rows = $.table.selectFirstColumns();
  118. if (rows.length == 0) {
  119. $.modal.alertWarning("请至少选择一条记录");
  120. return;
  121. }
  122. $.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
  123. var data = { "roleId": $("#roleId").val(), "userIds": rows.join() };
  124. $.operate.submit(prefix + "/cancelAll", "post", "json", data);
  125. });
  126. }
  127. /* 分配用户-取消授权 */
  128. function cancelAuthUser(userId) {
  129. $.modal.confirm("确认要取消该用户角色吗?", function() {
  130. $.operate.post(prefix + "/cancel", { "roleId": $("#roleId").val(), "userId": userId });
  131. })
  132. }
  133. </script>
  134. </body>
  135. </html>