<template>
  <transition
    appear
    name="animate__animated animate__move"
    enter-active-class="animate__slideInRight"
    leave-active-class="animate__slideOutRight"
  >
    <div class="widget-ELPVmonitoring" v-if="show">
      <div class="head">
        <div class="title">
          <div class="icon"></div>
          <span class="site-info">易涝点视频监测</span>
        </div>
      </div>
      <div class="content-info">
        <div class="content-item" v-for="item of siteList" :key="item.name">
          <div class="title">
            <div class="siteInfo">
              <div class="icon"></div>
              <span class="site-name">{{ item.name }}</span>
              <div class="siteIcon" @click="located(item.coor)"></div>
            </div>
            <div class="waterLevel">
              <div class="liquidFill">
                <liquidFillChart isNormal />
              </div>
              <div class="currentLevel">
                当前水位：
                <div class="value">{{ item.waterLevel }}m</div>
              </div>
            </div>
          </div>
          <div class="content">
            <hls-video></hls-video>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
import liquidFillChart from '../overviewData/components/liquidFillChart.vue'
import hlsVideo from './components/hlsVideo.vue'
import util from '@/views/bigScreen/util'
export default {
  name: 'ELPVmonitoring', //易涝点视频监测
  components: {
    liquidFillChart,
    hlsVideo
  },
  props: {
    show: {}
  },
  data() {
    return {
      siteList: [
        { name: '陵州大道东一段下穿隧道', waterLevel: 1.3, coor: [104.1637934, 30.0103335] },
        { name: '陵州大道东二段下穿隧道', waterLevel: 1.3, coor: [104.1662752, 30.0040547] },
        { name: '迎宾大道与绿岛街交叉口', waterLevel: 1.3, coor: [104.1467149, 29.9836909] }
      ],
      mapUtil: null
    }
  },
  watch: {
    show(n, o) {
      if (!n) {
        if (this.vectorLayer) this.vectorLayer.getSource().clear()
      }
    },
    view: {
      handler(n, o) {
        if (n) {
          this.mapUtil = new util(n)
        }
      }
    }
  },
  computed: {
    view() {
      return this.$store.state.bigScreen.view
    }
  },
  methods: {
    //定位方法
    located(position) {
      let obj = {
        name: '视频点位',
        src: require('@/views/bigScreen/monitoringCenter/images/视频点.png')
      }
      this.vectorLayer = this.mapUtil.located(
        obj,
        position.map((item) => parseFloat(item))
      )
    }
  }
}
</script>

<style lang='scss' scoped>
.animate__slideInRight,
.animate__slideOutRight {
  animation-duration: 3s; //动画持续时间
  animation-delay: 0s; //动画延迟时间
}
.widget-ELPVmonitoring {
  $size10: 0.052083rem /* 10/192 */;
  $size20: 0.104167rem /* 20/192 */;
  z-index: 2;
  //position
  bottom: $size10 /* 10/192 */;
  margin-right: $size20 /* 20/192 */;
  right: 0;
  position: absolute;
  //size
  height: calc(100% - 0.557292rem /* 107/192 */);
  width: 2.083333rem /* 400/192 */;
  //background
  background-color: rgba(20, 24, 47, 0.5);
  color: #eee;
  box-shadow: 0 0 20px rgba(1, 9, 20, 1);
  //font
  font-family: Source Han Sans CN;
  .head {
    height: 0.166667rem /* 32/192 */;
    width: 100%;
    background: linear-gradient(-90deg, rgba(43, 167, 255, 0.2) 0%, rgba(43, 167, 255, 0.08) 100%);
    .title {
      width: 100%;
      height: 100%;
      display: flex;
      font-weight: 400;
      .icon {
        height: 0.166667rem /* 32/192 */;
        width: 0.34375rem /* 66/192 */;
        background: url('./images/视频监测.png') no-repeat center center;
        background-size: 100% 100%;
      }
      span {
        font-weight: bold;
        font-size: 0.083333rem /* 16/192 */;
        color: #ffffff;
        // text-shadow: 0 0 10px rgba(65, 105, 225,0.3),0 0 20px rgba(65, 105, 225,0.3),0 0 30px rgba(65, 105, 225,0.3),0 0 40px rgba(65, 105, 225,0.3);
        padding: 0.041667rem /* 8/192 */;
      }
    }
  }
  .content-info {
    width: 100%;
    height: calc(100% - 0.166667rem);
    overflow: auto;
    padding: 2px;
    .content-item {
      width: 100%;
      height: 33%;
      float: left;
      overflow: hidden;
      .title {
        width: 100%;
        display: flex;
        padding: 0.145833rem 0 0 0;
        justify-content: space-between;
        align-items: center;
        .siteInfo {
          display: flex;
        }
        .icon {
          height: 0.072917rem /* 14/192 */;
          width: 0.052083rem /* 10/192 */;
          margin-right: 0.046875rem /* 9/192 */;
          background: url('./images/三角.png') no-repeat center center;
          background-size: 100% 100%;
        }
        .site-name {
          color: #ffffff;
          font-size: 0.072917rem /* 14/192 */;
          font-weight: 500;
        }
        .siteIcon {
          background: url('./images/定位.png') no-repeat center center;
          background-size: 100% 100%;
          width: 13px;
          height: 16px;
          margin-left: 0.0625rem /* 12/192 */;
          cursor: pointer;
        }
        .waterLevel {
          display: flex;
          align-items: center;
          .liquidFill {
            height: 0.114583rem /* 22/192 */;
            width: 0.114583rem /* 22/192 */;
          }
          .currentLevel {
            font-size: 0.0625rem /* 12/192 */;
            font-weight: 500;
            color: #ffffff;
            display: flex;
            align-items: baseline;
            .value {
              font-size: 0.072917rem /* 14/192 */;
              font-weight: bold;
              color: #2ba7ff;
            }
          }
        }
      }
      .content {
        height: calc(100% - 0.072917rem);
        width: 100%;
        padding: 0.052083rem /* 10/192 */;
      }
    }
  }
}
</style>