index.vue 58 KB
Newer Older
葛齐林's avatar
葛齐林 committed
1 2 3
<template lang="pug">
    //div(onselectstart="return false;"  @mousedown="regionMousedown" @mousemove="regionMousemove" @mouseup="regionMouseup")
    div(onselectstart="return false;")
xiexingan's avatar
xiexingan committed
4
        div(class="top_button" style="width:100%;height:40px; padding-top:3px;overflow:hidden;")
葛齐林's avatar
葛齐林 committed
5
            div(style="float:left;margin-left:16px;")
co_dengxiongwen's avatar
co_dengxiongwen committed
6
                div(:class="[item.value,iconId==item.id?item.value+'2':'']" name="iconListNow" :title="item.name" :style="{cursor:editable?'pointer':''}" :id="item.id" @click="changeIcon(item)" v-for="item in typeList")
葛齐林's avatar
葛齐林 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
            div(style="float:right; margin-top:6px;")
                el-button(type="primary" size='mini' style="margin-right:10px;" @click="changeEditable" v-if="!editable && isAuth('sys:point:edit')") 编辑
                el-button(type="primary" size='mini' style="margin-right:10px;" @click="handleCancel" v-if="editable" :disabled='cancelDisabled') 取消
                el-button(type="primary" size='mini' style="margin-right:10px;" @click="updateHandle" v-if="editable && isAuth('sys:point:update')" :disabled='listItem?false:true') 修改
                el-button(type="primary" size='mini' style="margin-right:10px;" @click="deleteHandle" v-if="editable && isAuth('sys:point:delete')" :disabled='listItem?false:true') 删除
                el-button(type="primary" size='mini' style="margin-right:10px;" @click="saveResourceList" :disabled='submitlDisabled' v-if="editable && isAuth('sys:point:save')") 保存
        div(style="clear:both")
        el-container( style='padding-left:0px;')
            el-aside(width="18vw" style='height:750px')
                el-card.treeCard.tree-container(style='min-height:630px;background:#f4f4f4;')
                    div(class="monitor_point_left_top")
                        div.title-bold(slot='header' class="monitor_point_left_topL") 资源点列表
                        div(class="monitor_point_left_topR")
                            el-input(suffix-icon="el-icon-search" size='mini' placeholder="" v-model="searchInput" clearable)
                    //- el-tree(style='background:#f4f4f4;' :data="treeData" ref='tree' :accordion='true' :highlight-current='true' :check-on-click-node='true' :props="defaultProps" :default-expand-all='false' @node-click="handleNodeClick" :default-expanded-keys='defaultExpandedKeys' :node-key='nodeKey' )
                    el-tree.dic_tree( :data="treeData"  ref='tree' :accordion='true' :highlight-current='true' :filter-node-method="filterNode"  :props="defaultProps" :default-expand-all='false' @node-click="handleNodeClick2" :default-expanded-keys='defaultExpandedKeys' :node-key='nodeKey' )
                        span(class="custom-tree-node" style='width:90%;line-height: 18px;' slot-scope="{ node, data }")
                            span(v-if="node.data.level == 3" class="el-icon-zhandian xa-icon")
                            //- span(v-if="node.data.level == 3 && node.data.iconB" class="el-icon-wq-treeIcon1")
                            span(v-if="node.data.level == 4 && node.data.iconB" class="el-icon-wq-treeIcon1 xa-icon")
                            span(v-if="node.data.level == 4 && !node.data.iconB" class="el-icon-wq-treeIcon xa-icon")
                            span(v-if="node.data.level == 5 && node.data.name == '视频监控'" class="el-icon-shipin xa-icon")
                            span(v-if="node.data.level == 5 && node.data.name == '出入口控制'" class="el-icon-churukoukongzhi xa-icon")
                            span(v-if="node.data.level == 5 && node.data.name == '入侵报警'" class="el-icon-ruqinbaojing xa-icon")
                            span(v-if="node.data.level == 5 && node.data.name == '安全检查'" class="el-icon-anquanjiancha xa-icon")
                            span(v-if="node.data.level == 6 " :class="node.data.icon+'7'" class='xa-icon')
                            <span style="position: relative;" >&nbsp;{{node.label}}<span style="width:25px; height:16px; position: absolute;left: -46px;top: -3px;"></span></span>
                            span(v-if=" node.data.iconB" class='el-icon-my-treeFlag')
            el-main(style="padding:0px;")
                el-card.tableCard
                    div(slot='header'  ref="sprtDom" )
                        el-row(:span="24")
                            el-col(:md='12' :sm="5" class='tier-btn')
                                el-button(type="primary" size='mini' plain :class="[checkedData.tierId===item.id?'active-tier':'']" style="float:left;margin:6px 10px 0 0; " v-for="item in mapList" :key='item.id' @click="changeMap(item)") {{item.name}}
                            el-col(:md='12' :sm="5")
                                div(style="float:right;")
                                    div( :class="item.value" :title="item.name" style="margin:5px 5px 0 0;" v-for="item in iconNameListBottom" @click="iconClick(item)")
                    el-row(style="padding-bottom:15px;height:680px" ,:span="24")
                        el-col()
                            <div id="map" style="width: 100%;height: 680px;position: relative;"></div>
                        el-col()

                    // 弹窗, 新增 / 修改
co_dengxiongwen's avatar
co_dengxiongwen committed
50
                    add-or-update(v-if='addOrUpdateVisible', ref='addOrUpdate', :p-list='list' @refreshdatalist='refreshdatalist' @refreshBean='refreshBean' @addNotify='addNotify')
葛齐林's avatar
葛齐林 committed
51 52 53 54 55
                    query-detail(v-if='queryDetailVisible', ref='queryDetail')
            span(:class="spanDragData.name" v-if="spanDragData.show" :style="{left:spanDragData.x+'px',top:spanDragData.y+'px',position:'fixed'}")
</template>

