index.vue 4.5 KB

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