Newer
Older
smartwell_front / src / views / overview / overview3dzq.vue
wangxitong on 22 Jan 2024 27 KB 总览
<!--suppress ALL -->
<template>
  <div style="overflow: hidden;height: 100%" class="map-zq">
    <mars3d-map v-loading="mapLoading" :basemap="basemap" map-key="zq" @onload="onMapload" />
<!--    左下角图层-->
    <div class="cover">
      <div v-for="(item,index) in labelName" :key="item" class="cover-item">
        <span v-if="index===0" style="color: #FF7FE9;font-weight: 900;width:17px">—</span>
        <span v-else-if="index===3"><img :src="'/../../../static/images/标识器.png'" style="width: 17px;height:17px"></span>
        <span v-else><img :src="'/../../../static/images/'+labelName[index]+'.png'" style="width: 17px;height:17px"></span>
        <!--        <span v-else><img :src="'/../../../static/images/燃气附属物.png'" style="width: 17px;height:17px"></span>-->
        <span style="position: relative;left: 5px">{{ item }}</span>
      </div>
    </div>
    <div class="overview-map-container">
      <!--搜索框-->
      <map-search-comp :list="resultList" placeholder="点位编号/名称/位置" style="margin-left:20px;background: #00000000" @search="search" @change-page="searchPageChange" @click-item="searchItemClick" @clear="clearSearch" />
      <div style="width: 230px; position: absolute;top:0px; right: 10px;display: flex">
        <i class="el-icon-map-location circle_btn" @click="setCenter(center)" />
        <el-slider v-model="alpha" style="width: 180px;margin-left: 10px" />
      </div>
      <!--报警列表-->
      <alarm-list :show="showAlarm" :data="alarmList" @row-click="alarmRowClick" />
      <!--工具箱-->
      <tool-box style="position: absolute; width:300px;top:25px;right: 0px" :is3-d="true" :show="!loading" :layers="layers" :layer-checked="checkedLayer" :tool-menu="menus.menuList" @change-base-map="changeBaseMap" @layer-change="filterLayer" @click-menu="clickMenu" @close-menu-pop="closeAllPopup" />
      <!--坐标定位窗口-->
      <popup-location ref="popupLocation" :is3-d="true" :show="menus.locationWindowShow" @search="setCenter" @picker="pickerPosition" @close="closePopupLocation" />
      <line-search ref="lineSearch" :show="menus.lineWindowShow" @search="setLine" @close="closeLineSearch" />
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getWellType } from '@/api/well/well'
import { getWellListZq, getWellInfo, getAlarmsNowZq, getWellAlarms } from '@/api/overview/wellOverview'
import { toPixel, toLngLat, toSize } from '@/components/Amap/utils/convert-helper'
import AlarmInfoWindow from './components/infoWindowAlarm'
import WellInfoWindow from './components/infoWindowWell'
import AlarmList from './components/alarmList'
import Vue from 'vue'
import ToolBox from '@/views/overview/components/toolBox'
import PopupDataFilter from '@/views/overview/components/popupDataFilter'
import PopupLocation from '@/views/overview/components/popupLocation'
import MapSearchComp from '@/views/overview/components/mapSearchComp'
import axios from 'axios'

import * as Cesium from 'mars3d-cesium'
// 导入mars3d主库
import 'mars3d/dist/mars3d.css'
import 'mars3d-cesium/Build/Cesium/Widgets/widgets.css'
import * as mars3d from 'mars3d'

import store from '@/store'
import { breadcrumb } from '@/settings'
import Mars3dMap from '@/components/Mars3D/Mars3dMap'
import { polylineC, polylineVolumeP } from '@/components/Mars3D/utils/ArcGisWfsLayer'
import { createPointLayer, createPointModelLayer } from '@/components/Mars3D/utils/GeoJsonLayer'
import {Graphic_Point, Tetrahedron} from '@/components/Mars3D/utils/GraphicLayer'
import LineSearch from "@/views/overview/components/lineSearch";

