<template>
  <div class="upload">
    <div class="gva-search-box">
      <el-form ref="searchForm" :inline="true" :model="searchInfo">
        <el-form-item label="姓名">
          <el-input clearable v-model="searchInfo.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="是否异常">
          <el-select clearable v-model="searchInfo.value" placeholder="请选择">
            <el-option label="正常" value="1"></el-option>
            <el-option label="异常" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选择日期">
          <el-date-picker
            v-model="searchInfo.date"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
          <el-button size="mini" icon="el-icon-refresh" @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="gva-table-box">

      <div class="gva-btn-list">
        <el-button class="excel-btn" size="mini" type="primary" icon="el-icon-download" @click="handleExcelExport('ExcelExport.xlsx')">导出</el-button>
        
      </div>
      <el-table :data="tableData">
        <el-table-column label="姓名" prop="ID" />
        <el-table-column label="所在部门" prop="ID" />
        <el-table-column label="工号" prop="ID" />
        <el-table-column label="是否上传行程码" prop="ID" />
        <el-table-column label="是否异常" prop="ID" />
        <el-table-column label="上传日期" prop="ID" />
      </el-table>
    </div>
  </div>
</template>

<script>
const path = import.meta.env.VITE_BASE_API
import { mapGetters } from 'vuex'
import infoList from '@/mixins/infoList'
import { exportExcel, loadExcelData, downloadTemplate } from '@/api/excel'
import { getMenuList } from '@/api/menu'
export default {
  name: 'Excel',
  mixins: [infoList],
  data() {
    return {
      listApi: getMenuList,
      path: path
    }
  },
  computed: {
    ...mapGetters('user', ['userInfo', 'token'])
  },
  created() {
    this.pageSize = 999
    this.getTableData()
  },
  methods: {
    handleExcelExport(fileName) {
      if (!fileName || typeof fileName !== 'string') {
        fileName = 'ExcelExport.xlsx'
      }
      exportExcel(this.tableData, fileName)
    },
    loadExcel() {
      this.listApi = loadExcelData
      this.getTableData()
    },
    downloadExcelTemplate() {
      downloadTemplate('ExcelTemplate.xlsx')
    }
  }
}
</script>

<style lang="scss" scoped>
.btn-list{
  display: flex;
  margin-bottom: 12px;
  justify-content: flex-end;

}
.excel-btn+.excel-btn{
  margin-left: 10px;
}
</style>
