<template>
  <div class="app-container">
    <div class="header boxShadow">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <!-- <el-form-item label="仓房名称">
          <el-select v-model="formInline.barnName" placeholder="活动区域" clearable>
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="检测日期">
          <el-date-picker type="date" placeholder="选择日期" v-model="formInline.testDate" style="width: 100%;" clearable></el-date-picker>
          </el-date-picker>
        </el-form-item>
        <el-form-item class="fr">
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <!-- <el-button type="primary" @click="onSubmit">粮情检测</el-button> -->
        </el-form-item>
      </el-form>
    </div>
    <van-list>
      <div class="list boxShadow" v-for="(item,index) in list" :key="index">
        <div class="list-main">
          <div class="list-content">
            <div class="list-title">{{ item.title}}</div>
            <van-row class="content-1">
              <van-col span="6">害虫监测单号:<span class="text-colorc">{{item.lhq}}</span></van-col>
              <van-col span="6">通道号:<span class="text-colorc">{{item.oxygen}}</span></van-col>
              <van-col span="6">害虫种类: <span class="text-colorc">{{item.co2}} </span></van-col>
              <!-- <van-col span="6">是否存在异常:<span><strong>{{item.isAbnormal}}</strong> </span></van-col> -->
            </van-row>
            <van-row class="content-1">
              <van-col span="6" class="color-red">虫情:<span>{{item.pest}} </span></van-col>
              <van-col span="6">检测时间:<span class="text-colorc">{{item.collectTime}} </span></van-col>
              <van-col span="6">采集人:<span class="text-colorc">{{item.gatherer}} </span></van-col>
              <!-- <van-col span="6">检测时间:<span class="text-colorc">{{item.detectionTime}} </span></van-col> -->
            </van-row>
          </div>
          <div class="list-btns">
            <el-button type="primary" @click="handleDetail">详情</el-button>
            <el-button type="primary" @click="onSubmit">检测</el-button>
          </div>
        </div>

      </div>
    </van-list>
    <div class="pagination-container">
      <el-pagination class="right" background :current-page.sync="listQuery.page" :page-size="listQuery.limit" :page-sizes="[5, 10, 20, 30]" :total="listQuery.total" @size-change="sizeChange" @current-change="pageChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
    </div>
  </div>
</template>

<script>
import { getList } from '@/api/table'

export default {
  filters: {

  },
  data () {
    return {
      formInline: {
        barnName: '',
        testDate: ''
      },
      list: [
        { title: '1号仓房', lhq: '32', oxygen: '4', co2: '虫害', pest: '玉米虫', gatherer: '王全德', collectTime: '2021-01-12' },
        { title: '1号仓房', lhq: '32', oxygen: '4', co2: '虫害', pest: '玉米虫', gatherer: '王全德', collectTime: '2021-01-12' },
        { title: '1号仓房', lhq: '32', oxygen: '4', co2: '虫害', pest: '玉米虫', gatherer: '王全德', collectTime: '2021-01-12' },
        { title: '1号仓房', lhq: '32', oxygen: '4', co2: '虫害', pest: '玉米虫', gatherer: '王全德', collectTime: '2021-01-12' },

      ],
      loading: 'false',
      finished: 'false',

      listQuery: {
        condition: "",
        page: 1,
        limit: 10,
        total: 10,
      },
    }
  },
  created () {

  },
  methods: {
    onSubmit () {
      console.log('submit!');
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`);
    },
    handleDetail () {
      this.$router.push({ name: 'PestDetectionDetail' })
    },
    sizeChange (v) {
      this.listQuery.limit = v
      console.log(`每页 ${v} 条`);
      this.list.splice(v, this.list.length - 1)
    },
    pageChange (v) {
      this.listQuery.page = v
      console.log(`当前页: ${v}`);
    },
  }
}
</script>
<style lang='scss' scoped>
.boxShadow {
  box-shadow: 5px -5px 10px -4px #efe3e3, -5px 5px 10px -4px #efe3e3;
}
::v-deep .van-notice-bar {
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.header {
  background-color: #fff;
  border-radius: 15px;
  padding: 15px;
  // height: 160px;
  .header-title {
    font-size: 14px;
    font-weight: 600;
    padding-left: 10px;
    border-left: 4px solid #5283e7;
  }
  .el-form {
    .el-form-item {
      margin-bottom: 0;
    }
    .fr {
      float: right;
    }
  }
}
.list {
  background-color: #fff;
  border-radius: 15px;
  margin-top: 10px;
  .list-main {
    padding-left: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    .list-title {
      font-size: 15px;
      font-weight: 700;
      padding: 10px 0;
    }
    .list-content {
      width: 80%;
      .content-1 {
        font-size: 14px;
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        // padding: 5px 0;
        strong {
          color: #d24848;
        }
        .text-colorc {
          color: #b8b8b8;
        }
        .color-red {
          color: #f12b07;
          font-weight: 600;
        }
      }
      .content-1:nth-last-child(1) {
        padding-bottom: 10px;
      }
    }
    .list-btns {
      width: 20%;
      background-color: #edf2fd;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
    }
  }
}
</style>
