<template>
  <div class="chart-list">
    <div class="chart-item">
      <chart-box name="气象预警" arrow="left"></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"></div>
          <div class="tips box-bg">
            物候进程：预计 <span>2天</span> 后第三次秋梢完全老熟，进入控梢期
          </div>
        </div>
      </chart-box>
    </div>
    <div class="chart-item diseases">
      <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>
        <pie-chart class="pie-chart" styleName="styleName1"></pie-chart>
        <div class="desc box-bg">
          异常区域中，<span>xx</span> %区域需要 打药，xx %需要 剪枝通风，xx %需要 剪除病枝 。当前分别有 xx %，xx %，xx %的区域尚未执行。
        </div>
      </chart-box>
    </div>
    <div class="chart-item evaluate">
      <chart-box name="营养评估" arrow="left">
        <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" v-for="item in 3" :key="item">
            <div class="circle"></div>
            <div class="txt">
              物候跨度正常<span>**棵树</span>，
              跨度<span>2个物候期</span>
            </div>
          </div>
        </div>
      </chart-box>
    </div>
  </div>
</template>

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

// 物候调节
const phenologyXData = ["萌动小叶", "红黄相间", "新梢老熟"]
const phenologyYData = [{
  startNum:44,
  endNum:0,
  startColor:"#E6AD00",
  endColor:"#232323"
},{
  startNum:33,
  endNum:22,
  startColor:"#FF7C8F",
  endColor:"#232323"
},{
  startNum:30,
  endNum:28,
  startColor:"#0BFE13",
  endColor:"#232323"
}]

// 病虫测报
const diseasesBtnGroup = ["病害1","病害2","病害3"]
const active = ref(0)
const handleActive = (i) =>{
  active.value = i
}

// 营养评估
const evaluateXData = ["正常", "较大", "异常"]
const evaluateYData = [33, 41, 43]
</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;
      background: linear-gradient(180deg, rgb(85, 85, 85,0.4) 0%, rgb(35, 35, 35,1) 100%);
      span{
        color: #69BDFF;
      }
    }
    .title-left{
      color: rgba(255,255,255,0.7);
    }
    &.phenology{
      .bar-chart{
        width: 100%;
        height: calc(100% - 70px);
      }
      .time-line{
        width: 100%;
        height: 70px;
        .line{
          width: 100%;
          height: calc(100% - 34px);
        }
        .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;
      }
      .desc{
        width: 100%;
        height: 57px;
        text-indent: 2em;
        letter-spacing: 1px;
        color: rgba(255,255,255,0.7);
      }
    }
    &.evaluate {
      .content {
        width: 100%;
        height: calc(100% - 68px - 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: #69BDFF;
          }
        }
      }
      .text-list {
        width: 100%;
        height: 68px;
        .text-item{
          display: flex;
          align-items: center;
          margin-bottom: 5px;
          .circle{
            width: 4px;
            height: 4px;
            background: rgba(255,255,255,0.44);
            border-radius: 50%;
            margin-right: 6px;
          }
          .txt{
            font-size: 12px;
            span{
              color: #69BDFF;
            }
          }
        }
      }
    }
  }
}
</style>