<script>
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
import AddOrUpdate from './add-or-update'
import QueryDetail from './query-detail'
import { getUUID } from '@/util'
import Vue from 'vue'
// openlayer
import 'ol/ol.css'
import { Map, View } from 'ol'
import { Projection } from 'ol/proj'
import { getCenter } from 'ol/extent'
import Modify from 'ol/interaction/Modify'
import ImageLayer from 'ol/layer/Image'
import ImageStatic from 'ol/source/ImageStatic'
import Zoom from 'ol/control/Zoom'
import { DoubleClickZoom } from 'ol/interaction'
import Draw from 'ol/interaction/Draw'
import LineString from 'ol/geom/LineString'
葛齐林's avatar
葛齐林 committed
72

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
// 图上图标相关
import OlFeature from 'ol/Feature'
import OlGeomPoint from 'ol/geom/Point'
import OlLayerVector from 'ol/layer/Vector'
import OlSourceVector from 'ol/source/Vector'
import OlStyleStyle from 'ol/style/Style'
import OlStyleIcon from 'ol/style/Icon'
// 用来添加相关文字描述的
import Text from 'ol/style/Text'
import Fill from 'ol/style/Fill'
import Stroke from 'ol/style/Stroke'
let that
export default {
  data() {
    return {
      featureItem: '',
      listItem: '',
      imgLayerList: [],
      iconId: '',
      iconStyle: null,
      mapsrc1: null,
      imgurl1: '',
      mapsrc2: null,
      imgurl2: '',
      mapsrc3: null,
      imgurl3: '',
      imageSrc: '', //资源点图片名称
      jing: '',
      wei: '',
      hwId: [],
      gxRotate: '',
      ssId: '',
      isDone: false,
      drawer: false,
      isCollapse: true,
      delflag: true,
      addOrUpdateVisible: false,
      queryDetailVisible: false,
      urlPath: window.CONFIG.urlPath,
      treeData: [],
      systemList: [],
      defaultExpandedKeys: [],
      defaultProps: {
        children: 'children',
        label: 'name',
        level: 'level'
      },
      nodeKey: 'id',
      station: {}, //当前选择的站点
      mapList: [], //当前站点的所有层
      stationMap: {}, //当前选择的层
      resource: {}, //当前选择的资源点
      typeList: [],
      checkedData: {
        stationId: '',
        stationName: '',
        type: '',
        tierId: '',
        tierName: '',
        resourceId: '',
        sId: localStorage.getItem('stationId')
      },
      currentNode: {},
      dragAble: false,
      list: [],
      searchInput: '',
      obj: 'pointer-events:none',
      editable: false,
      clickItem: {},
      iconNameListBottom: [],
      spanDragData: {
        x: 0,
        y: 0,
        show: false,
        name: ''
      },
      spanDragListNow: {},
      mousemoveStatus: false,
      drawType: 'None',
      draw: null,
      lineList: [],
      vectorLayer: null,
      lineVectorLayer: null,
      modify: null,
      //当前选择的层级
      tierMap: null,
      cancelDisabled: false,
      submitlDisabled: false
    }
  },
  components: {
    AddOrUpdate,
    QueryDetail
  },
  watch: {
    searchInput(val) {
      this.$refs.tree.filter(val)
    }
  },
  created() {
    that = this
    this.initTree()
    this.initResourceTypeDicList()
  },
  methods: {
    changeIcon(e) {
      this.iconId = e.id
      this.iconStyle = null
      this.lineList = []
      this.drawType = 'None'
      if (!this.map) {
        return
      }
      this.map.removeInteraction(this.draw)
      if (this.editable) {
        this.iconStyle = e
        if (
          this.iconStyle.name === '红外探测器' ||
          this.iconStyle.name === '振动光纤'
        ) {
          this.drawType = 'LineString'
        } else {
          this.drawType = 'Point'
        }
      }
      this.addInteraction()
    },
    // 初始化地图
    initMap(url) {
      let mapList = this.mapList
      // 计算静态地图映射到地图上的范围
      let extent = [-1100, 110, 1460, 820]
      let projection = new Projection({
        // 投影
        code: 'xkcd-image',
        units: 'pixels',
        extent: extent
      })
      if (mapList.length > 0) {
        for (var i = 0; i < mapList.length; i++) {
          let layerItem = new ImageLayer({
            id: mapList[i].id,
            source: new ImageStatic({
              url: mapList[i].readPath, //这里添加静态图片的地址
              projection: projection,
              imageExtent: extent
            }),
            visible: false
          })
          this.imgLayerList.push(layerItem)
        }
      }
      let zoomControl = new Zoom({
        delta: 0.2,
        zoomInTipLabel: '',
        zoomOutTipLabel: ''
      })
      // 大图
      this.map = new Map({
        target: 'map',
        layers: this.imgLayerList,
        controls: [zoomControl],
        view: new View({
          projection: projection,
          center: getCenter([0, 0, 418, 600]), // 获取范围的中心坐标。
          zoom: 2.5,
          maxZoom: 5,
          minZoom: 1.5,
          extent: [-1100, -100, 2000, 1000] //[minX,minY,maxX,maxY] 控制拖动
        })
      })
      // 删除默认的双击事件
      const dblClickInteraction = this.map
        .getInteractions()
        .getArray()
        .find((interaction) => {
          return interaction instanceof DoubleClickZoom
        })
      this.map.removeInteraction(dblClickInteraction)
葛齐林's avatar
葛齐林 committed
252

253
      this.changeVectorLayer(this.list)
co_dengxiongwen's avatar
co_dengxiongwen committed
254

co_dengxiongwen's avatar
co_dengxiongwen committed
255 256 257 258 259 260 261
      this.map.on('click', function (evt) {
        let feature = evt.map.forEachFeatureAtPixel(
          evt.pixel,
          function (feature) {
            return feature
          }
        )
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
        console.log('***当前点击***', feature)
        let coordinate = evt.coordinate //鼠标单击点的坐标
        if (feature) {
          that.cancelDisabled = false
          for (let i in that.list) {
            //true弹出详情页面
            that.mapClick(feature, that.list[i], true)
          }
        } else {
          //编辑状态下添加资源点事件(不包含红外探测器和振动光纤)
          if (that.iconStyle === null || !that.editable) {
          } else {
            if (
              that.iconStyle.name === '红外探测器' ||
              that.iconStyle.name === '振动光纤'
            ) {
              return
            }
            let bean = that.addPoint(coordinate)
            that.cancelDisabled = false
            that.list.push(bean)
            that.iconStyle = null
            that.lineList = []
葛齐林's avatar
葛齐林 committed
285

286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
            let newFeature = that.vectorLayer
              .getSource()
              .getFeatureById(bean.key)
            for (let i in that.list) {
              //true弹出详情页面
              that.mapClick(newFeature, that.list[i], false)
            }
            that.updateHandle()
          }
        }
      })
    },
    openAddOrUpdate(item) {
      if (this.editable) {
        this.addOrUpdateHandle(item)
      } else {
        this.queryDetail(item)
      }
    },
    mapClick(feature, item, flag) {
xiexingan's avatar
xiexingan committed
306
      console.log(item, 11)
307 308 309 310 311 312 313 314 315 316 317 318
      //默认样式
      let style = this.getPointStyle(item.imageSrc + '.png', item.name)
      //选中样式
      let style2 = this.getPointStyle(item.imageSrc + '2.png', item.name, 0.3)
      //获取feature对象
      let feature_ = this.vectorLayer.getSource().getFeatureById(item.id)
      //获取红外探测器或者振动光纤第二个点的feature对象
      let featureEnd = this.vectorLayer
        .getSource()
        .getFeatureById(item.key + 'end')
      if (feature_) {
        if (feature_ === feature || featureEnd === feature) {
xiexingan's avatar
xiexingan committed
319
          // console.log('选中了', feature_)
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
          //修改选中样式
          feature_.setStyle(style2)
          if (featureEnd) {
            featureEnd.setStyle(style2)
          }
          //未编辑状态下 点击查看
          if (flag) {
            if (!this.editable) this.openAddOrUpdate(item)
          }
          that.listItem = JSON.parse(JSON.stringify(item)) //地图上图标对应 list中的数据
        } else {
          //清除选中以外的样式
          feature_.setStyle(style)
          if (featureEnd) {
            featureEnd.setStyle(style)
          }
        }
      } else {
        //获取新增的feature对象
        let newFeature = this.vectorLayer.getSource().getFeatureById(item.key)
        //获取红外探测器或者振动光纤第二个点的feature对象
        let newFeatureEnd = this.vectorLayer
          .getSource()
          .getFeatureById(item.key + 'end')
        if (newFeature) {
          if (newFeature === feature || newFeatureEnd === feature) {
            newFeature.setStyle(style2)
            if (newFeatureEnd) {
              newFeatureEnd.setStyle(style2)
            }
            //未编辑状态下 点击查看
            if (flag) {
              if (!this.editable) this.openAddOrUpdate(item)
            }
            that.listItem = JSON.parse(JSON.stringify(item))
          } else {
            //清除选中以外的样式
            newFeature.setStyle(style)
            if (newFeatureEnd) {
              newFeatureEnd.setStyle(style)
            }
          }
        }
      }
    },
    //添加点
    addPoint(coordinate) {
      let bean = this.getNewBox(
        this.iconStyle,
        parseFloat(coordinate[0]).toFixed(2),
        parseFloat(coordinate[1]).toFixed(2),
        this.iconStyle.value
      )
      //新建一个要素ol.Feature
      let newFeature = new OlFeature({
        geometry: new OlGeomPoint(coordinate) //几何信息
      })
      newFeature.setStyle(
        this.getPointStyle(this.iconStyle.value + '.png', this.iconStyle.name)
      ) //设置要素样式
      newFeature.setId(bean.key)
      this.vectorLayer.getSource().addFeature(newFeature)
      //添加需要拖动的点
      this.modify.source_.addFeature(newFeature)
      return bean
    },
    //添加线
    addInteraction() {
      let value = this.drawType
      if (value === 'LineString') {
        //创建类型为LineString的Draw对象
        this.draw = new Draw({
          source: this.vectorLayer.getSource(),
          type: this.drawType,
          maxPoints: 2,
          style: this.getLineStyle(),
          // 绘制时停止点击事件
          stopClick: true
        })
        //添加绘制对象
        this.map.addInteraction(this.draw)
        let bean = null
葛齐林's avatar
葛齐林 committed
402

403
        //画线开始事件
co_dengxiongwen's avatar
co_dengxiongwen committed
404
        this.draw.on('drawstart', function (evt) {
405 406 407 408 409 410 411 412
          //获取坐标
          let coordinate = evt.target.sketchCoords_[0]
          //添加点
          bean = that.addPoint(coordinate)
          bean.addOrUpdate = 'save'
          that.list.push(bean)
        })
        //画线结束事件
co_dengxiongwen's avatar
co_dengxiongwen committed
413
        this.draw.on('drawend', function (evt) {
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
          //将draw绘制的线设置为透明色
          evt.feature.setStyle(that.setLineNone)
          //获取坐标
          let coordinate_ = evt.target.sketchCoords_[0]
          let coordinate = evt.target.sketchCoords_[1]
          let lineCoordinate = []
          lineCoordinate.push([coordinate_[0], coordinate_[1]])
          lineCoordinate.push([coordinate[0], coordinate[1]])
          //自定义绘制线
          let lineFeature = new OlFeature(new LineString(lineCoordinate))
          lineFeature.setId(bean.key + 'line')
          that.lineVectorLayer.getSource().addFeature(lineFeature)
          //添加需要拖动的线
          that.modify.source_.addFeature(lineFeature)
          //新建一个要素ol.Feature
          let newFeature = new OlFeature({
            geometry: new OlGeomPoint(coordinate) //几何信息
          })
          newFeature.setStyle(
            that.getPointStyle(
              that.iconStyle.value + '.png',
              that.iconStyle.name
            )
          ) //设置要素样式
          newFeature.setId(bean.key + 'end')
          //添加结束的点
          that.vectorLayer.getSource().addFeature(newFeature)
          //添加需要拖动的点
          that.modify.source_.addFeature(newFeature)
co_dengxiongwen's avatar
co_dengxiongwen committed
443

444 445 446 447 448 449 450
          bean.xpoint = parseFloat(coordinate[0]).toFixed(2)
          bean.ypoint = parseFloat(coordinate[1]).toFixed(2)
          that.list.push(bean)
          that.iconStyle = null
          that.lineList = []
          //删除绘制对象
          that.map.removeInteraction(that.draw)
葛齐林's avatar
葛齐林 committed
451

452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
          for (let i in that.list) {
            //true弹出详情页面
            that.mapClick(
              that.vectorLayer.getSource().getFeatureById(bean.key),
              that.list[i],
              false
            )
          }
          that.updateHandle()
        })
      }
    },
    setLineNone() {
      let style = new OlStyleStyle({
        stroke: new Stroke({
          color: 'transparent',
          width: 1
        })
      })
      return style
    },
    getLineStyle(src, name, flag) {
      let style = new OlStyleStyle({
        stroke: new Stroke({
          color: '#409EFF',
          width: 3
        })
      })
      return style
    },
    getPointStyle(src, name, zoom) {
      let style = new OlStyleStyle({
        image: new OlStyleIcon({
          anchor: [0.5, 0.5],
          scale: zoom || 0.4,
          //rotation:0 旋转度
xiexingan's avatar
xiexingan committed
488
          src: require('@/assets/images/imgs/' + src)
489 490 491
        }),
        text: new Text({
          text: name, // 添加文字描述
高超凡's avatar
高超凡 committed
492 493
          font: 'bold 14px font-size', // 设置字体大小
          stroke: new Stroke({ color: 'white', width: 5 }), //设置文字背景
494 495
          fill: new Fill({
            // 设置字体颜色
高超凡's avatar
高超凡 committed
496
            color: 'blue'
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
          }),
          offsetY: 30 // 设置文字偏移量
        })
      })
      return style
    },
    changeVectorLayer(list) {
      if (list) {
        this.list = list
      } else {
        return
      }
      if (this.map) {
        this.map.removeLayer(this.vectorLayer)
        this.map.removeLayer(this.lineVectorLayer)
        this.map.removeInteraction(this.modify)
      } else {
        return
      }
葛齐林's avatar
葛齐林 committed
516

517 518 519 520 521 522 523 524 525 526 527 528
      this.lineVectorLayer = new OlLayerVector({
        source: new OlSourceVector({
          features: []
        }),
        style: new OlStyleStyle({
          stroke: new Stroke({
            color: '#409EFF',
            width: 3
          })
        })
      })
      this.map.addLayer(this.lineVectorLayer)
葛齐林's avatar
葛齐林 committed
529

530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
      let featuresArr = []
      let lineLastArr = []
      for (let i in list) {
        if (list[i].imageSrc) {
          //振动光纤和红外线对射
          if (
            list[i].type === 'e670524ecb9e4a03b8ddbc7d91a63b1b' ||
            list[i].type === '4f69755dbc0c45e49c142857286c5669'
          ) {
            let lineFeatures = []
            lineFeatures.push([list[i].xlongit, list[i].ylat])
            lineFeatures.push([list[i].xpoint, list[i].ypoint])
            let lineFeature = new OlFeature(new LineString(lineFeatures))
            lineFeature.setId(list[i].id + 'line')
            this.lineVectorLayer.getSource().addFeature(lineFeature)
            lineLastArr.push(list[i])
          }
          featuresArr.push(this.getFeature(list[i].xlongit, list[i].ylat))
          let style = this.getPointStyle(
            list[i].imageSrc + '.png',
            this.list[i].name
          )
          featuresArr[i].setStyle(style)
          featuresArr[i].setId(list[i].id)
        } else {
          continue
        }
      }
      let LinefeaturesArr = []
      for (let i in lineLastArr) {
        LinefeaturesArr.push(
          this.getFeature(lineLastArr[i].xpoint, lineLastArr[i].ypoint)
        )
        let style = this.getPointStyle(
          lineLastArr[i].imageSrc + '.png',
          lineLastArr[i].name
        )
        LinefeaturesArr[i].setStyle(style)
        lineLastArr[i].key = lineLastArr[i].id
        LinefeaturesArr[i].setId(lineLastArr[i].key + 'end')
        this.list.push(lineLastArr[i])
      }
葛齐林's avatar
葛齐林 committed
572

573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
      this.vectorLayer = new OlLayerVector({
        source: new OlSourceVector({
          features: featuresArr.concat(LinefeaturesArr)
        })
      })
      this.map.addLayer(this.vectorLayer)
      //将点和线的Feature对象 ,放在一个数组里面
      let modifyFeatures = this.lineVectorLayer
        .getSource()
        .getFeatures()
        .concat(this.vectorLayer.getSource().getFeatures())
      // this.modify = new Modify({
      //       source: this.vectorLayer.getSource()
      //   })
      this.modify = new Modify({
        source: new OlSourceVector({
          features: modifyFeatures
        })
      })
      this.modify.on('modifyend', (e) => {
        let pixel = this.map.getEventPixel(e.mapBrowserEvent.originalEvent)
        //获取当前拖拽的feature对象,该feature没有id,
        let feature = e.mapBrowserEvent.map.forEachFeatureAtPixel(
          pixel,
co_dengxiongwen's avatar
co_dengxiongwen committed
597
          function (feature) {
598 599 600
            return feature
          }
        )
co_dengxiongwen's avatar
co_dengxiongwen committed
601

602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
        if (feature) {
          that.cancelDisabled = false
          //feature与features数组对象比较Geometry对象的坐标是否相等可得出当前拖拽的feature的对象
          for (let i in that.list) {
            //根据id获取feature对象
            //let feature_ = that.vectorLayer.getSource().getFeatureById(that.list[i].id)
            //新增的feature对象没保存,是没有id通过,key获取feature对象
            let featureKey = that.vectorLayer
              .getSource()
              .getFeatureById(that.list[i].key)
            //红外探测器和振动光纤的第二点同过key+'end'获取feature对象
            let featureEnd = that.vectorLayer
              .getSource()
              .getFeatureById(that.list[i].key + 'end')
            if (featureKey || featureEnd) {
              //获取坐标
              let coordinate
              //if (feature_) coordinate = feature_.getGeometry().flatCoordinates
              if (featureKey) {
                coordinate = featureKey.getGeometry().flatCoordinates
              }
              if (
                featureKey &&
                coordinate.toString() ===
                  feature.getGeometry().flatCoordinates.toString()
              ) {
                that.list[i].xlongit = parseFloat(coordinate[0]).toFixed(2)
                that.list[i].ylat = parseFloat(coordinate[1]).toFixed(2)
                that.listItem = JSON.parse(JSON.stringify(that.list[i]))
                // if (that.listItem) {
                //     that.listItem.xlongit = parseFloat(coordinate[0]).toFixed(2)
                //     that.listItem.ylat = parseFloat(coordinate[1]).toFixed(2)
                // }
                let style = that.getPointStyle(
                  that.list[i].imageSrc + '2.png',
                  that.list[i].name,
                  '0.3'
                )
                featureKey.setStyle(style)
葛齐林's avatar
葛齐林 committed
641

642 643 644 645 646 647 648 649
                //break
              } else {
                if (featureKey) {
                  let style = that.getPointStyle(
                    that.list[i].imageSrc + '.png',
                    that.list[i].name
                  )
                  featureKey.setStyle(style)
葛齐林's avatar
葛齐林 committed
650
                }
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
              }
              if (featureEnd) {
                coordinate = featureEnd.getGeometry().flatCoordinates
              }
              if (
                featureEnd &&
                coordinate.toString() ===
                  feature.getGeometry().flatCoordinates.toString()
              ) {
                that.list[i].xpoint = parseFloat(coordinate[0]).toFixed(2)
                that.list[i].ypoint = parseFloat(coordinate[1]).toFixed(2)
                that.listItem = JSON.parse(JSON.stringify(that.list[i]))
                // if (that.listItem) {
                //     that.listItem.xpoint = parseFloat(coordinate[0]).toFixed(2)
                //     that.listItem.ypoint = parseFloat(coordinate[1]).toFixed(2)
                // }
                let style = that.getPointStyle(
                  that.list[i].imageSrc + '2.png',
                  that.list[i].name,
                  '0.3'
                )
                featureEnd.setStyle(style)
                //break
              } else {
                if (featureEnd) {
                  let style = that.getPointStyle(
                    that.list[i].imageSrc + '.png',
                    that.list[i].name
                  )
                  featureEnd.setStyle(style)
葛齐林's avatar
葛齐林 committed
681
                }
682 683 684 685 686
              }
            }
          }
        }
      })
葛齐林's avatar
葛齐林 committed
687

688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
      if (this.editable) {
        //添加拖拽监听事件
        this.map.addInteraction(this.modify)
      }
    },
    handRotate(id) {
      this.hwId.push(id)
    },
    getFeature(x, y) {
      return new OlFeature({
        type: 'icon',
        geometry: new OlGeomPoint([x, y])
      })
    },
    handwheel(e, item) {
      let str = e.wheelDelta
      if (str < 0) {
        // 下滚动 100
        item.width = parseInt(item.width) - 10
        if (item.width <= 40) {
          item.width = 40
        }
        //console.log(item.width)
      }
      if (str > 0) {
        // 上滚动 -100
        item.width = parseInt(item.width) + 10
        if (item.width >= 600) {
          item.width = 600
        }
        //console.log(item.width)
      }
    },
    //新建资源点对象
    getNewBox(item, j, w, src) {
      let uuid = getUUID()
        .replace('-', '')
        .replace('-', '')
        .replace('-', '')
        .replace('-', '')
      return {
        id: uuid,
        key: uuid,
        level: 6,
        name: item.name,
        password: '',
        port: '',
        remark: '',
        stationId: this.checkedData.stationId,
        stationName: this.checkedData.stationName,
        tierId: this.checkedData.tierId,
        tierName: this.checkedData.tierName,
        type: item.id,
co_dengxiongwen's avatar
co_dengxiongwen committed
741
        modeTypes: '',
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
        equipmentModel: '',
        maxPower: '',
        installDate: null,
        maintenanceDate: null,
        region: '',
        icon: item.value,
        iconPath: '',
        username: 'admin',
        // xpoint: x || '100',
        // ypoint: y || '100',
        width: 200,
        xlongit: j || '',
        ylat: w || '',
        imageSrc: src,
        isLine: 0,
        //生成资源点编码的前缀
        codeType: item.remark,
        addOrUpdate: 'save'
      }
    },
    // 树节点过滤
    filterNode(value, data) {
      if (!value) return true
      return data.name.indexOf(value) !== -1
    },
    initTree() {
      // console.log('stationId:', this.checkedData.sId)
      this.$http({
        url: this.$http.adornUrl('/liResource/getTreeList'),
        method: 'post',
        data: {
          stationId: this.checkedData.sId,
          name: this.searchInput
        }
      }).then((data) => {
        if (data && data.code === 0) {
          this.treeData = data.tree
          console.log('treeData', this.treeData)
          this.defaultExpandedKeys = []
          this.$nextTick(() => {
            if (
              !this.treeData ||
              this.treeData.length <= 0 ||
              !this.treeData[0].children ||
              this.treeData[0].children.length <= 0
            ) {
              return
            }
            if (!this.tierMap) {
              this.currentNode = this.$refs.tree.getNode(
                this.treeData[0].children[0].id
              ).data
              //将选中的层级树节点设置为选中
              this.$refs.tree.setCurrentNode(this.currentNode)
              Vue.set(this.treeData[0].children[0], 'iconB', true)
              this.defaultExpandedKeys = [this.currentNode.id]
              this.isFlag(this.treeData, this.currentNode.id)
              this.initStation(this.treeData[0].id, null, 1)
            } else {
              //层级
              if (this.tierMap.level === 4) {
                this.currentNode = this.$refs.tree.getNode(this.tierMap.id).data
                this.initStation(this.tierMap.stationId, null, this.tierMap.id)
              }
              //资源点类型
              if (this.tierMap.level === 5) {
                this.currentNode = this.$refs.tree.getNode(this.tierMap.id).data
                this.initStation(
                  this.tierMap.stationId,
                  this.tierMap.children,
                  this.tierMap.id
                )
              }
              //资源点
              if (this.tierMap.level === 6) {
                this.currentNode = this.$refs.tree.getNode(this.tierMap.id).data
葛齐林's avatar
葛齐林 committed
818

819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
                let res = this.$refs.tree.getNode(
                  this.tierMap.tierId + this.tierMap.type
                ).data
                this.initStation(
                  this.tierMap.stationId,
                  res.children,
                  this.tierMap.tierId + this.tierMap.type
                )
              }
              //将选中的层级树节点设置为选中
              this.$refs.tree.setCurrentNode(this.currentNode)
              Vue.set(this.tierMap, 'iconB', true)
              this.defaultExpandedKeys = [this.currentNode.id]
              this.isFlag(this.treeData, this.currentNode.id)
            }
          })
        }
      })
    },
    initStation(id, res, subId) {
      // console.log('初始化站点id:', id)
      this.$http({
        url: this.$http.adornUrl(`/liStation/getId/${id}`),
        method: 'get',
        params: this.$http.adornParams()
      })
        .then((data) => {
          if (data && data.code === 0) {
            if (data.bean) {
              this.station = data.bean
              this.mapList = data.bean.mapList
              this.mapList.forEach((element) => {
                element.readPath = this.urlPath + element.filePath
              })
              this.checkedData.stationId = this.station.id
              this.checkedData.stationName = this.station.stationName
            }
            if (res) {
              this.mapList.forEach((e) => {
                if (res.tierId === e.id) {
                  this.checkedData.tierId = e.id
                  this.checkedData.tierName = e.name
                  this.stationMap = e
葛齐林's avatar
葛齐林 committed
862
                }
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
              })
            } else {
              if (!this.checkedData.tierId) {
                this.checkedData.tierId = this.mapList[0].id
                this.checkedData.tierName = this.mapList[0].name
                this.stationMap = this.mapList[0]
              }
            }
            // console.log('站点地图:', this.mapList)
          }
        })
        .then(() => {
          if (subId === 1) {
            this.showResourceByMapId(null)
          } else {
            this.showResourceByParentId(subId)
          }
          if (!this.map) {
            this.initMap()
            this.imgLayerList[0].setVisible(true) //初始第一个显示
          } else {
            this.changeVectorLayer(this.list)
          }
        })
    },
葛齐林's avatar
葛齐林 committed
888

889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978
    isFlag(data, id) {
      data.forEach((res) => {
        if (res.id === id) {
          Vue.set(res, 'iconB', true)
        } else {
          Vue.set(res, 'iconB', false)
        }
        if (res.children) {
          this.isFlag(res.children, id)
        }
      })
    },
    // 改变层级和鹰眼图
    changeImgControl(id) {
      for (var k = 0; k < this.imgLayerList.length; k++) {
        if (this.imgLayerList[k].values_.id == id) {
          // that.imgurl=map.readPath
          this.imgLayerList[k].setVisible(true)
        } else {
          this.imgLayerList[k].setVisible(false)
        }
      }
    },
    handleNodeClick2(node) {
      //判断是否为编辑状态,如果为编辑状态提示是否保存编辑的图层在跳转
      // if (this.editable && (node.level === 5 || node.level === 4)) {
      //     this.$confirm(`请确认编辑图层是否保存?`, '提示', {
      //         confirmButtonText: '确认',
      //         cancelButtonText: '取消',
      //         type: 'warning',
      //         closeOnClickModal: false
      //     }).then(() => {
      //         this.handleNodeClick(node)
      //     }).catch(() => {
      //
      //     })
      // } else {
      //     this.handleNodeClick(node)
      // }
      this.handleNodeClick(node)
    },
    //线路资源点树节点点击事件
    handleNodeClick(node) {
      // console.log('node.id', node.id)
      //console.log('选中树节点', node)
      this.currentNode = node
      let level = node.level
      let name = node.name
      let id = node.id
      let code = node.code
      this.isFlag(this.treeData, id)
      // this.treeData.forEach(res => {
      //   if (res.id === id) {
      //     Vue.set(res, 'iconB', true)
      //   } else {
      //     Vue.set(res, 'iconB', false)
      //   }
      // })
      //每次选择节点都先清空资源位
      if (level !== 6) {
        // this.list = []
        this.listItem = '' //控制编辑按钮
      }
      if (level === 2) {
        //线路
        this.checkedData.lineId = id
        this.checkedData.lineName = name
      } else if (level === 3) {
        //站点
        this.checkedData.stationId = id
        this.checkedData.stationName = name
        // this.initTreeStationMap(node)
      } else if (level === 4) {
        this.tierMap = node
        //层级
        this.checkedData.tierId = id
        this.checkedData.tierName = name
        this.checkedData.stationId = node.stationId
        this.stationMap = node
        // console.log('选中节点的层级id', this.tierId)
        this.showResourceByMapId(null)
        this.changeVectorLayer(this.list)
        this.changeImgControl(id)
      } else if (level === 5) {
        this.tierMap = node
        //子系统
        this.checkedData.subCode = code
        this.checkedData.subSystem = name
        this.checkedData.stationId = node.stationId
        this.checkedData.tierId = node.tierId
葛齐林's avatar
葛齐林 committed
979

980 981 982 983 984 985
        this.mapList.forEach((element) => {
          if (element.id === node.tierId) {
            this.stationMap = element
            return false
          }
        })
葛齐林's avatar
葛齐林 committed
986

987 988
        this.list = JSON.parse(JSON.stringify(node.children))
        // console.log('资源点列表:', this.list)
葛齐林's avatar
葛齐林 committed
989

990 991 992 993 994 995 996
        this.list.forEach((res) => {
          Vue.set(res, 'active', false)
        })
        this.changeVectorLayer(this.list)
        this.changeImgControl(node.tierId)
      } else if (level === 6) {
        this.tierMap = node
xiexingan's avatar
xiexingan committed
997 998 999 1000 1001 1002
        // var sysId = ''
        // this.systemList.forEach((element) => {
        //   if (node.subCode === element.value) {
        //     sysId = element.id
        //   }
        // })
1003
        // 资源点
xiexingan's avatar
xiexingan committed
1004
        let subNode = this.$refs.tree.getNode(node.tierId + node.type).data
1005 1006 1007 1008 1009
        // console.log('当前要选中的层级节点', subNode)
        this.list = []
        subNode.children.forEach((res) => {
          this.list.push(res)
        })
葛齐林's avatar
葛齐林 committed
1010

1011 1012 1013 1014
        this.checkedData.resourceId = id
        this.checkedData.tierId = node.tierId
        this.changeImgControl(node.tierId)
        this.changeVectorLayer(this.list)
葛齐林's avatar
葛齐林 committed
1015

1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
        let feature = this.vectorLayer.getSource().getFeatureById(id)
        if (feature) {
          for (let i in this.list) {
            // if (feature.id_ == that.list[i].id) {
            //     this.listItem = JSON.parse(JSON.stringify(that.list[i]))
            // }
            //flag为ture打开详情或者编辑页面
            this.mapClick(feature, that.list[i], false)
          }
        }
      }
葛齐林's avatar
葛齐林 committed
1027

1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
      this.iconNameListBottom.forEach((res) => {
        if (this.clickItem && res.id === this.clickItem.id) {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 4
          ) {
            res.value = res.value.substring(0, res.value.length - 1) + '3'
          }
        }
      })
      //console.log(this.list)
      // this.clickItem = ''
    },
    //切换层级
    changeMap(map) {
      //图层缩放级别设置为默认
      this.map.getView().setZoom(1)
      for (var k = 0; k < this.imgLayerList.length; k++) {
        if (this.imgLayerList[k].values_.id == map.id) {
          // that.imgurl=map.readPath
          this.imgLayerList[k].setVisible(true)
        } else {
          this.imgLayerList[k].setVisible(false)
        }
      }
      this.currentNode = this.$refs.tree.getNode(map.id).data
      this.tierMap = this.currentNode
      // console.log('当前要选中的节点', this.currentNode)
      //将选中的层级树节点设置为选中
      this.$refs.tree.setCurrentNode(this.currentNode)
      this.defaultExpandedKeys = [this.currentNode.id]
      this.isFlag(this.treeData, this.currentNode.id)
葛齐林's avatar
葛齐林 committed
1059

1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
      // console.log('当前要选中的节点2', this.currentNode)
      this.checkedData.tierId = map.id
      this.checkedData.tierName = map.name
      let stationNode = this.$refs.tree.getNode(map.stationId).data
      // console.log('当前要选中的站点', stationNode)
      this.checkedData.stationId = stationNode.id
      this.checkedData.stationName = stationNode.name
      this.stationMap = map
      this.iconNameListBottom.forEach((res) => {
        if (res.id === this.clickItem.id) {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 4
          ) {
            res.value = res.value.substring(0, res.value.length - 1) + '3'
          }
        }
      })
      if (!this.checkedData.tierId) {
        return
      }
      this.showResourceByMapId(null)
      this.changeVectorLayer(this.list)
      this.changeImgControl(map.id)
    },
    //根据层级id展示当前层级所有的资源点
    showResourceByMapId(item) {
      if (!this.checkedData.tierId) {
        return
      }
      let tierNode = this.$refs.tree.getNode(this.checkedData.tierId).data
      // console.log('当前要选中的层级节点', tierNode.children)
      this.list = []
      tierNode.children.forEach((type) => {
        type.children.forEach((res) => {
          if (item === null || (item != null && item.id === res.type)) {
            this.list.push(res)
          }
        })
      })
葛齐林's avatar
葛齐林 committed
1099

1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
      this.list.forEach((res) => {
        Vue.set(res, 'active', false)
      })
      // console.log(this.list, '++++++')
    },
    //根据上级id展示所有的资源点
    showResourceByParentId(id) {
      let node = this.$refs.tree.getNode(id).data
      this.list = []
      if (node.level === 4) {
        node.children.forEach((type) => {
          type.children.forEach((res) => {
            this.list.push(res)
          })
        })
      } else {
        node.children.forEach((e) => {
          this.list.push(e)
        })
      }
    },
    refreshBean(bean) {
      this.listItem = JSON.parse(JSON.stringify(bean))
    },
    refreshdatalist(res) {
      let style = this.getPointStyle(res.imageSrc + '2.png', res.name, '0.3')
      let newItem = this.vectorLayer.getSource().getFeatureById(res.key)
      let newItemEnd = this.vectorLayer
        .getSource()
        .getFeatureById(res.key + 'end')
      if (newItem) newItem.setStyle(style)
      if (newItemEnd) newItemEnd.setStyle(style)
      for (let i in this.list) {
        if (this.list[i].key === res.key) {
          this.list[i] = res
        }
      }
    },
    //保存当前页面上的资源点位置
    saveResourceList() {
      if (this.list.length === 0) {
        this.$message.error('资源点为空不能保存!')
        return
      }
      //数组去重
      let paramList = Array.from(new Set(this.list))
葛齐林's avatar
葛齐林 committed
1146

1147 1148 1149 1150 1151 1152 1153 1154
      let flag = true
      //判断是否有无id的新增资源点
      this.list.forEach((res) => {
        if (res.addOrUpdate === 'save') {
          flag = false
          return false
        }
      })
co_dengxiongwen's avatar
co_dengxiongwen committed
1155
      console.log('paramList:', paramList)
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
      this.submitlDisabled = true
      if (flag) {
        this.$http({
          url: this.$http.adornUrl(`/liResource/updateList`),
          method: 'post',
          data: paramList
        }).then((data) => {
          // console.log(data)
          if (data.message) {
            this.addNotify(data.message)
            return
          }
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.initTree()
                this.changeEditable()
                this.checkedData.resourceId = ''
                this.delflag = true
                this.iconId = ''
                this.listItem = ''
                this.submitlDisabled = false
              }
            })
          } else {
            this.iconId = ''
            this.$message.error(data.msg)
            this.submitlDisabled = false
          }
        })
        this.submitlDisabled = false
      } else {
        this.$confirm(
          `未填写信息的新增资源点将被忽略,是否继续?`,
          '保存资源点',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            closeOnClickModal: false
          }
        )
          .then(() => {
            // console.log('当前页面资源点位置:', this.list)
            this.$http({
              url: this.$http.adornUrl(`/liResource/updateList`),
              method: 'post',
              data: paramList
            })
              .then((data) => {
                // console.log(data)
                if (data && data.code === 0) {
                  if (data.message) {
                    this.addNotify(data.message)
葛齐林's avatar
葛齐林 committed
1213
                    return
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
                  }
                  this.$message({
                    message: '操作成功',
                    type: 'success',
                    duration: 1500,
                    onClose: () => {
                      this.initTree()
                      this.changeEditable()
                      this.checkedData.resourceId = ''
                      this.delflag = true
                      this.submitlDisabled = false
葛齐林's avatar
葛齐林 committed
1225
                    }
1226
                  })
葛齐林's avatar
葛齐林 committed
1227
                } else {
1228 1229
                  this.$message.error(data.msg)
                  this.submitlDisabled = false
葛齐林's avatar
葛齐林 committed
1230
                }
1231 1232
              })
              .catch(() => {
co_dengxiongwen's avatar
co_dengxiongwen committed
1233
                this.submitlDisabled = false
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
              })
          })
          .catch(() => {
            this.submitlDisabled = false
          })
      }
    },
    //提示
    addNotify(message) {
      this.$message({
        type: 'error',
        message: '存在重复信息,保存失败!',
        duration: 1500,
        showClose: true
      })
      this.$notify({
        title: '以下信息存在重复,请核实:',
        message: message,
        duration: 0,
        dangerouslyUseHTMLString: true
      })
      this.submitlDisabled = false
    },
    // 详情
    queryDetail(item) {
      this.queryDetailVisible = true
      //this.handleNodeClick(item)
葛齐林's avatar
葛齐林 committed
1261

1262 1263 1264 1265 1266
      this.currentNode = this.$refs.tree.getNode(item.id).data
      //将选中的层级树节点设置为选中
      this.$refs.tree.setCurrentNode(this.currentNode)
      this.defaultExpandedKeys = [this.currentNode.id]
      this.isFlag(this.treeData, this.currentNode.id)
葛齐林's avatar
葛齐林 committed
1267

1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
      this.$nextTick(() => {
        this.$refs.queryDetail.init(item.id)
      })
    },
    // 新增 / 修改
    addOrUpdateHandle(item) {
      this.resource = null
      this.addOrUpdateVisible = true
      //   this.list.forEach(res => {
      //     if (res.id === id) {
      //       this.resource = res
      //       console.log(this.resource)
      //     }
      //   })
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(item)
      })
    },
    // 移动资源位坐标
    changeResourceLocation(id, x, y) {
      // console.log('changeResourceLocation:', id, x, y)
      this.list.forEach((res) => {
        if (res.id === id) {
          // console.log('移动坐标1:', res.name, res.xpoint, res.ypoint)
          res.xpoint = x
          res.ypoint = y
          // console.log('移动坐标2:', res.name, res.xpoint, res.ypoint)
        }
      })
    },
    handleCancel() {
      this.iconId = ''
      this.initTree()
      this.listItem = ''
      this.cancelDisabled = true
      this.editable = false
    },
    // 修改
    updateHandle() {
      let listItem = this.listItem
      if (listItem) {
        this.openAddOrUpdate(listItem)
      }
    },
    // 删除
    deleteHandle() {
      // console.log('dataListSelections:', this.dataListSelections)
      // var ids = this.checkedData.resourceId
      //   ? [this.checkedData.resourceId]
      //   : this.dataListSelections.map(item => {
      //     return item.id
      //   })
      // this.listItem.id
      // var ids = [this.checkedData.resourceId]
      let ids = []
      if (this.listItem.id) {
        ids.push(this.listItem.id)
      } else {
        ids.push(this.listItem.key)
      }
      for (let i in ids) {
        //删除绘制的图标和线
        // this.delPoint(ids[i])
        for (let j in this.list) {
          if (this.list[j].id === ids[i]) {
            this.$http({
              url: this.$http.adornUrl('/liResource/validateDeleteResource'),
              method: 'get',
              params: this.$http.adornParams({
                stationId: localStorage.getItem('stationId'),
                id: ids[i]
              })
            }).then((data) => {
              if (data && data.code === 0) {
                //删除绘制的图标和线
                this.delPoint(ids[i])
                this.list[j].deleted = 1
葛齐林's avatar
葛齐林 committed
1345 1346
                this.listItem = ''
                this.cancelDisabled = false
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398
              }
            })
          }
          if (!this.list[j].id) {
            if (this.list[j].key === ids[i]) {
              //删除绘制的图标和线
              this.delPoint(ids[i])
              this.list.splice(j, 1)
            }
          }
        }
      }
    },
    //删除绘制的图标和线
    delPoint(id) {
      let feature = this.vectorLayer.getSource().getFeatureById(id)
      //删除id对应的资源点
      this.vectorLayer.getSource().removeFeature(feature)
      let featureEnd = this.vectorLayer.getSource().getFeatureById(id + 'end')
      if (featureEnd) {
        //删除红外探测器或者振动光纤id对应的资源点
        this.vectorLayer.getSource().removeFeature(featureEnd)
        let lineFeature = this.lineVectorLayer
          .getSource()
          .getFeatureById(id + 'line')
        if (lineFeature) {
          //删除id对应的连线
          this.lineVectorLayer.getSource().removeFeature(lineFeature)
        }
      }
    },
    changeEditable() {
      this.$nextTick(() => {
        this.clickMap(true)
      })
      this.isDone = !this.isDone
      this.editable = !this.editable //保存按钮切换显示
      this.cancelDisabled = false
      this.$forceUpdate()
      //设置是否启动拖动
      if (!this.editable) {
        this.map.removeInteraction(this.modify)
      } else {
        //添加拖拽监听事件
        this.map.addInteraction(this.modify)
      }
    },
    statusClick(item) {
      //icon状态切换
      if (!this.editable) {
        return
      }
葛齐林's avatar
葛齐林 committed
1399

1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412
      item.value = item.value + '2'
      this.typeList.forEach((res) => {
        if (item.id !== res.id) {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 2
          ) {
            res.value = res.value.substring(0, res.value.length - 1)
          }
        }
      })
    },
    clickMap() {
      let that = this
co_dengxiongwen's avatar
co_dengxiongwen committed
1413
      this.map.on('click', function (e) {
1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432
        that.jing = parseFloat(e.coordinate[0]).toFixed(2)
        that.wei = parseFloat(e.coordinate[1]).toFixed(2)
      })
    },
    regionMousedown(e) {
      if (!this.editable) {
        return
      }
      if (e.srcElement.id === '') {
        return
      }
      // if (e.path) {
      //     if (
      //       e.path[0].attributes.name &&
      //       e.path[0].attributes.name.nodeValue != 'iconListNow'
      //     ) {
      //       return
      //     }
      // } else {
葛齐林's avatar
葛齐林 committed
1433

1434
      // }
葛齐林's avatar
葛齐林 committed
1435

1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
      this.typeList.forEach((res) => {
        // if ((e.path && e.path[0].id !== res.id) || e.srcElement.id !== res.id) {
        if (e.srcElement.id !== res.id) {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 2
          ) {
            res.value = res.value.substring(0, res.value.length - 1)
          }
        } else {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 2
          ) {
            return
          }
          res.value = res.value + '2'
          this.spanDragData.name = res.value
          this.spanDragListNow = res
          this.mousemoveStatus = true
        }
      })
    },
    regionMousemove(e) {
      if (this.mousemoveStatus) {
        this.spanDragData.x = e.clientX - 24
        this.spanDragData.y = e.clientY - 106
        this.spanDragData.show = true
      }
    },
    regionMouseup(e) {
      this.mousemoveStatus = false
      this.typeList.forEach((res) => {
        if (res.value.substring(res.value.length - 1, res.value.length) == 2) {
          res.value = res.value.substring(0, res.value.length - 1)
        }
      })
      this.spanDragData.x = 0
      this.spanDragData.y = 0
      this.spanDragData.show = false
      this.spanDragData.name = ''
    },
    iconClick(item) {
      console.log(this.currentNode)
      this.iconNameListBottom.forEach((res) => {
        if (res.id === item.id) {
          if (
            res.value.substring(res.value.length - 1, res.value.length) != 4
          ) {
            res.value = res.value.substring(0, res.value.length - 1) + '4'
          }
        } else {
          if (
            res.value.substring(res.value.length - 1, res.value.length) == 4
          ) {
            res.value = res.value.substring(0, res.value.length - 1) + '3'
          }
葛齐林's avatar
葛齐林 committed
1491
        }
1492 1493 1494 1495 1496 1497 1498 1499
      })
      if (this.currentNode.level == 5) {
        this.list = []
        this.currentNode.children.forEach((el) => {
          if (item.id === el.type) {
            this.list.push(el)
          }
        })
葛齐林's avatar
葛齐林 committed
1500

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519
        this.list.forEach((res) => {
          Vue.set(res, 'active', false)
        })
      } else {
        this.showResourceByMapId(item)
      }
      this.clickItem = item
      this.changeVectorLayer(this.list)
    },
    initResourceTypeDicList() {
      this.$http({
        url: this.$http.adornUrl('/sysDictionary/getResourceTypeDicList'),
        method: 'get',
        params: this.$http.adornParams({
          stationId: localStorage.getItem('stationId')
        })
      }).then((data) => {
        if (data && data.code === 0) {
          this.typeList = JSON.parse(JSON.stringify(data.list))
xiexingan's avatar
xiexingan committed
1520
          console.log('类型:', this.typeList)
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530
          this.iconNameListBottom = JSON.parse(JSON.stringify(data.list))
          this.iconNameListBottom.forEach((res) => {
            res.value += '3'
          })
        }
      })
    },
    iconMousedown(e) {
      e.width = Number(e.width) + 10
      //console.log(e.width)
葛齐林's avatar
葛齐林 committed
1531
    }
