<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="list">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column :label="$t('文件名')" align="center" prop="fileName" />
      <el-table-column :label="$t('文件路径')" align="center" prop="fileUrl" />
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleDownload(scope.row)"
          >{{ $t('下载') }}</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { list } from "@/api/monitor/log";

export default {
  name: "Log",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 下载操作日志 */
    handleDownload(row) {
      window.location.href = process.env.VUE_APP_BASE_API + "/monitor/log/download?fileName=" + encodeURI(row.fileName) + "&fileUrl=" + encodeURI(row.fileUrl);
    },
    /** 查询操作日志 */
    getList() {
      this.loading = true;
      list().then(response => {
          this.list = response.data;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
  }
};
</script>

