<!--
  Description: 高德地图信息窗体 - 光伏节点
  Author: 李亚光
  Date: 2023-05-10
 -->
<script lang="ts" setup name="infoWindow">
import trendChart from './trendChart.vue'
const overlay = ref()
const infoWindow = ref()
const info = ref()
const trendRef = ref()
// 初始化
const initialize = (e) => {
  overlay.value = e.overlay
  infoWindow.value = e.infoWindow
  info.value = e.info
  trendRef.value.expand = true
  trendRef.value.range = 'day'
}
defineExpose({ initialize })
// 关闭
const close = () => {
  infoWindow.value.close()
  trendRef.value.expand = true
}
const expand = computed(() => {
  return trendRef.value?.expand
})
</script>

<template>
  <div class="container" :style="`height: ${expand ? '180px' : '400px'}`">
    <div class="title">
      <div class="text">
        {{ info?.stationName }}
      </div>
      <div class="close" @click="close">
        x
      </div>
    </div>
    <div class="item">
      光伏挂载节点 : {{ info?.nodeId }}
    </div>
    <div class="item">
      <span>发电机组有功 : {{ info?.pg }} MW</span>  <span>发电机组无功 : {{ info?.qg }} MW</span>
    </div>
    <div class="item">
      碳排强度 : {{ info?.strength }} gCO2·/kWh
    </div>
    <trend-chart ref="trendRef" :width="420" :height="200" :device-id="info?.deviceId" :device-type="1" />
  </div>
</template>

<style lang="scss" scoped>
.container {
  width: 450px;
  height: 400px;
  padding: 10px;
  background-color: #fff;
  border: 1px solid #6d9ece;

  .title {
    font-size: 16px;
    font-weight: 700;
    padding: 0 10px;
    display: flex;
    justify-content: space-between;

    .close {
      color: #ccc;

      &:hover {
        cursor: pointer;
      }
    }
  }

  .item {
    padding: 0 5px;
    color: #111213;
    font-size: 14px;
    margin: 10px;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
  }
}
</style>
