index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="app-container">
  3. <doc-alert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
  4. <!-- 搜索工作栏 -->
  5. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item label="登录地址" prop="userIp">
  7. <el-input v-model="queryParams.userIp" placeholder="请输入登录地址" clearable style="width: 240px;"
  8. @keyup.enter.native="handleQuery"/>
  9. </el-form-item>
  10. <el-form-item label="用户名称" prop="username">
  11. <el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable style="width: 240px;"
  12. @keyup.enter.native="handleQuery"/>
  13. </el-form-item>
  14. <el-form-item label="状态" prop="status">
  15. <el-select v-model="queryParams.status" placeholder="结果" clearable style="width: 240px">
  16. <el-option :key="true" label="成功" :value="true"/>
  17. <el-option :key="false" label="失败" :value="false"/>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="登录时间" prop="createTime">
  21. <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  22. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  26. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-row :gutter="10" class="mb8">
  30. <el-col :span="1.5">
  31. <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  32. v-hasPermi="['system:login-log:export']">导出</el-button>
  33. </el-col>
  34. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  35. </el-row>
  36. <el-table v-loading="loading" :data="list">
  37. <el-table-column label="访问编号" align="center" prop="id" />
  38. <el-table-column label="日志类型" align="center" prop="logType" width="120">
  39. <template v-slot="scope">
  40. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="scope.row.logType" />
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="用户名称" align="center" prop="username" />
  44. <el-table-column label="登录地址" align="center" prop="userIp" width="130" :show-overflow-tooltip="true" />
  45. <el-table-column label="userAgent" align="center" prop="userAgent" width="400" :show-overflow-tooltip="true" />
  46. <el-table-column label="结果" align="center" prop="status">
  47. <template v-slot="scope">
  48. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="scope.row.result" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="登录日期" align="center" prop="loginTime" width="180">
  52. <template v-slot="scope">
  53. <span>{{ parseTime(scope.row.createTime) }}</span>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  58. @pagination="getList"/>
  59. </div>
  60. </template>
  61. <script>
  62. import { list, exportLoginLog } from "@/api/system/loginlog";
  63. export default {
  64. name: "Logininfor",
  65. data() {
  66. return {
  67. // 遮罩层
  68. loading: true,
  69. // 导出遮罩层
  70. exportLoading: false,
  71. // 显示搜索条件
  72. showSearch: true,
  73. // 总条数
  74. total: 0,
  75. // 表格数据
  76. list: [],
  77. // 状态数据字典
  78. statusOptions: [],
  79. // 查询参数
  80. queryParams: {
  81. pageNo: 1,
  82. pageSize: 10,
  83. userIp: undefined,
  84. username: undefined,
  85. status: undefined,
  86. createTime: []
  87. }
  88. };
  89. },
  90. created() {
  91. this.getList();
  92. },
  93. methods: {
  94. /** 查询登录日志列表 */
  95. getList() {
  96. this.loading = true;
  97. list(this.queryParams).then(response => {
  98. this.list = response.data.list;
  99. this.total = response.data.total;
  100. this.loading = false;
  101. }
  102. );
  103. },
  104. /** 搜索按钮操作 */
  105. handleQuery() {
  106. this.queryParams.pageNo = 1;
  107. this.getList();
  108. },
  109. /** 重置按钮操作 */
  110. resetQuery() {
  111. this.resetForm("queryForm");
  112. this.handleQuery();
  113. },
  114. /** 导出按钮操作 */
  115. handleExport() {
  116. this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => {
  117. // 处理查询参数
  118. let params = {...this.queryParams};
  119. params.pageNo = undefined;
  120. params.pageSize = undefined;
  121. this.exportLoading = true;
  122. return exportLoginLog(params);
  123. }).then(response => {
  124. this.$download.excel(response, '登录日志.xls');
  125. this.exportLoading = false;
  126. }).catch(() => {});
  127. }
  128. }
  129. };
  130. </script>