<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.a"
            placeholder="请输入养殖场"
          ></el-input>
        </el-form-item>
        <el-form-item label="标记编号">
          <el-input
            v-model="searchForm.b"
            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 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 prop="d" label="疑是父母编号"></el-table-column>
        <el-table-column prop="e" label="相似度"></el-table-column>
        <el-table-column label="亲缘关系结果">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="download(scope.row.id)"
              class="detail-btn"
              >查看</el-button
            >
          </template>
        </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: {
        a: '',
        b: ''
      },
      tableData: [
        {
          id: 0,
          a: '若尔盖',
          b: '82010000991',
          c: '雌',
          d: '8',
          e: '血液',
          f: '82020000981',
          g: '99.99%'
        },
        {
          id: 1,
          a: '若尔盖',
          b: '82010000992',
          c: '雌',
          d: '6',
          e: '血液',
          f: '82020000986',
          g: '69.99%'
        },
        {
          id: 2,
          a: '若尔盖',
          b: '82010000994',
          c: '雌',
          d: '6',
          e: '血液',
          f: '82020000985',
          g: '79.99%'
        },
        {
          id: 3,
          a: '若尔盖',
          b: '82010000995',
          c: '雌',
          d: '6',
          e: '血液',
          f: '82020000989',
          g: '98.99%'
        },
        {
          id: 3,
          a: '若尔盖',
          b: '82010000998',
          c: '雌',
          d: '6',
          e: '血液',
          f: '82020000976',
          g: '78.99%'
        }
      ],
      form: {
        page: 1,
        pagesize: 20
      },
      total: 5
    }
  },
  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>
