index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="app-container">
  3. <el-form :inline="true" label-width="68px">
  4. <el-form-item label="登录地址">
  5. <el-input
  6. v-model="queryParams.ipaddr"
  7. placeholder="请输入登录地址"
  8. clearable
  9. style="width: 240px;"
  10. size="small"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="用户名称">
  15. <el-input
  16. v-model="queryParams.userName"
  17. placeholder="请输入用户名称"
  18. clearable
  19. style="width: 240px;"
  20. size="small"
  21. @keyup.enter.native="handleQuery"
  22. />
  23. </el-form-item>
  24. <el-form-item label="状态">
  25. <el-select
  26. v-model="queryParams.status"
  27. placeholder="登录状态"
  28. clearable
  29. size="small"
  30. style="width: 240px"
  31. >
  32. <el-option
  33. v-for="dict in statusOptions"
  34. :key="dict.dictValue"
  35. :label="dict.dictLabel"
  36. :value="dict.dictValue"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="登录时间">
  41. <el-date-picker
  42. v-model="dateRange"
  43. size="small"
  44. style="width: 240px"
  45. value-format="yyyy-MM-dd"
  46. type="daterange"
  47. range-separator="-"
  48. start-placeholder="开始日期"
  49. end-placeholder="结束日期"
  50. ></el-date-picker>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  54. </el-form-item>
  55. </el-form>
  56. <el-table v-loading="loading" :data="list" style="width: 100%;">
  57. <el-table-column label="访问编号" align="center" prop="infoId" />
  58. <el-table-column label="用户名称" align="center" prop="userName" />
  59. <el-table-column label="登录地址" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
  60. <el-table-column label="登录地点" align="center" prop="loginLocation" />
  61. <el-table-column label="浏览器" align="center" prop="browser" />
  62. <el-table-column label="操作系统" align="center" prop="os" />
  63. <el-table-column label="登录状态" align="center" prop="status" :formatter="statusFormat" />
  64. <el-table-column label="操作信息" align="center" prop="msg" />
  65. <el-table-column label="登录日期" align="center" prop="loginTime" width="180">
  66. <template slot-scope="scope">
  67. <span>{{ parseTime(scope.row.loginTime) }}</span>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <pagination
  72. v-show="total>0"
  73. :total="total"
  74. :page.sync="queryParams.pageNum"
  75. :limit.sync="queryParams.pageSize"
  76. @pagination="getList"
  77. />
  78. </div>
  79. </template>
  80. <script>
  81. import { list } from "@/api/monitor/logininfor";
  82. export default {
  83. data() {
  84. return {
  85. // 遮罩层
  86. loading: true,
  87. // 总条数
  88. total: 0,
  89. // 表格数据
  90. list: [],
  91. // 状态数据字典
  92. statusOptions: [],
  93. // 日期范围
  94. dateRange: [],
  95. // 查询参数
  96. queryParams: {
  97. pageNum: 1,
  98. pageSize: 10,
  99. ipaddr: undefined,
  100. userName: undefined,
  101. status: undefined
  102. }
  103. };
  104. },
  105. created() {
  106. this.getList();
  107. this.getDicts("sys_common_status").then(response => {
  108. this.statusOptions = response.data;
  109. });
  110. },
  111. methods: {
  112. /** 查询登录日志列表 */
  113. getList() {
  114. this.loading = true;
  115. list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  116. this.list = response.rows;
  117. this.total = response.total;
  118. this.loading = false;
  119. }
  120. );
  121. },
  122. // 登录状态字典翻译
  123. statusFormat(row, column) {
  124. return this.selectDictLabel(this.statusOptions, row.status);
  125. },
  126. /** 搜索按钮操作 */
  127. handleQuery() {
  128. this.queryParams.pageNum = 1;
  129. this.getList();
  130. }
  131. }
  132. };
  133. </script>