1532 1533
  }
}
葛齐林's avatar
葛齐林 committed
1534
</script>
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
<style lang="scss" scoped>
.dic_tree {
  background: #f4f4f4;
  font-size: 14px;
  transform: translateX(-6px);
  margin-top: 20px;
}
.dic_tree /deep/ .el-tree-node__content {
  padding-left: 0px !important;
}
葛齐林's avatar
葛齐林 committed
1545

1546 1547 1548 1549
.dic_tree /deep/ .el-tree-node {
  position: relative;
  padding-left: 16px;
}
葛齐林's avatar
葛齐林 committed
1550

1551 1552 1553
.dic_tree /deep/ .el-tree-node__children {
  padding-left: 10px;
}
葛齐林's avatar
葛齐林 committed
1554

1555 1556 1557
.dic_tree /deep/ .el-tree-node :last-child:before {
  height: 38px;
}
葛齐林's avatar
葛齐林 committed
1558

1559 1560 1561
.dic_tree /deep/ .el-tree > .el-tree-node:before {
  border-left: none;
}
葛齐林's avatar
葛齐林 committed
1562

1563 1564 1565
.tree-container /deep/ .el-tree > .el-tree-node:after {
  border-top: none;
}
葛齐林's avatar
葛齐林 committed
1566

1567 1568 1569 1570 1571 1572 1573
.dic_tree /deep/ .el-tree-node:before {
  content: '';
  left: -4px;
  position: absolute;
  right: auto;
  border-width: 1px;
}
葛齐林's avatar
葛齐林 committed
1574

