<template>
  <div class="chart-list">
    <div class="chart-item">
      <chart-box name="气象预警" arrow="left">
        <div class="base-wrap">
          <div class="base-item">111</div>
        </div>
        <one-line-chart></one-line-chart>
      </chart-box>
    </div>
    <div class="chart-item phenology">
      <chart-box name="物候调节" arrow="left">
        <template #title-left>
          <span class="title-left"> - 控梢期</span>
        </template>
        <bar-chart class="bar-chart" styleName="styleName2" :xData="phenologyXData" :yData="phenologyYData"></bar-chart>
        <div class="time-line">
          <div class="line">
            <!-- <time-line></time-line> -->
            <img class="time-img" src="@/assets/images/home/time-line.png" alt="">
          </div>
          <div class="tips box-bg">
            物候进程：预计 <span>2天</span> 后第三次秋梢完全老熟，进入控梢期
          </div>
        </div>
      </chart-box>
    </div>
    <div class="chart-item phenology">
      <chart-box name="病虫测报" arrow="left">
        <!-- <template #title-right>
          <div class="btn-group">
            <div :class="['btn-item',{active:active===index}]" @click="handleActive(index)" v-for="(item,index) in diseasesBtnGroup" :key="index">{{item}}</div>
          </div>
        </template> -->
        <bar-chart class="bar-chart" styleName="styleName2" :xData="phenologyXData1" :yData="phenologyYData1"></bar-chart>
        <div class="time-line">
          <div class="line">
            <img class="time-img" src="@/assets/images/home/time-line.png" alt="">
          </div>
          <div class="tips box-bg">
            异常区域中，<span>xx</span> %区域需要 <span>打药</span>，<span>xx</span> %需要 <span>剪枝通风</span>
          </div>
        </div>
        <!-- <pie-chart class="pie-chart" styleName="styleName1"></pie-chart> -->
      </chart-box>
    </div>
    <div class="chart-item evaluate">
      <chart-box name="营养评估" arrow="left">
        <template #title-left>
          <span class="title-left"> - 肥效比</span>
        </template>
        <div class="content">
          <bar-chart styleName="styleName1" :xData="evaluateXData" :yData="evaluateYData"></bar-chart>
          <div class="box-bg text">
            目前果园跨度异常比例达到<span>**%</span>，需要提供 <span>叶面肥</span>补充营养
          </div>
        </div>
        <div class="text-list box-bg">
          <div class="text-item">
            <div class="circle"></div>
            <div class="txt">
              肥效比 低<span>**棵树</span>
            </div>
          </div>
          <div class="text-item">
            <div class="circle"></div>
            <div class="txt">
              肥效比 中<span>**棵树</span>
            </div>
          </div>
          <div class="text-item">
            <div class="circle"></div>
            <div class="txt">
              肥效比 高<span>**棵树</span>
            </div>
          </div>
        </div>
      </chart-box>
    </div>
  </div>
</template>

<script setup>
import {ref} from 'vue'
import chartBox from "@/components/chartBox.vue";
import timeLine from "@/components/timeLine.vue";
import barChart from "@/components/charts/barChart.vue";
import pieChart from "@/components/charts/pieChart.vue";
import oneLineChart from "@/components/charts/oneLineChart.vue";

// 物候调节
const phenologyXData = ["萌动小叶", "红黄相间", "新梢老熟","白点","花穗伸长"]
const phenologyYData = [{
  startNum:130,
  endNum:130,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:120,
  endNum:90,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:120,
  endNum:1,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:130,
  endNum:0,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:130,
  endNum:0,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
}]

// 病虫测报
const diseasesBtnGroup = ["病害1","病害2","病害3"]
const active = ref(0)
const handleActive = (i) =>{
  active.value = i
}
const phenologyXData1 = ["病虫害03", "病害1", "虫害1","病虫害02","病虫害01"]
const phenologyYData1 = [{
  startNum:130,
  endNum:130,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:120,
  endNum:90,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:120,
  endNum:1,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:130,
  endNum:0,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
},{
  startNum:130,
  endNum:0,
  startColor:"#c6ab6b",
  endColor:"#4e442e"
}]

// 营养评估
const evaluateXData = ["低", "中", "高"]
const evaluateYData = [33, 40, 52]
</script>

<style lang="scss" scoped>
.chart-list {
  width: calc(100% - 54px - 10px);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  .chart-item {
    width: 100%;
    height: calc(100% / 4);
    box-sizing: border-box;
    margin-bottom: 10px;
    &.chart-item:last-child {
      margin: 0;
    }
    .box-bg{
      border-radius: 2px 2px 0 0;
      font-size: 12px;
      padding: 3px 6px;
      box-sizing: border-box;
      font-family: Arial, Helvetica, sans-serif;
      background: linear-gradient(180deg, rgb(85, 85, 85,0.4) 0%, rgb(35, 35, 35,1) 100%);
      span{
        color: #FFD489;
      }
    }
    .title-left{
      color: rgba(255,255,255,0.7);
      font-family: 'SOURCEHANTIFINE';
    }
    &.phenology{
      .bar-chart{
        width: 100%;
        height: calc(100% - 87px);
      }
      .time-line{
        width: 100%;
        height: calc(45px + 34px + 10px);
        .line{
          width: 100%;
          height: calc(100% - 34px - 10px);
          margin: 4px 0 6px 0;
          .time-img{
            width: 100%;
            height: 100%;
          }
        }
        .tips{
          width: 100%;
          height: 34px;
          line-height: 28px;
        }
      }
    }
    &.diseases{
      .btn-group{
        font-size: 11px;
        display: flex;
        align-items: center;
        .btn-item{
          border-radius: 2px;
          padding: 2px 4px;
          margin-left: 8px;
          cursor: pointer;
          &.active{
            background: #4F4F4F;
          }
        }
      }
      .pie-chart{
        width: 100%;
        height: calc(100% - 57px - 10px);
        margin-bottom: 10px;
      }
    }
    &.evaluate {
      .content {
        width: 100%;
        height: calc(100% - 33px - 10px);
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 10px;
        .text{
          font-weight: 400;
          padding: 8px 0 4px 5px;
          text-indent: 2em;
          margin-left: 8px;
          span{
            color: #FFD489;
          }
        }
      }
      .text-list {
        width: 100%;
        height: 33px;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        .text-item{
          display: flex;
          align-items: center;
          
          .circle{
            width: 4px;
            height: 4px;
            background: rgba(255,255,255,0.44);
            border-radius: 50%;
            margin-right: 6px;
          }
          .txt{
            font-size: 12px;
            span{
              color: #FFD489;
            }
          }
        }
      }
    }
  }
}
</style>