<!--
 * @Author: Guanghao
 * @Date: 2021-12-31 14:29:34
 * @LastEditors: Guanghao
 * @LastEditTime: 2022-01-05 18:56:12
 * @Description: 后台管理-角色管理页面
-->

<template>
  <div class="log back-column-one">
    <div class="back-title">{{ $route.meta.title }}</div>
    <el-tabs value="role-remember">
      <el-tab-pane label="操作日志" name="role-remember">
        <el-table :data="actionList" style="width: 100%">
          <el-table-column
            v-for="title in actionTitleList"
            :key="title.prop"
            :prop="title.prop"
            :label="title.label"
            show-overflow-tooltip
          />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="登录日志" name="role-remember2">
        <el-table :data="loginList" style="width: 100%">
          <el-table-column
            v-for="title in loginTitleList"
            :key="title.prop"
            :prop="title.prop"
            :label="title.label"
            show-overflow-tooltip
          />
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import LogBiz from "../../biz/Back/Log.js";

export default {
  name: "Log",

  data() {
    return {
      // 操作日志列表标题
      actionTitleList: [
        {
          prop: "user",
          label: "用户",
        },

        {
          prop: "time",
          label: "时间",
        },
        {
          prop: "module",
          label: "模块",
        },
        {
          prop: "position",
          label: "所在位置",
        },
        {
          prop: "action",
          label: "行为",
        },
      ],
      actionList: [], // 操作日志数据列表
      // 登录日志列表标题
      loginTitleList: [
        {
          prop: "user",
          label: "用户",
        },
        {
          prop: "time",
          label: "登录时间",
        },
        {
          prop: "result",
          label: "认证结果",
        },
        {
          prop: "ip",
          label: "IP地址",
        },
      ],
      loginList: [], // 登录日志数据列表
    };
  },

  async created() {
    const [actionList, loginList] = await Promise.all([
      LogBiz.findByAction(),
      LogBiz.findByLogin(),
    ]);
    this.actionList = actionList;
    this.loginList = loginList;
  },
};
</script>

<style lang="scss" scoped>
@import "~@/scss/Back/back.scss";
</style>