1575 1576 1577 1578 1579 1580 1581
.dic_tree /deep/ .el-tree-node:after {
  content: '';
  left: -4px;
  position: absolute;
  right: auto;
  border-width: 1px;
}
葛齐林's avatar
葛齐林 committed
1582

1583 1584 1585 1586 1587 1588 1589
.dic_tree /deep/ .el-tree-node:before {
  border-left: 1px dashed #bfbfbf;
  bottom: 0px;
  height: 100%;
  top: -26px;
  width: 1px;
}
葛齐林's avatar
葛齐林 committed
1590

1591 1592 1593 1594 1595 1596 1597 1598 1599
.dic_tree /deep/ .el-tree-node:after {
  border-top: 1px dashed #bfbfbf;
  height: 20px;
  top: 12px;
  width: 35px;
}
.tree-container /deep/ .el-tree > .el-tree-node:after {
  border-top: none;
}
葛齐林's avatar
葛齐林 committed
1600

1601 1602 1603 1604 1605 1606 1607 1608 1609
.tree-container {
  /* 树的parent,样式自定 */
}
.dic_tree /deep/ .el-tree-node__expand-icon.expanded {
  transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
}
.dic_tree /deep/ .el-icon-caret-right:before {
  background: url('../../../assets/images/add.png');
葛齐林's avatar
葛齐林 committed
1610

1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  font-size: 18px;
  background-size: 18px;
}
.dic_tree
  /deep/
  .el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
  background: url('../../../assets/images/sub.png');
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  font-size: 18px;
  background-size: 18px;
}
.dic_tree /deep/.el-tree-node__content > .el-tree-node__expand-icon {
  padding: 1px;
}
.dic_tree /deep/.el-tree-node__expand-icon.is-leaf::before {
  opacity: 0;
}
.dic_tree /deep/.is-leaf.el-tree-node__expand-icon.el-icon-caret-right {
  // margin-left: -15px !important;
}
葛齐林's avatar
葛齐林 committed
1638
</style>
1639 1640 1641 1642 1643 1644
<style lang="scss">
.line_warp {
  // width: 300px;
  height: 45px;
  display: flex;
  align-items: center;
葛齐林's avatar
葛齐林 committed
1645

1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
  .point_left {
    width: 50px;
    height: 50px;
    transform: translateX(14px);
  }
  .point_right {
    width: 50px;
    height: 50px;
    transform: translateX(-14px);
  }
}
.el-tree--highlight-current
  .el-tree-node.is-current
  > .el-tree-node__content
  .custom-tree-node {
  background-color: #33b0f6 !important;
  color: aliceblue;
}
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  background-color: transparent;
}
葛齐林's avatar
葛齐林 committed
1667 1668
</style>

