online.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: 'browser',
  24. title: '浏览器'
  25. },
  26. {
  27. field: 'os',
  28. title: '操作系统'
  29. },
  30. {
  31. field: 'status',
  32. title: '状态',
  33. align: 'center',
  34. formatter: function(value, row, index) {
  35. if (value == 'on_line') {
  36. return '<span class="label label-success">在线</span>';
  37. } else if (value == 'off_line') {
  38. return '<span class="label label-primary">离线</span>';
  39. }
  40. }
  41. },
  42. {
  43. field: 'startTimestamp',
  44. title: '登录时间'
  45. },
  46. {
  47. field: 'lastAccessTime',
  48. title: '最后访问时间'
  49. },
  50. {
  51. title: '操作',
  52. align: 'center',
  53. formatter: function(value, row, index) {
  54. var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="#" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
  55. return msg;
  56. }
  57. }];
  58. var url = prefix + "/list";
  59. $.initTable(columns, url);
  60. });
  61. // 单条强退
  62. function forceLogout(id) {
  63. $.modalConfirm("确定要强制选中用户下线吗?", function() {
  64. _ajax(prefix + "/forceLogout/" + id, "", "post");
  65. })
  66. }
  67. // 批量强退
  68. function batchForceLogout() {
  69. var rows = $.getSelections("sessionId");
  70. if (rows.length == 0) {
  71. $.modalMsg("请选择要删除的数据", modal_status.WARNING);
  72. return;
  73. }
  74. $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
  75. _ajax(prefix + '/batchForceLogout', { "ids": rows }, "post");
  76. });
  77. }