online.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. var prefix = ctx + "monitor/online"
  2. $(function() {
  3. var columns = [{
  4. checkbox: true
  5. },
  6. {
  7. field: 'sessionId',
  8. title: '会话编号'
  9. },
  10. {
  11. field: 'loginName',
  12. title: '登录名称'
  13. },
  14. {
  15. field: 'deptName',
  16. title: '部门名称'
  17. },
  18. {
  19. field: 'ipaddr',
  20. title: '主机'
  21. },
  22. {
  23. field: 'longinLocation',
  24. title: '登录地点'
  25. },
  26. {
  27. field: 'browser',
  28. title: '浏览器'
  29. },
  30. {
  31. field: 'os',
  32. title: '操作系统'
  33. },
  34. {
  35. field: 'status',
  36. title: '状态',
  37. align: 'center',
  38. formatter: function(value, row, index) {
  39. if (value == 'on_line') {
  40. return '<span class="badge badge-primary">在线</span>';
  41. } else if (value == 'off_line') {
  42. return '<span class="badge badge-danger">离线</span>';
  43. }
  44. }
  45. },
  46. {
  47. field: 'startTimestamp',
  48. title: '登录时间'
  49. },
  50. {
  51. field: 'lastAccessTime',
  52. title: '最后访问时间'
  53. },
  54. {
  55. title: '操作',
  56. align: 'center',
  57. formatter: function(value, row, index) {
  58. var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="#" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
  59. return msg;
  60. }
  61. }];
  62. var url = prefix + "/list";
  63. $.initTable(columns, url);
  64. });
  65. // 单条强退
  66. function forceLogout(id) {
  67. $.modalConfirm("确定要强制选中用户下线吗?", function() {
  68. _ajax(prefix + "/forceLogout/" + id, "", "post");
  69. })
  70. }
  71. // 批量强退
  72. function batchForceLogout() {
  73. var rows = $.getSelections("sessionId");
  74. if (rows.length == 0) {
  75. $.modalMsg("请选择要删除的数据", modal_status.WARNING);
  76. return;
  77. }
  78. $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
  79. _ajax(prefix + '/batchForceLogout', { "ids": rows }, "post");
  80. });
  81. }