Newer
Older
cockpit_hxrq_front / src / views / maps / highConsequenceArea.vue
<!--
 * @Description: 高后果区专题
 * @Author: 王晓颖
 * @Date: 2021-04-07 14:40:59
 -->
<template>
  <layout-map>
    <!--地图-->
    <Map :url="configUrl" @onload="onMapload" >
      <pipe-layer :show="true"/>
      <hca-heat-layer ref="hcaHeat" :show="heatShow"/>
      <hca-point-layer ref="hcaPoint" :show="positionShow"/>
      <manage-station-layer ref="manageStation" :show="stationShow"/>
    </Map>
    <div class="map-btn-group">
      <select-button :select="heatShow" name="热力图" icon="icon-heat" @click="showHeat(heatShow)"/>
      <select-button :select="positionShow" name="点位分布" icon="icon-position" @click="showPosition(positionShow)"/>
      <select-button :select="stationShow" name="管理处" icon="icon-station" @click="showStation(stationShow)"/>
    </div>
  </layout-map>
</template>

<script>
import Map from '@/components/Map/MarsMap.vue'
import Weather from '@/components/weather/weather'
import Clock from '@/components/clock/Clock'
import SelectAll from './components/selectAll'
import SelectButton from '@/components/SelectTool/components/selectButton'
import { getTimes } from '@/utils/dateutils'
import LayoutMap from '@/layout/layoutMap'
import HighConsequenceDialog from './components/highConsequenceDialog'
import PipeLayer from '@/components/Map/components/pipeLayer'
import HcaHeatLayer from '@/components/Map/components/hcaHeatLayer'
import HcaPointLayer from '@/components/Map/components/hcaPointLayer'
import ManageStationLayer from '@/components/Map/components/manageStationLayer'
export default {
  name: 'Index',
  components: {
    ManageStationLayer,
    HcaPointLayer,
    HcaHeatLayer,
    PipeLayer,
    HighConsequenceDialog,
    LayoutMap,
    SelectAll,
    Weather,
    Clock,
    Map,
    SelectButton
  },
  filters: {
    boardNameFilter(val) {
      if (val === '全部' || val === '') {
        return '全省高后果区'
      } else {
        return val + '区域高后果区'
      }
    }
  },

  data() {
    return {
      map: null, // 地图
      configUrl: 'static/config/config.json',
      alpha: 100, // 透明度
      underground: null, // ?
      heatShow: true, // 热力图显示
      stationShow: true, // 管理站显示
      positionShow: false, // 点位显示
      boardData: {
        name: '全部',
        value: 196
      }, // 统计版展示数据
      pointColorArr: ['#f33349', '#f79a2c', '#f2fa19', '#95e40c', '#1ffee6'],
      timer: null, // 轮训定时器
      clock: 86400 // 间隔时间
    }
  },
  methods: {
    // 地图构造完成回调
    onMapload(map) {
      // 以下为演示代码
      this.map = map
      // 背景透明
      this.map._viewer.scene.backgroundColor = new this.Cesium.Color(0.0, 0.0, 0.0, 0.0)
      this.map._viewer.scene.globe.baseColor.alpha = 0
      this.refreshData()
    },
    // 选框发生变化
    selectChange({ area, people, time, level }) {
      area = area === '全部' ? '' : area
      time = time === '全部' ? '' : time
      level = level === '全部' ? '' : level
      // 获取人数范围
      let min = 0
      let max = 100000
      switch (people) {
        case '10-100':
          min = 10
          max = 100
          break
        case '101-150':
          min = 101
          max = 150
          break
        case '151-200':
          min = 151
          max = 200
          break
        case '200以上':
          min = 200
          break
      }
      // 解析时间
      let beginTime = ''
      let endTime = ''
      if (time) {
        const result = getTimes(time)
        beginTime = result.beginDate
        endTime = result.endDate
      }
      this.boardData.name = area
      // 查询数据
      let count = 0
      for (const hca of this.highConsequence) {
        let flag = true // 标记是否合格
        const real_people = parseInt(hca['户数'] === null ? '1' : hca['户数'])
        // 比较区域
        if (area && hca['所属管理处'] && hca['所属管理处'].indexOf(area) === -1) {
          flag = false
        }
        // 比较人数
        if (real_people && (real_people > max || real_people < min)) {
          flag = false
        }
        // 比较时间
        if (time) {
          const real_date = new Date(hca['识别时间'])
          if (real_date && (real_date < beginTime || real_date > endTime)) {
            flag = false
          }
        }
        // 比较级别
        if (level && hca['高后果区级别'] && hca['高后果区级别'] === level) {
          flag = false
        }
        if (flag) {
          count++
        }
      }
      this.boardData.value = count
    },
    // 管理处的弹窗
    addStationDiv() {
      const { Cesium, mars3d } = this
      const graphicLayer = new mars3d.layer.GraphicLayer()
      this.graphicLayer = graphicLayer
      this.map.addLayer(graphicLayer)
      for (const station of this.manageStations) {
        var graphic = new mars3d.graphic.DivGraphic({
          position: Cesium.Cartesian3.fromDegrees(station.x, station.y, 10000),
          style: {
            html: `<div class="divpoint divpoint-theme-29baf1">
                    <div class="divpoint-wrap">
                        <div class="area">
                            <div class="arrow-lt"></div>
                            <div class="b-t"></div>
                            <div class="b-r"></div>
                            <div class="b-b"></div>
                            <div class="b-l"></div>
                            <div class="arrow-rb"></div>
                            <div class="label-wrap">
                                <div class="title">${station.name}</div>
                                <div class="label-content">
                                    <div class="data-li">
                                        <div class="data-label">经度:</div>
                                        <div class="data-value"><span class="label-num">${station.x}</span>
                                        </div>
                                    </div>
                                    <div class="data-li">
                                        <div class="data-label">纬度:</div>
                                        <div class="data-value"><span class="label-num">${station.y}</span>
                                        </div>
                                    </div>
                                    `,
            // anchor: [0, 0],
            horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10000, 500000), // 按视距距离显示
            scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.1),
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
          },
          pointerEvents: false // false时不允许拾取和触发任意鼠标事件,但可以穿透div缩放地球
        })
        graphicLayer.addGraphic(graphic)
        graphic.testPoint = false // 打开测试点,与DIV点进行对比位置调整css
      }
    },
    // 是否显示热力图
    showHeat(show) {
      this.heatShow = !this.heatShow
    },
    // 是否显示管理处
    showStation(show) {
      this.stationShow = !this.stationShow
    },
    // 显示位置
    showPosition(show) {
      this.positionShow = !this.positionShow
    },
    refreshData() {
      this.timer = setInterval(() => {
        console.log('refreshData')
        if (this.heatShow) {
          this.$refs.hcaHeat.initLayer()
        }
        if (this.pointShow) {
          this.$refs.hcaPoint.initLayer()
        }
      }, this.clock * 1000)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .label-div{
    position: absolute;
    top: 140px;
    left:31rem;
    z-index:100;
    color: white;
    padding:2rem 3rem 1.5rem 3rem;
    background-image: url("../../assets/button_images/board-box1.png");
    background-size: 100% 100%;
    .label{
      margin-bottom: 1rem;
      font-size:1.2rem;
    }
    .value{
      font-family: DS-DigitalBold;
      font-size:2.5rem;
    }
  }
  .map-btn-group{
    position: absolute;
    bottom:3rem;
    left:50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
  }
</style>

<style rel="stylesheet/scss" lang="scss">
  /*整个容器*/
  .mapcontainer {
    position: relative;
    height: 100%;
    width: 100%;
    background-color: transparent;
    /*background-color: #051151;*/
  }
  /*logo遮罩*/
  .mask{
    position: fixed;
    padding-left:10px;
    padding-right:10px;
    bottom:0px;
    left:0px;
    background-color:#000000;
    color:#ffffff;
    line-height:2
  }

</style>