let layer2021 = null
let layer2020 = null
// 设备
let dev_layer = []
let alarm_layer = null
let rqline_layer = []
let rqwell_layer = null
let rqbox_layer = null
let underground = null
export default {
  name: 'Overview3D',
  components: {LineSearch, Mars3dMap, MapSearchComp, PopupLocation, PopupDataFilter, ToolBox, AlarmList },
  data() {
    return {
      layerName: ['燃气阀门井', '燃气调压箱', '中燃燃气标识器', '圣井燃气标识器', '正和燃气标识器', '华润燃气标识器', '华气燃气标识器', '井盖状态监测仪', '管盯', '燃气智能监测终端', '激光遥测云台', '可燃气体监测终端','燃气管线'],
      layerColor: [
        '#fd7ee8',
        '#99999a',
        '#0095fe',
        '#0095fe',
        '#0095fe',
        '#0095fe',
        '#0095fe',
        '#0095fe',
        '#fdc401',
        '#fcd03a',
        '#fd7ee8',
        '#2aa416'],
      labelName: ['燃气管线', '燃气阀门井', '燃气调压箱', '中燃-圣井-正和-华润-华气标识器', '井盖状态监测仪', '管盯', '燃气智能监测终端', '激光遥测云台', '可燃气体监测终端'],
      basemap: 1112,
      baseLayer: 'dark', // 底图图层
      layers: [{ id: 'well', name: '井图层', children: [] }, { id: 'line', name: '管线图层', children: [] }, { id: 'dev', name: '设备图层', children: [] }, { id: 'alarm', name: '报警图层' }], // 图层列表
      checkedLayer: [], // 选中的图层
      center: ['', ''], // 地图中心
      // center: [this.$store.getters.lng, this.$store.getters.lat], // 地图中心
      type: this.baseConfig.showPointType, // 加载数据方式:massMarkers海量点或cluster聚合点
      refreshType: this.baseConfig.refreshType, // 刷新数据方式:clock定时器或websocket推送
      searchResultSize: [24, 30],
      searchResultOffset: [-12, -30],
      mapLoading: false,
      searchResultIcon: require('@/assets/overview/pure-position-icon.png'), // 报警图标
      showAlarm: true, // 是否显示报警
      alpha: 80,
      toolShow: false, // 工具栏是否显示
      menus: {
        menuList: [
          // { icon: 'search', menu: 'dataFilter', name: '数据筛选' },
          { icon: 'coordinate', menu: 'location', name: '坐标定位' },
          { icon: 'search', menu: 'line', name: '管线筛选' },
        ],
        dataFilterWindowShow: false, // 数据筛选窗口是否显示
        locationWindowShow: false, // 坐标定位窗口是否显示
        lineWindowShow: false
      }, // 工具栏菜单
      listQuery: {
        keywords: '', // 关键字
        wellType: '', // 点位类型
        deptid: '' // 组织机构
      }, // 筛选条件
      count: 30, // 倒计时显示时间
      clock: null, // 计时器
      showWellType: false, // 是否显示点位类型下拉,默认边上
      wellTypeList: [], // 点位类型列表
      alarmList: [], // 显示报警列表
      alarmWells: [], // 报警井列表
      resultList: [], // 搜索结果列表
      searchMarkers: [], // 当前搜索页展示marker集合
      latestAlarmTime: '', // 列表中最新报警事件
      alarmFirstAmount: true, // 是否初次加载报警
      firstAmount: true, // 是否第一次加载井数据
      loading: true, // 加载图标是否显示
      markers: [], // 所有井的点原始数据
      tempMarker: null,
      bloomEffect: null,
      isAll: true
    }
  },
  computed: {
    ...mapGetters([
      'needRefresh',
      'bodyHeight'
    ])
  },
  watch: {
    alpha(val) {
      // window.viewer.imageryLayers._layers.forEach(layer => {
      //   layer.alpha = val / 100 // 我们可以设置为0
      // })
      window.map.basemap.opacity = val / 100
      // window.map.getLayer('building', 'name').show = val / 100 > 0.5
      if (window.map.level >= 19 && this.alpha < 90) {
        // 展示该展示的
        rqwell_layer['3D'].show = this.checkedLayer.indexOf('well-燃气阀门井') !== -1
        rqbox_layer['3D'].show = this.checkedLayer.indexOf('well-燃气调压箱') !== -1
      } else {
        // 隐藏
        rqwell_layer['3D'].show = false
        rqbox_layer['3D'].show = false
      }
    },
    needRefresh(val) { // 需要刷新报警
      console.log('socket报警刷新')
      if (val) this.refreshAlarm()
    },
    'menus.locationWindowShow'(val) { // 打开弹窗设置默认中心,关闭弹窗清空屏幕
      if (val) {
        this.$refs.popupLocation.setQuery(this.center)
      } else {
        // window.map.remove(this.tempMarker)
      }
    }
  },
  created() {
    this.fetchWellType()
    this.resultList = []
  },
  mounted() {
    this.$nextTick(() => {
      this.windowResize(window.innerHeight, window.innerWidth)
    })
  },
  beforeDestroy() {
    this.$store.dispatch('settings/changeSetting', {
      key: 'breadcrumb',
      value: true
    })
    this.$store.dispatch('settings/changeSetting', {
      key: 'tagsView',
      value: true
    })
    if (this.clock) {
      clearInterval(this.clock)
      this.clock = null
    }
  },
  beforeCreate: function() { // 从后台获取系统配置,根据配置判断是否加载验证码控件
    this.$store.dispatch('settings/changeSetting', {
      key: 'breadcrumb',
      value: false
    })
    this.$store.dispatch('settings/changeSetting', {
      key: 'tagsView',
      value: false
    })
  },
  methods: {
    windowResize(height, width) {
      // 查找header高度
      const el_header = document.getElementById('app-header')
      let bodyHeight = height - (el_header ? el_header.clientHeight : 56)
      if (store.getters.tagsView) {
        const el_tagsView = document.getElementById('tags-view-container')
        bodyHeight -= el_tagsView ? el_tagsView.clientHeight : 34
      }
      if (breadcrumb) {
        const el_navbar = document.getElementsByClassName('navbar')
        bodyHeight -= el_navbar ? el_navbar[0].clientHeight : 48
      }
      // 减去2个padding
      bodyHeight -= 5
      store.dispatch('settings/ChangeHeight', bodyHeight)
    },
    // initBaseMap() {
    //   const url2021 = 'http://172.20.90.108:8081/geoesb/proxy/5a44607b2e814658b463b76f9675bd3e/9bf164775ad94a18a5324f0eb681deea'
    //   const url2020 = 'http://172.20.90.108:8081/geoesb/proxy/4fb75f7491c94356a9dd58a44d0dc57b/9bf164775ad94a18a5324f0eb681deea'
    //
    //   var layerProvider = new Cesium.WebMapTileServiceImageryProvider({
    //     url: url2021 + '/Layers/default/Custom_Layers/{TileMatrix}/{TileRow}/{TileCol}.png',
    //     layer: 'wzmap_map',
    //     style: 'default',
    //     tileMatrixSetID: 'default028mm',
    //     format: 'image/png',
    //     tilingScheme: new Cesium.GeographicTilingScheme(),
    //     tileMatrixLabels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21']
    //   })
    //   layer2021 = window.viewer.imageryLayers.addImageryProvider(layerProvider)
    //   layer2021.alpha = this.alpha / 100
    //
    //   layerProvider = new Cesium.WebMapTileServiceImageryProvider({
    //     url: url2020 + '?service=WMTS&request=GetTile&version=1.0.0&layer=JN2020DOM_05M&style=default&format=image/png&TileMatrixSet=CustomCRS4490ScaleJN2020DOM_05M&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}',
    //     layer: 'wzmap_map',
    //     style: 'default',
    //     tileMatrixSetID: 'default028mm',
    //     format: 'image/png',
    //     tilingScheme: new Cesium.GeographicTilingScheme(),
    //     tileMatrixLabels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21']
    //   })
    //   layer2020 = window.viewer.imageryLayers.addImageryProvider(layerProvider)
    //   layer2020.alpha = this.alpha / 100
    //
    //   layer2021.show = false
    // },
    // 初始化放这里
    onMapload(map, center) {
      window.map = map
      this.center = center
      underground = new mars3d.thing.Underground({ alpha: this.alpha / 100 })
      window.map.addThing(underground)
      alarm_layer = new mars3d.layer.GraphicLayer({ name: '报警图层' })
      window.map.addLayer(alarm_layer)
      this.initLine()
      this.initPoint()
      window.map.on(mars3d.EventType.cameraChanged, this.cameraChange, this)
    },
    async initLine(where='1<>1') {
      rqline_layer.forEach(item => window.map.removeLayer(item))
      rqline_layer = []
      // 三维管线
      rqline_layer.push(polylineVolumeP('0', '#FF7FE9', '燃气管线', 0.1, '', where))
      // 二维管线
      rqline_layer.push(polylineC('0', '#FF7FE9', '燃气管线', 3, where))
    },
    async initPoint(condition = '') {
      // this.mapLoading = true
      if (rqwell_layer !== null) {
        window.map.removeLayer(rqwell_layer['2D'])
        window.map.removeLayer(rqwell_layer['3D'])
      }
      if (rqbox_layer !== null) {
        window.map.removeLayer(rqbox_layer['2D'])
        window.map.removeLayer(rqbox_layer['3D'])
      }

      // 设备图层
      if (dev_layer.length !== 0) {
        dev_layer.forEach(item => window.map.removeLayer(item))
      }
      dev_layer = []

      const rq = condition === '' ? '1<>1' : "编号 LIKE '%" + condition + "%' or 附属物名称 LIKE '%" + condition + "%' or 所属道路 LIKE '%" + condition + "%'"
      const bsq = condition === '' ? '1<>1' : "编号 LIKE '%" + condition + "%' or 对象名称 LIKE '%" + condition + "%' or 所属道路 LIKE '%" + condition + "%'"
      rqwell_layer = createPointModelLayer('1', '燃气阀门井', '../static/images/燃气阀门井.png', '../static/model/rq.gltf', 1.5, rq,this.layerColor[0])
      rqbox_layer = createPointModelLayer('2', '燃气调压箱', '../static/images/燃气调压箱.png', '../static/model/tyx.glb', 0.1, rq,this.layerColor[1])
      for (let i = 2; i < 12; i++) {
        dev_layer.push(createPointLayer(this.layerName[i], i + 1, i <= 6 ? '../static/images/标识器.png' : '../static/images/' + this.layerName[i] + '.png', bsq, this.layerColor[i]))
      }
      const that = this
      rqwell_layer['2D'].on(mars3d.EventType.load, function(event) {
        that.mapReady()
      })
    },
    // 控制二维线的显隐
    // todo
    cameraChange() {
      if (window.map.level >= 19 && this.alpha < 90) {
        // 展示该展示的
        rqwell_layer['3D'].show = this.checkedLayer.indexOf('well-燃气阀门井') !== -1
        rqbox_layer['3D'].show = this.checkedLayer.indexOf('well-燃气调压箱') !== -1
      } else {
        // 隐藏
        rqwell_layer['3D'].show = false
        rqbox_layer['3D'].show = false
      }
    },
    // 初始化放这里
    mapReady() {
      this.refreshAlarm()
      this.fetchWellList() // 加载全部井
      this.firstAmount = true
      this.toolShow = true
      // if (this.refreshType === 'clock') { // 如果需要倒计时刷新的
      setTimeout(() => { this.countDown() }, 1000)
      // }
    },
    // 过滤图层
    filterLayer(checkedLayer) {
      this.checkedLayer = checkedLayer
      // 0.选中or没选中井图层
      if (checkedLayer.indexOf('well-燃气阀门井') !== -1) {
        rqwell_layer['2D'].show = true
        rqwell_layer['3D'].show = true
      } else {
        rqwell_layer['2D'].show = false
        rqwell_layer['3D'].show = false
      }
      if (checkedLayer.indexOf('well-燃气调压箱') !== -1) {
        rqbox_layer['2D'].show = true
        rqbox_layer['3D'].show = true
      } else {
        rqbox_layer['2D'].show = false
        rqbox_layer['3D'].show = false
      }

      // 1.选中or没选中管线图层
      checkedLayer.indexOf('line') !== -1 ? rqline_layer.forEach(item => { item.show = true }) : rqline_layer.forEach(item => { item.show = false })

      // 2.选中or没选中设备图层
      const devTypes = checkedLayer.filter(item => item.indexOf('dev-') > -1).map(item => item.substring(4))
      dev_layer.forEach(layer => { layer.show = devTypes.indexOf(layer.options.name) > -1 })

      // // 3.选中or没选中报警图层
      checkedLayer.indexOf('alarm') !== -1 ? alarm_layer.show = true : alarm_layer.show = false
    },
    // 切换底图
    // changeBaseMap(type) {
    //   this.baseLayer = type
    //   if (type === 'gaode_vec') {
    //     layer2021.show = true
    //     layer2020.show = false
    //     window.viewer.imageryLayers.raiseToTop(layer2021)
    //     // window.map.basemap = 1112
    //     // if (this.bloomEffect !== null) {
    //     //   this.bloomEffect.enabled = false
    //     // }
    //   } else {
    //     layer2021.show = false
    //     layer2020.show = true
    //     window.viewer.imageryLayers.raiseToTop(layer2020)
    //     // window.map.basemap = 1113
    //     // if (this.bloomEffect !== null) {
    //     //   this.bloomEffect.enabled = true
    //     // }
    //   }
    // },
    changeBaseMap(type) {
      this.baseLayer = type
      if (type === 'dark') {
        this.basemap = 1112
      } else if (type === 'gaode_vec') {
        this.basemap = 1111
      } else {
        this.basemap = 1113
      }
    },
    // 倒计时函数
    countDown() {
      this.clock = setInterval(() => {
        this.count--
        if (this.count < 0) { // 当倒计时小于0时清除定时器
          this.refreshAlarm()
          this.count = this.baseConfig.refreshTime
        }
      }, 1000)
    },
    // 获取点位类型,显示点位类型下拉
    fetchWellType() {
      // getWellType().then(response => {
      // this.wellTypeList = []
      // // 如果该用户支持的点位类型只有一个,则不显示该筛选框
      // const supportWellTypes = this.$store.getters.wellTypes
      // this.wellTypeList = response.data.filter(wellType => {
      //   return supportWellTypes.findIndex(item => item == wellType.value) > -1
      // })
      const wellLayer = {
        id: 'well',
        name: '井图层',
        children: this.layerName.map(item => {
          return {
            id: 'well-' + item,
            name: item
          }
        }).splice(0, 2)
      }
      const lineLayer = {
        id: 'line',
        name: '管线图层',
        children: this.layerName.map(item => {
          return {
            id: 'line-' + item,
            name: item
          }
        }).splice(12, 1)
      }
      const devLayer = {
        id: 'dev',
        name: '设备图层',
        children: this.layerName.map(item => {
          return {
            id: 'dev-' + item,
            name: item
          }
        }).splice(2, 10)
      }
      this.layers.splice(0, 1, wellLayer)
      this.layers.splice(1, 1, lineLayer)
      this.layers.splice(2, 1, devLayer)

      if (this.baseConfig.showAllWells) {
        this.checkedLayer = ['well', 'line', 'dev']
        wellLayer.children.forEach(item => this.checkedLayer.push('well-' + item.name))
        lineLayer.children.forEach(item => this.checkedLayer.push('line-' + item.name))
        devLayer.children.forEach(item => {
          this.checkedLayer.push('dev-' + item.name)
        })
        // this.checkedLayer = [...this.checkedLayer, 'well', this.wellTypeList.map(item => 'well-' + item.value)]
      } else {
        this.checkedLayer = [...this.checkedLayer]
      }
      if (this.wellTypeList.length <= 1) {
        this.showWellType = false
      }
      // })
    },
    // 清空查询
    clearSearch() {
      this.searchMarkers = []
      this.resultList = []
    },
    // 数据查询
    search(keywords) {
      if (keywords === '') {
        this.isAll = true
        this.initPoint('')
      } else {
        this.isAll = false
        this.resultList = this.markers.filter(item => {
          if (item.wellCode.includes(keywords) || item.wellName.includes(keywords) || item.position.includes(keywords)) {
            return true
          } else {
            return false
          }
        })
        this.initPoint(keywords)
      }
    },
    // 搜索结果页面变化,触发地图展示列表中所有
    searchPageChange(currentMarkers) {
      // 增加查询展示图层
      this.searchMarkers = currentMarkers
    },
    // 点击搜索结果项居中,弹窗
    searchItemClick(marker) {
      const point = rqwell_layer['2D'].graphics.filter(item => {
        return item.options.id === marker.wellCode
      })[0]
      if (point === undefined) {
        this.$message.warning('当前建设无次井,请联系管理员!')
        return
      }
      var center = { lat: point.options.position[1], lng: point.options.position[0], alt: 300, heading: 360, pitch: -90 }
      window.map.setCameraView(center)
      point.openPopup()
    },
    // 获取全部井列表
    fetchWellList() {
      this.loading = true
      getWellListZq().then(response => {
        this.loading = false
        if (response.code === 200) {
          const wells = response.data
          if (wells.length > 0) {
            this.markers = []
            for (const well of wells) {
              this.markers.push(well)
            }
          }
        }
        this.loading = false
        // this.mapLoading = false
      })
    },
    // 刷新报警列表
    refreshAlarm() {
      console.log('refreshAlarm')
      this.count = this.baseConfig.refreshTime
      this.loading = true
      // 如果showAlarm为ture, 确保选中图层报警
      if (this.showAlarm && this.checkedLayer.indexOf('alarm') == -1) {
        this.checkedLayer.push('alarm')
      }
      // 删除所有适量数据
      alarm_layer.closePopup().clear()
      // todo
      getAlarmsNowZq().then(response => {
        if (response.code === 200) {
          this.loading = false
          // 判断最新报警时间,若和旧的最新时间不一样,则判断是否需要产生声音
          if (response.data.length > 0) {
            const latestTime = response.data[0].alarmTime
            console.log(latestTime, 'vs', this.latestAlarmTime)
            if (this.latestAlarmTime < latestTime) {
              // 如果不是初次加载并且声音开关开启状态
              if ((!this.alarmFirstAmount) && this.baseConfig.alarmSound) {
                console.log('playAudio')
                this.playAudio()
              }
              this.latestAlarmTime = latestTime
            }
          }
          this.alarmFirstAmount = false // 初次加载完毕

          // 获取当前报警列表
          this.alarmList = response.data // 要显示的报警列表
          this.alarmList.forEach(item => {
            const popup = {
              '设备编号': item.devcode,
              '井编号': item.wellCode,
              '井类型': item.wellTypeName,
              '报警内容': item.alarmContent,
              '报警数值': item.alarmValue,
              '报警时间': item.alarmTime,
              '报警位置': item.position,
              '经纬度': item.coordinateX + ',' + item.coordinateY,
            }
            Tetrahedron(alarm_layer, [item.coordinateX, item.coordinateY], item)
            Graphic_Point(alarm_layer, [item.coordinateX, item.coordinateY], item, popup)
            console.log(alarm_layer)
          })
        }
      })
    },

    // 关闭所有弹窗
    clearInfoWindow() {
      const { map } = this
      map.clearInfoWindow()
    },
    // 点击报警列表
    alarmRowClick(row) {
      // if (!this.isAll) {
      //   this.$message.info('当前搜索条件不为空,请重新搜索')
      //   return
      // }
      // const wellId = row.wellId
      // const point = rqwell_layer['2D'].graphics.filter(item => {
      //   return item.options.id === row.wellCode
      // })[0]
      // if (point === undefined) {
      //   this.$message.warning('当前建设无次井,请联系管理员!')
      //   return
      // }
      // var center = { lat: point.options.position[1], lng: point.options.position[0], alt: 300, heading: 360, pitch: -90 }
      // window.map.setCameraView(center)
      // point.openPopup()
      if (this.showAlarm && this.checkedLayer.indexOf('alarm') == -1) {
        this.checkedLayer.push('alarm')
      }
      const point = alarm_layer.graphics.filter(item => {
        return item.options.id === row.alarmId
      })[0]
      var center = { lat: point.options.position[1], lng: point.options.position[0], alt: 300, heading: 360, pitch: -90 }
      window.map.setCameraView(center)
      point.openPopup()

    },
    // 点击工具箱菜单, menu:{menu:'xxx', name:''}, 建议菜单menu属性的命名与自定义弹窗的show属性名称保持同一规则
    clickMenu(menu) {
      this.closeAllPopup()
      const key = menu.menu + 'WindowShow'
      const obj = {}
      obj[key] = true // 将该值置为false, 需要借助obj中转
      Object.assign(this.menus, obj)
    },
    // 关闭所有菜单点出的弹窗
    closeAllPopup() {
      for (const key in this.menus) {
        if (key.indexOf('WindowShow') > -1) {
          // 将该值置为false, 需要借助obj中转
          const obj = {}
          obj[key] = false
          Object.assign(this.menus, obj)
        }
      }
    },
    // 关闭数据筛选弹窗
    closePopupDataFilter() {
      Object.assign(this.menus, { dataFilterWindowShow: false })
    },
    // 坐标定位,居中,绘点
    setCenter(position) {
      var center = { lat: position[1], lng: position[0], alt: 20000, heading: 360, pitch: -45 }
      window.map.setCameraView(center)
    },
    // 坐标拾取, 在地图上绘点
    pickerPosition() {
      const { searchResultOffset, searchResultIcon, searchResultSize, center } = this
      const icon = new window.AMap.Icon({
        size: toSize(searchResultSize), // 图标尺寸
        image: searchResultIcon, // Icon的图像
        imageSize: toSize(searchResultSize) // 根据所设置的大小拉伸或压缩图片
      })
      const marker = new window.AMap.Marker({
        icon: icon,
        position: center,
        offset: toPixel(searchResultOffset),
        draggable: true
      })
      marker.on('dragend', e => {
        const position = [e.lnglat.lng, e.lnglat.lat]
        this.$refs.popupLocation.setQuery(position)
      })
      marker.setMap(window.map)
      this.tempMarker = marker
    },
    setLine(query) {
      console.log(query)
      const year = new Date().getFullYear()
      let where = '1<>1'
      if(query.deptName !== '') {
        where = "权属单位 LIKE '%" + query.deptName + "%'"
      }
      // const rq =  "编号 LIKE '%" + condition + "%' or 附属物名称 LIKE '%" + condition + "%' or 所属道路 LIKE '%" + condition + "%'"

      switch (query.age) {
        case '':
          break
        case '大于5年':
          where = where === '1<>1'? `建设年代 <= '${year-5}'`: where + ` and 建设年代 <= '${year-5}'`
          break
        case '大于10年':
          where = where === '1<>1'? `建设年代 <= '${year-10}'`: where + ` and 建设年代 <= '${year-10}'`
          break
        case '大于15年':
          where = where === '1<>1'? `建设年代 <= '${year-15}'`: where + ` and 建设年代 <= '${year-15}'`
          break
        case '大于20年':
          where = where === '1<>1'? `建设年代 <= '${year-20}'`: where + ` and 建设年代 <= '${year-20}'`
          break
      }
      console.log(where)
      this.initLine(where)
    },
    // TODO: 关闭坐标定位窗口, 清除地图上的标注
    closePopupLocation() {
      Object.assign(this.menus, { locationWindowShow: false })
    },
    closeLineSearch() {
      Object.assign(this.menus, { lineWindowShow: false })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
.overview-map-container{
  width: 100%;
  overflow: hidden;
  padding: 0px;
  .map-demo{
    width: 100%;
    .svg-icon{
      width: 20px;
      height: 20px;
    }
    .alarm-icon{
      width: 29px;
      height: 30px;
    }
  }
}
.cover{
  position: absolute;
  bottom: 6px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  background-color: #fcfbe8;
  border-radius: 5px;
  width: 270px;
  height: 200px;
  padding: 10px;
  box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
  border-color: rgba(0, 0, 0, .05);
  .cover-item{
    width: 100%;
    height: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #505a5e;
  }
}
.map-zq {
  .el-loading-mask {
    background-color: rgba(255, 255, 255, .3) !important;
  }
  .el-loading-spinner .circular {
    height: 70px;
    width: 70px;
    font-weight: bold;
    font-size: 18px;
    border-radius: 2px;
  }
  .circle_btn{
    background: #419efe;
    margin-top: 5px;
    width: 25px;
    height: 25px;
    text-align: center;
    border-radius: 50%;
    color: white;
    padding-top: 4px;
  }
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
.no-head-scrollbar .el-scrollbar__wrap, has-head-scrollbar .el-scrollbar__wrap {
  padding: 0px 10px;
}
</style>