index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
  4. <el-form-item label="登录地址" prop="ipaddr">
  5. <el-input
  6. v-model="queryParams.ipaddr"
  7. placeholder="请输入登录地址"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="用户名称" prop="userName">
  13. <el-input
  14. v-model="queryParams.userName"
  15. placeholder="请输入用户名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-table
  26. v-loading="loading"
  27. :data="list.slice((pageNum-1)*pageSize,pageNum*pageSize)"
  28. style="width: 100%;"
  29. >
  30. <el-table-column label="序号" type="index" align="center">
  31. <template slot-scope="scope">
  32. <span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="会话编号" align="center" prop="tokenId" :show-overflow-tooltip="true" />
  36. <el-table-column label="登录名称" align="center" prop="userName" :show-overflow-tooltip="true" />
  37. <el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
  38. <el-table-column label="登录时间" align="center" prop="loginTime" width="180">
  39. <template slot-scope="scope">
  40. <span>{{ parseTime(scope.row.loginTime) }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  44. <template slot-scope="scope">
  45. <el-button
  46. size="mini"
  47. type="text"
  48. icon="el-icon-delete"
  49. @click="handleForceLogout(scope.row)"
  50. v-hasPermi="['monitor:online:forceLogout']"
  51. >强退</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
  56. </div>
  57. </template>
  58. <script>
  59. import { list, forceLogout } from "@/api/monitor/online";
  60. export default {
  61. name: "Online",
  62. data() {
  63. return {
  64. // 遮罩层
  65. loading: true,
  66. // 总条数
  67. total: 0,
  68. // 表格数据
  69. list: [],
  70. pageNum: 1,
  71. pageSize: 10,
  72. // 查询参数
  73. queryParams: {
  74. ipaddr: undefined,
  75. userName: undefined
  76. }
  77. };
  78. },
  79. created() {
  80. this.getList();
  81. },
  82. methods: {
  83. /** 查询登录日志列表 */
  84. getList() {
  85. this.loading = true;
  86. list(this.queryParams).then(response => {
  87. this.list = response.rows;
  88. this.total = response.total;
  89. this.loading = false;
  90. });
  91. },
  92. /** 搜索按钮操作 */
  93. handleQuery() {
  94. this.pageNum = 1;
  95. this.getList();
  96. },
  97. /** 重置按钮操作 */
  98. resetQuery() {
  99. this.resetForm("queryForm");
  100. this.handleQuery();
  101. },
  102. /** 强退按钮操作 */
  103. handleForceLogout(row) {
  104. this.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?').then(function() {
  105. return forceLogout(row.tokenId);
  106. }).then(() => {
  107. this.getList();
  108. this.$modal.msgSuccess("强退成功");
  109. }).catch(() => {});
  110. }
  111. }
  112. };
  113. </script>