index.vue 3.7 KB

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