online.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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="online-form">
  11. <div class="select-list">
  12. <ul>
  13. <li>
  14. 登录地址:<input type="text" name="ipaddr"/>
  15. </li>
  16. <li>
  17. 登录名称:<input type="text" name="loginName"/>
  18. </li>
  19. <li>
  20. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  21. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  22. </li>
  23. </ul>
  24. </div>
  25. </form>
  26. </div>
  27. <div class="btn-group-sm" id="toolbar" role="group">
  28. <a class="btn btn-danger multiple disabled" onclick="javascript:batchForceLogout()" shiro:hasPermission="monitor:online:batchForceLogout">
  29. <i class="fa fa-sign-out"></i> 强退
  30. </a>
  31. </div>
  32. <div class="col-sm-12 select-table table-striped">
  33. <table id="bootstrap-table"></table>
  34. </div>
  35. </div>
  36. </div>
  37. <th:block th:include="include :: footer" />
  38. <script th:inline="javascript">
  39. var forceFlag = [[${@permission.hasPermi('monitor:online:forceLogout')}]];
  40. var prefix = ctx + "monitor/online";
  41. $(function() {
  42. var options = {
  43. uniqueId: "sessionId",
  44. url: prefix + "/list",
  45. exportUrl: prefix + "/export",
  46. sortName: "lastAccessTime",
  47. sortOrder: "desc",
  48. showExport: true,
  49. escape: true,
  50. columns: [{
  51. checkbox: true
  52. },
  53. {
  54. title: "序号",
  55. formatter: function (value, row, index) {
  56. return $.table.serialNumber(index);
  57. }
  58. },
  59. {
  60. field: 'sessionId',
  61. title: '会话编号'
  62. },
  63. {
  64. field: 'loginName',
  65. title: '登录名称',
  66. sortable: true
  67. },
  68. {
  69. field: 'deptName',
  70. title: '部门名称'
  71. },
  72. {
  73. field: 'ipaddr',
  74. title: '主机'
  75. },
  76. {
  77. field: 'loginLocation',
  78. title: '登录地点'
  79. },
  80. {
  81. field: 'browser',
  82. title: '浏览器'
  83. },
  84. {
  85. field: 'os',
  86. title: '操作系统'
  87. },
  88. {
  89. field: 'status',
  90. title: '会话状态',
  91. align: 'center',
  92. formatter: function(value, row, index) {
  93. if (value == 'on_line') {
  94. return '<span class="badge badge-primary">在线</span>';
  95. } else if (value == 'off_line') {
  96. return '<span class="badge badge-danger">离线</span>';
  97. }
  98. }
  99. },
  100. {
  101. field: 'startTimestamp',
  102. title: '登录时间',
  103. sortable: true
  104. },
  105. {
  106. field: 'lastAccessTime',
  107. title: '最后访问时间',
  108. sortable: true
  109. },
  110. {
  111. title: '操作',
  112. align: 'center',
  113. formatter: function(value, row, index) {
  114. // 传值改成 array 类型
  115. var ids = [row.sessionId]
  116. var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + ids + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
  117. return msg;
  118. }
  119. }]
  120. };
  121. $.table.init(options);
  122. });
  123. // 单条强退
  124. // 将该请求并到 batchForceLogout 中
  125. function forceLogout(sessionId) {
  126. $.modal.confirm("确定要强制选中用户下线吗?", function() {
  127. var data = { "ids": sessionId };
  128. $.operate.post(prefix + "/batchForceLogout", data);
  129. })
  130. }
  131. // 批量强退
  132. function batchForceLogout() {
  133. var rows = $.table.selectColumns("sessionId");
  134. if (rows.length == 0) {
  135. $.modal.alertWarning("请选择要强退的用户");
  136. return;
  137. }
  138. $.modal.confirm("确认要强退选中的" + rows.length + "条数据吗?", function() {
  139. var url = prefix + "/batchForceLogout";
  140. var data = { "ids": rows };
  141. $.operate.post(url, data);
  142. });
  143. }
  144. </script>
  145. </body>
  146. </html>