1669 1670 1671 1672 1673 1674 1675 1676 1677
<style lang="scss" scoped>
#map {
  /deep/.ol-zoom {
    // display: none;
  }
  /deep/ .ol-zoom .ol-unselectable .ol-control {
    display: none;
  }
}
葛齐林's avatar
葛齐林 committed
1678

1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
.treeCard {
  .el-tree {
    overflow-y: scroll;
    height: 640px;
  }
}

.tree_house {
  width: 12px;
  height: 18px;
  display: inline-block;
  img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    // transform: translateY(-8px);
    transform: translateX(-40px);
  }
}
.tree_point {
  width: 12px;
  height: 18px;
  display: inline-block;
  img {
    width: 15px;
    height: 15px;
    vertical-align: middle;
    transform: translateY(-2px);
  }
}
.resource-container {
  width: 100%;
  height: 100%;
  position: relative;
  border: 0px solid black;
  overflow: auto;
  .span-box {
    height: 30px;
    // width: 30px;
    font-size: 12px;
    border-radius: 5px;
    /* border: 1px solid red; */
    position: absolute;
    // left: 0;
    // top: 0;
    .span-img {
      width: 100%;
      height: 100%;
      border-radius: 5px;
      background-size: 182%;
葛齐林's avatar
葛齐林 committed
1729
    }
1730 1731 1732 1733 1734 1735 1736
  }
  .active {
    background-color: #fd949d;
    height: 40px;
    width: 40px;
  }
}
葛齐林's avatar
葛齐林 committed
1737

