<template>
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="导入记录" name="first">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="模块名称" prop="modelName">
            <el-select
              v-model="queryParams.modelName"
              placeholder="请选择模块名称"
              clearable
            >
              <el-option
                v-for="item in modelNameOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="文件名称" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入文件名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-input
            v-model="queryParams.status"
            placeholder="请输入状态"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="操作人" prop="createBy">
          <el-input
            v-model="queryParams.createBy"
            placeholder="请输入操作人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="错误信息" prop="error">
          <el-input
            v-model="queryParams.error"
            placeholder="请输入错误信息"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建时间">
          <el-date-picker
            v-model="queryParams.createTime"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="importExportLogList">
        <el-table-column label="模块名称" align="center" prop="modelName" />
        <el-table-column label="文件名称" align="center" prop="name" />
        <el-table-column label="状态" align="center" prop="status" />
        <el-table-column label="操作人" align="center" prop="createBy" />
        <el-table-column label="错误信息" align="center" prop="error" />
        <el-table-column label="操作时间" align="center" prop="createTime" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-tab-pane>
    <el-tab-pane label="导出记录" name="second">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="模块名称" prop="modelName">
            <el-select
              v-model="queryParams.modelName"
              placeholder="请选择模块名称"
              clearable
            >
              <el-option
                v-for="item in modelNameOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="文件名称" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入文件名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-input
            v-model="queryParams.status"
            placeholder="请输入状态"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="操作人" prop="createBy">
          <el-input
            v-model="queryParams.createBy"
            placeholder="请输入操作人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="错误信息" prop="error">
          <el-input
            v-model="queryParams.error"
            placeholder="请输入错误信息"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建时间">
          <el-date-picker
            v-model="queryParams.createTime"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="importExportLogList">
        <el-table-column label="模块名称" align="center" prop="modelName" />
        <el-table-column label="文件名称" align="center" prop="name" />
        <el-table-column label="状态" align="center" prop="status" />
        <el-table-column label="操作人" align="center" prop="createBy" />
        <el-table-column label="错误信息" align="center" prop="error" />
        <el-table-column label="操作时间" align="center" prop="createTime" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-tab-pane>
    <el-tab-pane label="文件下载记录" name="third">文件下载记录</el-tab-pane>
  </el-tabs>
</template>

<script>
import { listImportExportLog, getImportExportLog, delImportExportLog, addImportExportLog, updateImportExportLog } from "@/api/manage/importExportLog";
export default {
  name: "ImportExportLog",
  data() {
    return {
      activeName: 'first',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 导入导出日志;表格数据
      importExportLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //模块数据
      modelNameOption:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        modelName: null, //模块名称
        name: null,  //文件名称
        createBy:null,  //操作人
        error: null, //错误信息
        status: null,  //状态
        createTime:null  //创建时间
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleClick(tab, event) {
      this.getList();
    //   console.log(tab, event);
    },
    /** 查询导入导出日志;列表 */
    getList() {
      this.loading = true;
      listImportExportLog(this.queryParams).then(response => {
        console.log("response",response);
        this.importExportLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        modelName: null,
        name: null,
        error: null,
        status: null,
        createBy:null,  
        createTime:null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>