index.vue 3.8 KB

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