<template>
  <div class="base-container">
    <fnHeader></fnHeader>
    <div class="content">
      <!-- <div class="top"></div> -->
      <div class="left">
        <tool-list direction="left" :list="leftToolList" @handleActive="handleActiveLeft"></tool-list>
        <component :is="components[currentComponent]" />
      </div>
      <div class="home-bottom">
        <div class="log-box">
          <chart-box name="果园日志"></chart-box>
        </div>
        <div class="file-box">
          <chart-box name="果园档案"></chart-box>
        </div>
      </div>
      <div class="right">
        <div class="list">
          <chart-box name="农事列表" arrow="arrow-left"></chart-box>
        </div>
        <tool-list direction="right" :list="rightToolList"></tool-list>
      </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 toolList from "@/components/toolList.vue";
import HomeMap from "./homeMap";
import homePage from "./components/homePage.vue"
import weatherPage from "./components/weatherPage.vue"
import phenologyPage from "./components/phenologyPage.vue"
const components = {  
  homePage,
  weatherPage,
  phenologyPage
};  

let homeMap = new HomeMap();
const mapRef = ref();
onMounted(() => {
  let location = "POINT (113.78049350268851 23.419886891845312)"
  homeMap.initMap(location, mapRef.value);
})

const currentComponent = ref('homePage');
const handleActiveLeft = (e) =>{
  currentComponent.value = e.componentName
}
const leftToolList = [
  {
    title:'首页',
    name:'home',
    componentName:'homePage'
  },
  {
    title:'气象预警',
    componentName:'weatherPage'
  },
  {
    title:'物候调节',
    componentName:'phenologyPage'
  },
  {
    title:'病虫测报'
  },
  {
    title:'营养评估'
  }
]

const rightToolList = [
  {
    title:'农事列表'
  },
  {
    title:'新增农事'
  },
  {
    title:'复核对比'
  }
]
</script>

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

  .content {
    width: 100%;
    height: calc(100% - 74px - 48px);
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
    .left,
    .right {
      pointer-events: all;
      width: calc(376px + 54px);
      height: 100%;
      padding-top: 10px;
      box-sizing: border-box;
      display: flex;
    }
    .right {
      .list {
        width: 100%;
        height: 100%;
      }
    }
    .home-bottom {
      display: flex;
      align-items: flex-end;
      width: calc(100% - 430px - 430px - 72px);
      height: 100%;
      align-self: flex-end;
      .log-box {
        pointer-events: all;
        height: 30%;
        width: calc(100% - 340px - 28px);
        margin-right: 28px;
      }
      .file-box {
        pointer-events: all;
        height: 25%;
        width: 340px;
      }
    }
  }
}
.bottom-map {
  width: 100%;
  height: 100vh;
  position: absolute;
  z-index: 0;
}
</style>