<template>
  <div>
    <div class="c-left">
      <div>
        <span class="box-title1">全区农药使用监管</span>
        <ul class="row-overview">
          <li v-for="item in leftTopData" :key="item.title">
            <span>{{ item.title }}</span>
            <span class="ro-num">{{ item.value }}</span>
            <span>{{ item.unit }}</span>
          </li>
        </ul>
      </div>
      <span class="box-title2">门店统计</span>
      <div class="cl-b2">
        <el-select v-model="sort_mdtj" placeholder="乡镇" class="select-default" popper-class="select-default-popper">
          <el-option v-for="item in 5" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <el-table :data="data_mdtj" class="table-default" height="17vh">
          <el-table-column label="农资门店" prop="shop" min-width="50" show-overflow-tooltip/>
          <el-table-column label="经营地址" prop="address" min-width="50" show-overflow-tooltip/>
        </el-table>
      </div>
      <span class="box-title2">用药强度分析(去年)</span>
      <div class="cl-b3">
        <ul class="clb3-row1">
          <li v-for="item in data_yyqd.list" :key="item.title">
            <img src="../../../../assets/imgs/deck/page_znfx/icon-bottle.png" alt="">
            <div>
              <span>{{ item.title }}</span><span class="clb3-num">{{ item.value }}</span>
              <div>
                <span>环比</span><i class="icon-huanbi" :class="item.trend==='up'?'huanbi-up':'huanbi-down'"></i><span class="clb3-num">{{ item.percent }}</span><span class="clb3-unit">%</span>
              </div>
            </div>
          </li>
        </ul>
        <div id="chart-clb3"></div>

      </div>
      <span class="box-title2">安全风险预测</span>
      <div class="cl-b2">
        <el-select v-model="sort_fxyc" class="select-default" popper-class="select-default-popper">
          <el-option v-for="item in ['豇豆','土豆','豌豆','毛豆','黄豆']" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <el-table :data="data_fxyc" class="table-default" height="17vh">
          <el-table-column label="主体名称" prop="name" min-width="100" show-overflow-tooltip/>
          <el-table-column label="种类" prop="type" min-width="50" show-overflow-tooltip/>
          <el-table-column label="告警原因" prop="reason" min-width="65" show-overflow-tooltip/>
          <el-table-column label="种植面积(亩)" prop="area" min-width="80" show-overflow-tooltip/>
        </el-table>
      </div>
    </div>
    <div class="c-right">
      <div>
        <span class="box-title1">绿色农药管控</span>
        <div class="cr-b1">
          <span>绿色农资门店</span>
          <div>
            <span>{{ greenShop }}</span><span>家</span>
          </div>
        </div>
      </div>
      <span class="box-title2">销售订单信息</span>
      <div class="cr-b2">
        <div class="crb2-sort">
          <el-select v-model="sort_xsdd.year" @change="getMonthArr" placeholder="请选择年" class="select-default" popper-class="select-default-popper">
            <el-option v-for="item in yearArr" :key="item" :label="item+'年'" :value="item"></el-option>
          </el-select>
          <el-select v-model="sort_xsdd.month" placeholder="请选择月" class="select-default" popper-class="select-default-popper">
            <el-option v-for="item in monthArr" :key="item" :label="item+'月份'" :value="item"></el-option>
          </el-select>
          <el-select v-model="sort_xsdd.shop" placeholder="门店" class="select-default" popper-class="select-default-popper">
            <el-option v-for="item in 5" :key="item" :label="item" :value="item"></el-option>
          </el-select>
        </div>
        <ul class="row-overview">
          <li v-for="item in data_xsdd.overview" :key="item.title">
            <span>{{ item.title }}</span>
            <span class="ro-num">{{ item.value }}</span>
            <span>{{ item.unit }}</span>
          </li>
        </ul>
        <el-table :data="data_xsdd.tableData" class="table-default" height="28vh">
          <el-table-column label="门店" prop="shop" min-width="80" show-overflow-tooltip/>
          <el-table-column label="采购人" prop="purchaser" min-width="65" show-overflow-tooltip/>
          <el-table-column label="商品名称" prop="goodsName" min-width="85" show-overflow-tooltip/>
          <el-table-column label="数量" prop="count" min-width="50" show-overflow-tooltip/>
          <el-table-column label="单价(元)" prop="price" min-width="70" show-overflow-tooltip/>
          <el-table-column label="时间" prop="time" min-width="90" show-overflow-tooltip/>
        </el-table>
      </div>
      <span class="box-title2">销售趋势</span>
      <div class="cr-b3">
        <ul class="row-overview">
          <li v-for="item in data_xsqs.overview" :key="item.title">
            <span>{{ item.title }}</span>
            <span class="ro-num">{{ item.value }}</span>
            <span>{{ item.unit }}</span>
          </li>
        </ul>
        <div id="chart-crb3"></div>

      </div>
    </div>
  </div>
</template>

<script>
import { setYyqdfx, setXsqs } from '@/echarts/options'

