<template>
  <div class="container-box">
    <div class="search-box">
      <el-form
        :inline="true"
        ref="searchForm"
        :model="searchForm"
        class="demo-form-inline"
        label-width="auto"
        size="mini"
      >
        <el-form-item label="文件名">
          <el-input
            v-model="searchForm.farm"
            placeholder="请输入文件名"
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="success" icon="el-icon-search" @click="searchClick"
            >搜索</el-button
          >
          <el-button type="warning" icon="el-icon-refresh" @click="resetClick"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="list-box">
      <el-table :data="tableData" style="width: 100%" size="mini" border>
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="a" label="文件名"></el-table-column>
        <el-table-column prop="b" label="文件大小"></el-table-column>
        <el-table-column prop="c" label="上传时间"></el-table-column>
        <el-table-column prop="d" label="品种"></el-table-column>
        <el-table-column prop="e" label="文件状态"></el-table-column>
        <el-table-column label="操作">
          <el-button size="mini" type="text" class="detail-btn">
            <a
              href="https://smart-1259258654.cos.ap-guangzhou.myqcloud.com/pdf/CX_82010000990.txt"
              target="_blank"
              rel="noopener noreferrer"
              >下载</a
            >
          </el-button>
        </el-table-column>
      </el-table>
      <div class="page-box">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[20, 50, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="form.page"
          :page-size="form.pagesize"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchForm: {
        farm: '',
        number: ''
      },
      tableData: [
        {
          id: 0,
          a: 'CX_82010000990',
          b: '10.23MB',
          c: '2024-03-06',
          d: '九龙牦牛',
          e: '已上传'
        },
        {
          id: 1,
          a: 'CX_82010000991',
          b: '11.05MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        },
        {
          id: 2,
          a: 'CX_82010000992',
          b: '12.36MB',
          c: '2024-03-06',
          d: '华西牛',
          e: '已上传'
        },
        {
          id: 3,
          a: 'CX_82010000993',
          b: '14.78MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        },
        {
          id: 4,
          a: 'CX_82010000994',
          b: '14.36MB',
          c: '2024-03-06',
          d: '西藏高山牦牛',
          e: '已上传'
        },
        {
          id: 5,
          a: 'CX_82010000995',
          b: '18.64MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        },
        {
          id: 6,
          a: 'CX_82010000996',
          b: '15.78MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        },
        {
          id: 7,
          a: 'CX_82010000997',
          b: '13.85MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        },
        {
          id: 8,
          a: 'CX_82010000998',
          b: '16.12MB',
          c: '2024-03-06',
          d: '西门塔尔',
          e: '已上传'
        }
      ],
      form: {
        page: 1,
        pagesize: 20
      },
      total: 9
    }
  },
  methods: {
    // 搜索
    searchClick() {},
    // 重置
    resetClick() {
      for (const key in this.searchForm) {
        this.searchForm[key] = ''
      }
    },
    // 条
    handleSizeChange(val) {
      this.form.pagesize = parseInt(val)
    },
    // 页
    handleCurrentChange(val) {
      this.form.page = parseInt(val)
    },
    download(id) {
      this.$message({
        message: '下载成功',
        type: 'success'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.container-box {
  min-height: calc(100vh - 84px);
  padding: 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  .search-box {
    background: #fff;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 25px;
  }
  .list-box {
    flex: 1;
    background: #fff;
    border-radius: 6px;
    padding: 10px 15px;
    .detail-btn {
      color: #67c23a;
    }
    .page-box {
      margin-top: 10px;
    }
  }
}
.el-form-item {
  margin-bottom: 0px;
  margin-right: 20px;
}
// table
/deep/.el-table th.el-table__cell {
  background-color: #f5f7fa;
}
/deep/ .cell {
  font-weight: normal;
}
</style>
