<template>
  <div class="base-container no-events">
    <fnHeader></fnHeader>
    <div class="content">
      <!-- <div class="top"></div> -->
      <div class="left yes-events">
        <div class="chart-list">
          <div class="chart-item">
            <chart-box name="光照效能" arrow="left">
              <!-- <template #title-right>
                <div>
                  <el-select
                    v-model="topographicValue"
                    placeholder="请选择"
                    style="width: 86px"
                    size="small"
                  >
                    <el-option
                      v-for="item in topographicOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </div>
              </template> -->
              <div class="topographic-content">
                <bar-chart
                  styleName="styleName1"
                  :xData="evaluateXData"
                  :yData="evaluateYData"
                ></bar-chart>
                <!-- <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>26</span>棵
                    </div>
                    </div>
                </div> -->
              </div>
            </chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="气象预警" arrow="left">
              <div class="topographic-content">
                <bar-chart
                  styleName="styleName1"
                  :xData="evaluateXData"
                  :yData="evaluateYData"
                ></bar-chart>
                <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>15626</span>棵(树龄3.5年)</div>
                  </div>
                </div>
              </div>
            </chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="气象预警" arrow="left"></chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="气象预警" arrow="left"></chart-box>
          </div>
        </div>
      </div>
      <div class="home-bottom">
        <div class="file-box yes-events">
          <chart-box name="果园档案">
            <template #title-right>
              <el-icon class="arrow-icon cursor-pointer" color="#141414"
                ><DArrowLeft
              /></el-icon>
              <div class="edit-btn cursor-pointer" @click="goBack">返回</div>
            </template>
            <file-bar>
              <div class="btn-list">
                <div class="btn-item">新增</div>
                <div class="btn-item">筛选</div>
                <div class="btn-item">撤销</div>
                <div class="btn-item">保存</div>
              </div>
            </file-bar>
          </chart-box>
        </div>
      </div>
      <div class="right yes-events">
        <div class="chart-list">
          <div class="chart-item">
            <chart-box name="病害历史" arrow="arrow-left">
              <template #title-right>
                <el-select
                  v-model="pestHistoryValue"
                  placeholder="请选择"
                  size="small"
                  class="common-select"
                  popper-class="common-select-popper"
                >
                  <el-option
                    v-for="item in pestHistoryOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </template>
              <div class="pest-history">
                <bar-chart
                  styleName="styleName1"
                  :xData="evaluateXData"
                  :yData="evaluateYData"
                ></bar-chart>
              </div>
            </chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="虫害历史" arrow="arrow-left">
              <template #title-right>
                <el-select
                  v-model="pestHistoryValue"
                  placeholder="请选择"
                  size="small"
                  class="common-select"
                  popper-class="common-select-popper"
                >
                  <el-option
                    v-for="item in pestHistoryOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </template>
              <div class="topographic-content">
                <bar-chart
                  styleName="styleName1"
                  :xData="evaluateXData"
                  :yData="evaluateYData"
                ></bar-chart>
                <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>15626</span>棵(树龄3.5年)</div>
                  </div>
                </div>
              </div>
            </chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="气象预警" arrow="arrow-left"></chart-box>
          </div>
          <div class="chart-item">
            <chart-box name="气象预警" arrow="arrow-left"></chart-box>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div ref="mapRef" class="bottom-map"></div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import fnHeader from "@/components/fnHeader.vue";
import chartBox from "@/components/chartBox.vue";
import fileBar from "@/components/fileBar.vue";
import barChart from "@/components/charts/barChart.vue";
import FileMap from "./fileMap";
import router from "@/router";

let fileMap = new FileMap();
const mapRef = ref();
const topographicValue = ref("高温风险");
const topographicOptions = ref([
  { label: "高温风险", value: "高温风险" },
  { label: "病害风险", value: "病害风险" },
  { label: "虫害风险", value: "虫害风险" },
  { label: "阴雨寡照", value: "阴雨寡照" },
]);

// 右1-病害历史
const pestHistoryValue = ref("品种");
const pestHistoryOptions = ref([
  { label: "品种", value: "品种" },
  { label: "品种1", value: "品种1" },
  { label: "品种2", value: "品种2" },
  { label: "品种3", value: "品种3" },
]);

// 地形风险
const evaluateXData = ["区域1", "区域2", "区域3"];
const evaluateYData = [33, 41, 43];

onMounted(() => {
  let location = "POINT (113.78049350268851 23.419886891845312)";
  fileMap.initMap(location, mapRef.value);
});

// 返回
const goBack = () => {
  router.replace("/home");
};
</script>

<style lang="scss" scoped>
.base-container {
  width: 100%;
  height: 100vh;
  color: #fff;
  position: absolute;
  box-sizing: border-box;
  z-index: 1;

  .content {
    width: 100%;
    height: calc(100% - 74px - 48px);
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
    .left,
    .right {
      width: 375px;
      height: 100%;
      padding-top: 10px;
      box-sizing: border-box;
      display: flex;
      .chart-list {
        width: 100%;
        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;
          }
        }
      }
      .topographic-content {
        width: 100%;
        height: calc(100% - 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;
          }
        }
        .box-bg {
          border-radius: 2px 2px 0 0;
          font-size: 12px;
          padding: 8px 6px;
          box-sizing: border-box;
          background: linear-gradient(
            180deg,
            rgb(85, 85, 85, 0.4) 0%,
            rgb(35, 35, 35, 1) 100%
          );
        }
      }
      .text-list {
        flex: none;
        margin: 0 16px;
        .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 {
              margin: 0 2px 0 6px;
              color: #e8ba52;
            }
          }
        }
      }
    }
    .left {
      padding-left: 20px;
    }
    .right {
      padding-right: 20px;
      .list {
        width: 100%;
        height: 100%;
      }
      .pest-history {
        width: 100%;
        height: 100%;
        padding: 6px 8px 20px 20px;
        box-sizing: border-box;
      }
    }
    .home-bottom {
      display: flex;
      align-items: flex-end;
      width: calc(100% - 375px - 375px - 72px);
      height: 100%;
      justify-content: flex-end;
      .file-box {
        height: 25%;
        min-height: 210px;
        width: 422px;
        position: relative;
        box-shadow: 0 0 3px 3px #2199f8;
        .arrow-icon {
          top: -32px;
          left: 50%;
          position: absolute;
          background: #fff;
          width: 16px;
          height: 80px;
          line-height: 80px;
          border-radius: 5px 0 0 5px;
          text-align: center;
          transform: translateX(-50%) rotate(270deg);
        }
        .edit-btn {
          padding: 2px 24px;
          background: #2199f8;
          border-radius: 4px;
        }
        .btn-list {
          position: absolute;
          right: 4px;
          .btn-item {
            background: #4f4f4f;
            border-radius: 4px;
            padding: 2px 24px;
            margin-bottom: 16px;
            &:last-child {
              margin-bottom: 0;
            }
          }
        }
      }
    }
  }
}
.bottom-map {
  width: 100%;
  height: 100vh;
  position: absolute;
  z-index: 0;
}
</style>
