index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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="userIp">
  5. <el-input v-model="queryParams.userIp" placeholder="请输入登录地址" clearable size="small" @keyup.enter.native="handleQuery"/>
  6. </el-form-item>
  7. <el-form-item label="用户名称" prop="username">
  8. <el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable size="small" @keyup.enter.native="handleQuery"/>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  12. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. <el-table v-loading="loading" :data="list" style="width: 100%;">
  16. <el-table-column label="会话编号" align="center" prop="id" width="300" />
  17. <el-table-column label="登录名称" align="center" prop="username" width="100" />
  18. <el-table-column label="部门名称" align="center" prop="deptName" width="100" />
  19. <el-table-column label="登陆地址" align="center" prop="userIp" width="100" />
  20. <el-table-column label="userAgent" align="center" prop="userAgent" :show-overflow-tooltip="true" />
  21. <el-table-column label="登录时间" align="center" prop="createTime" width="180">
  22. <template slot-scope="scope">
  23. <span>{{ parseTime(scope.row.createTime) }}</span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  27. <template slot-scope="scope">
  28. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleForceLogout(scope.row)"
  29. v-hasPermi="['system:user-session:delete']">强退</el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. <pagination v-show="total>0" :total="total" :page.sync="pageNo" :limit.sync="pageSize" />
  34. </div>
  35. </template>
  36. <script>
  37. import { list, forceLogout } from "@/api/system/session";
  38. export default {
  39. name: "Online",
  40. data() {
  41. return {
  42. // 遮罩层
  43. loading: true,
  44. // 总条数
  45. total: 0,
  46. // 表格数据
  47. list: [],
  48. // 查询参数
  49. queryParams: {
  50. pageNo: 1,
  51. pageSize: 10,
  52. userIp: undefined,
  53. username: undefined
  54. }
  55. };
  56. },
  57. created() {
  58. this.getList();
  59. },
  60. methods: {
  61. /** 查询登录日志列表 */
  62. getList() {
  63. this.loading = true;
  64. list(this.queryParams).then(response => {
  65. this.list = response.data.list;
  66. this.total = response.data.total;
  67. this.loading = false;
  68. });
  69. },
  70. /** 搜索按钮操作 */
  71. handleQuery() {
  72. this.pageNo = 1;
  73. this.getList();
  74. },
  75. /** 重置按钮操作 */
  76. resetQuery() {
  77. this.resetForm("queryForm");
  78. this.handleQuery();
  79. },
  80. /** 强退按钮操作 */
  81. handleForceLogout(row) {
  82. this.$confirm('是否确认强退名称为"' + row.username + '"的数据项?', "警告", {
  83. confirmButtonText: "确定",
  84. cancelButtonText: "取消",
  85. type: "warning"
  86. }).then(function() {
  87. return forceLogout(row.id);
  88. }).then(() => {
  89. this.getList();
  90. this.msgSuccess("强退成功");
  91. })
  92. }
  93. }
  94. };
  95. </script>