1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765
.tier-btn {
  .active-tier {
    background-color: #409eff;
    color: #ffffff;
  }
}
.monitor_point_left_top {
  height: 42px;
  background: #e1edf4;
  padding-left: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .monitor_point_left_topL {
    height: 40px;
    padding-top: 10px;
    float: left;
    div {
      height: 40px;
      float: left;
      padding: 0 10px 0 10px;
      line-height: 40px;
      cursor: pointer;
      font-family: Microsoft YaHei;
      font-size: 14px;
      span {
        color: #35aff8;
      }
葛齐林's avatar
葛齐林 committed
1766
    }
1767 1768 1769 1770 1771 1772
    div.on {
      background: #fff;
      border: 1px solid #c3c3c3;
      border-bottom: none;
      font-family: Microsoft YaHei;
      font-weight: 400;
葛齐林's avatar
葛齐林 committed
1773
    }
1774 1775 1776 1777 1778 1779 1780
  }
  .monitor_point_left_topR {
    // float: right;
    margin-right: 20px;
    // margin-top: 10px;
    .el-input {
      width: 109px;
葛齐林's avatar
葛齐林 committed
1781
    }
1782 1783 1784 1785
    /deep/ .el-input--mini .el-icon-search {
      line-height: 28px;
      color: #35aff8;
      font-weight: bold;
葛齐林's avatar
葛齐林 committed
1786
    }
1787 1788
  }
}
葛齐林's avatar
葛齐林 committed
1789

1790 1791 1792
.top_button {
  background: url(~@/assets/images/sysiconbg.png);
}
葛齐林's avatar
葛齐林 committed
1793
</style>