export default {
  name: 'ZnfxNzjy',
  data() {
    return {
      leftTopData: [
        { title: '农药门店', value: 113, unit: '家' },
        { title: '从业经营', value: 246, unit: '人' }
      ],
      sort_mdtj: '',
      data_mdtj: [
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
        { shop: 'XXXXXXXXXXX经营社', address: 'XXXXXXXXXXXXXXX' },
      ],
      data_yyqd: {
        list: [
          { title: '用药总量(吨)', value: 343432, percent: 120, trend: 'up' },
          { title: '每亩用药(千克)', value: 343432, percent: 120, trend: 'down' },
        ],
        chart: [
          { year: '2019', value: 165 },
          { year: '2020', value: 185 },
          { year: '2021', value: 167 },
          { year: '2022', value: 215 },
          { year: '2023', value: 166 },
        ]
      },
      sort_fxyc: '豇豆',
      data_fxyc: [
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
        { name: 'XXXXXX经营社', type: '豇豆', reason: '用药11天', area: 72.34 },
      ],
      greenShop: 16,
      sort_xsdd: {
        year: '',
        month: '',
        shop: ''
      },
      yearArr: [],
      monthArr: [],
      data_xsdd: {
        overview: [
          { title: '购买主体', value: 1634, unit: '个' },
          { title: '订单数量', value: 2467, unit: '单' }
        ],
        tableData: [
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
          { shop: 'XXXXXX', purchaser:'张三', goodsName:'甲氰菊酯', count:'3', price:'25', time:'2023-06-06' },
        ]
      },
      data_xsqs: {
        overview: [
          { title: '上年补贴总额', value: 143, unit: '万' },
          { title: '当年已补贴金额', value: 53, unit: '万' }
        ],
        chart: [
          { time: '22-12', sales: 3900, pay: 3000, subsidy: 3350 },
          { time: '23-01', sales: 2400, pay: 1600, subsidy: 1900 },
          { time: '23-02', sales: 3100, pay: 2300, subsidy: 2700 },
          { time: '23-03', sales: 3000, pay: 2100, subsidy: 2500 },
          { time: '23-04', sales: 2700, pay: 1900, subsidy: 2200 },
          { time: '23-05', sales: 3900, pay: 3000, subsidy: 3350 },
        ]
      }
    }
  },
  mounted() {
    this.getRecentYears()
    this.sort_xsdd.year = new Date().getFullYear()
    this.getMonthArr()
    this.sort_xsdd.month = new Date().getMonth()+1
    setYyqdfx(document.getElementById('chart-clb3'), this.data_yyqd.chart)
    setXsqs(document.getElementById('chart-crb3'), this.data_xsqs.chart)
  },
  methods: {
    getRecentYears() {
      let thisYear = new Date().getFullYear()
      for(let i=0; i>-5; i--) {
        this.yearArr.push(thisYear+i)
      }
    },
    getMonthArr() {
      this.sort_xsdd.month = ''
      this.monthArr = []
      const d = new Date()
      const maxMonth = d.getFullYear()===this.sort_xsdd.year? d.getMonth()+1: 12
      for(let i=1; i<=maxMonth; i++) {
        this.monthArr.push(i)
      }
    }
  },
  watch: {

  }
}
</script>

<style lang="scss" scoped>
.c-left {
  left: 260px;
}

.row-overview {
  display: flex;
  justify-content: space-between;
  li {
    width: 337px;
    height: 67px;
    background: url('../../../../assets/imgs/deck/page_znfx/bg-nymd.png');
    background-size: 100% 100%;
    text-align: center;

  }
  span {
    font-size: 28px;
    line-height: 36px;
    font-weight: 400;
    color: #FFFFFF;
  }
  .ro-num {
    font-size: 36px;
    line-height: 36px;
    font-family: YSBTH;
    color: #FFE359;
    margin: 0 10px;
  }
}

.cl-b2 {
  .el-select {
    width: 255px;
    float: right;
    margin-bottom: 30px;
  }
}

.cl-b3 {
  .clb3-row1 {
    display: flex;
    justify-content: space-between;
    li {
      display: flex;
      align-items: center;
      img {
        width: 102px;
        height: 102px;
        margin-right: 18px;
      }
      &>div {
        width: fit-content;
        &>span {
          display: block;
          margin-bottom: 5px;
        }
        &>div {
          display: flex;
          align-items:end;
        }
      }
      span {
        font-size: 28px;
        color: #FFFFFF;
      }
      .clb3-num, .clb3-unit {
        font-size: 36px;
        font-family: YSBTH;
        color: #FFE359;
        line-height: 32px;
      }
      .clb3-unit {
        font-size: 24px;
        line-height: 22px;
      }
      .huanbi-up {
        background: url('../../../../assets/imgs/deck/page_znfx/huanbi-up.png');
      }
      .huanbi-down {
        background: url('../../../../assets/imgs/deck/page_znfx/huanbi-down.png');
      }
      .icon-huanbi {
        display: block;
        width: 24px;
        height: 24px;
        background-size: contain;
        margin: 0 5px;
      }
    }
  }
  #chart-clb3 {
    height: 18vh;
    width: 100%;
    margin-top: 20px;
  }

}

.cr-b1 {
  margin-top: -1vh;
  text-align: center;
  &>span {
    font-size: 28px;
    color: #FFFFFF;
  }
  &>div {
    width: 408px;
    height: 77px;
    background: url('../../../../assets/imgs/deck/page_znfx/bg-lsnzmd.png');
    background-size: cover;
    margin: 20px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    span:nth-child(1) {
      font-size: 44px;
      font-family: YSBTH;
      color: #FFE359;
      margin-right: 10px;
    }
    span:nth-child(2) {
      font-size: 28px;
      color: #FFFFFF;
    }
  }
}

.cr-b2 {
  .crb2-sort {
    display: flex;
    justify-content: space-between;
    .el-select {
      width: 31%;
    }
  }
  .row-overview {
    margin: 20px 0;
  }
}

.cr-b3 {
  #chart-crb3 {
    height: 28vh;
    width: 100%;
    margin-top: 20px;
  }
}
</style>