Browse Source

- 检测系统修改

yj 3 years ago
parent
commit
f2ca812314

+ 1 - 1
public/config.js

@@ -25,7 +25,7 @@ export const appconfig = {
   // 地图初始视角中心
   // 临时使用
   // 当前地图坐标系, 用于转换
-  'currPRJ': 'proj44',
+  'currPRJ': 'proj47',
   
   'initLayers': 'pipemap&&smlayergroup', // 用于配置图层树 pipemap&&group
   // 地图初始视角级别

+ 20 - 3
src/views/pipelineDefect/common/cesiumUtil.ts

@@ -44,6 +44,21 @@ export default class CesiumUtil {
         })
     }
 
+    getCenterFormFeas (coors) {
+        if (coors.length === 0) return
+        let xmin, xmax, ymin, ymax
+        coors.forEach(line => {
+            let [startPoint, endPoint] = line
+            let [sx, sy] = startPoint
+            let [ex, ey] = endPoint
+            xmin = xmin ? Math.min.call(null, sx, ex, xmin) : Math.min.call(null, sx, ex)
+            xmax = xmax ? Math.max.call(null, sx, ex, xmax) : Math.max.call(null, sx, ex)
+            ymin = ymin ? Math.min.call(null, sy, ey, ymin) : Math.min.call(null, sy, ey)
+            ymax = ymax ? Math.max.call(null, sy, ey, ymax) : Math.max.call(null, sy, ey)
+        })
+        return [(xmin + xmax) / 2, (ymin + ymax) / 2]
+    }
+
     // 移动到地点
     flyTo(target) {
         this.viewer.flyTo(target, {
@@ -56,14 +71,16 @@ export default class CesiumUtil {
         })
     }
     // 设置视角
-    setView(car3, orientation = { heading: 0, pitch: -90, roll: 0 }) {
-        this.viewer.camera.setView({
+    setView(car3, callback?, orientation = { heading: 0, pitch: -90, roll: 0 }) {
+        this.viewer.camera.flyTo({
             destination: car3,
             orientation: {
                 heading: Cesium.Math.toRadians(orientation.heading),
                 pitch: Cesium.Math.toRadians(orientation.pitch),
                 roll: Cesium.Math.toRadians(orientation.roll)
-            }
+            },
+            duration: 1,
+            complete: callback
         })
     }
     // 起点

+ 4 - 4
src/views/pipelineDefect/common/graphic.ts

@@ -79,18 +79,18 @@ export default class GraphicUtil {
             position,
             billboard: { //图标
                 image: img || testImg,
-                width: 6,
-                height: 6,
+                width: 16,
+                height: 16,
                 heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                 rotation: 0,
-                sizeInMeters: true
+                // sizeInMeters: true
             },
         })
     }
     // 图元 贴地线
     createPLine(positions, color = Cesium.Color.RED, width, data) {
         return new Cesium.GroundPolylinePrimitive({
-            // releaseGeometryInstances: false,
+            releaseGeometryInstances: false,
             geometryInstances: new Cesium.GeometryInstance({
                 geometry: new Cesium.GroundPolylineGeometry({ positions, width: width || 5 }),
                 id: data || 'id',

+ 5 - 1
src/views/pipelineDefect/common/proj.ts

@@ -6,6 +6,8 @@ export class projUtil {
     // 坐标系定义
     // TODO 自定义坐标系
     defs = {
+        'EPSG:4547': 'PROJCS["CGCS2000_3_Degree_GK_CM_105E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",114.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4547]]',
+        'EPSG:4546': 'PROJCS["CGCS2000_3_Degree_GK_CM_105E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",111.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4546]]',
         'EPSG:4544': 'PROJCS["CGCS2000_3_Degree_GK_CM_105E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4544]]',
         'EPSG:4543': 'PROJCS["CGCS2000_3_Degree_GK_CM_102E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",102.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4543]]',
         'EPSG:4495': 'PROJCS["CGCS2000_3_Degree_GK_CM_102E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",99.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",4495]]'
@@ -17,7 +19,9 @@ export class projUtil {
         proj57: "EPSG:3857", // ol
         proj43: "EPSG:4543", // pzh
         proj95: "EPSG:4495",
-        proj44: "EPSG:4544" // rs
+        proj44: "EPSG:4544", // rs
+        proj46: 'EPSG:4546', // 宜昌
+        proj47: "EPSG:4547" // 岳阳
     }
 
     constructor () {

+ 1 - 1
src/views/pipelineDefect/components/popupWindow.vue

@@ -108,7 +108,7 @@ export default {
             baseFilePath: '/psjc/file',
 
             offset: { x: 0, y: 0 },
-            pOffset: { x: 227, y: 343 },
+            pOffset: { x: 237, y: 343 },
             eOffset: { x: 232, y: 354 },
 
             showPipeInfo: false,

+ 22 - 12
src/views/pipelineDefect/components/simpleMap.vue

@@ -75,7 +75,7 @@ export default {
         },
         // 初始化地图
         initMap () {
-            var viewer = CesiumUtil.getInitViewer(this.$el)
+            var viewer = CesiumUtil.getInitViewer(this.$el.getElementsByClassName('mainmap')[0])
             this.cesiumUitl = new CesiumUtil(viewer)
             this.graphicUtil = new GraphicUtil()
             this.projUtil = new projUtil()
@@ -86,12 +86,13 @@ export default {
             this.initCesiumStatus() // 初始化 cesium 状态
             this.initBaseMap() // 加载图层,包括专题图,影像图
             this.initTianditu() // 加载矢量图,poi
-            // 设置位置
-            let center = CesiumUtil.degrees2Car3(...this.center)
-            this.cesiumUitl.setView(center)
             
-            this.primitiveCollection = new Cesium.PrimitiveCollection()
-            this.viewer.scene.primitives.add(this.primitiveCollection)
+            let dataSources = this.viewer.dataSources
+            this.pDataSource = new Cesium.CustomDataSource('line')
+            dataSources.add(this.pDataSource)
+            this.dDataSource = new Cesium.CustomDataSource('defect')
+            dataSources.add(this.dDataSource)
+
             this.$emit('afterLoad')
         },
         // 
@@ -250,11 +251,11 @@ export default {
                     let findStrucColor = colors.find(colorObj => defect['structClass'] && defect['structClass'].includes(colorObj.level))
                     // 结构性
                     let scolor = findStrucColor ? findStrucColor.color : defaultColor
-                    let sFea = this.getPrimity('line', lineCar3, { color: scolor }, { ...defect, lineCar3 })
+                    let sFea = this.getEntity('line', lineCar3, { color: scolor }, { ...defect, lineCar3 })
                     features.strucDefectFeatures.push(sFea)
                     // 功能性
                     let fcolor = findFuncColor ? findFuncColor.color : defaultColor
-                    let fFea = this.getPrimity('line', lineCar3, { color: fcolor }, { ...defect, lineCar3 })
+                    let fFea = this.getEntity('line', lineCar3, { color: fcolor }, { ...defect, lineCar3 })
                     features.funcDefectFeatures.push(fFea)
                     // 缺陷
                     if (defect.geometry) {
@@ -281,8 +282,17 @@ export default {
             return features
         },
         removeCesiumGraphics () {
-            this.primitiveCollection.removeAll()
-            this.viewer.entities.removeAll()
+          if (this.pDataSource) {
+            let entities = this.pDataSource.entities
+            let arr = entities.values
+            arr.forEach(e => entities.remove(e))
+          }
+          if (this.dDataSource) {
+            let entities = this.dDataSource.entities
+            let arr = entities.values
+            arr.forEach(e => entities.remove(e))
+            
+          }
         },
         //  加载管线
         addLines (lines) {
@@ -290,7 +300,7 @@ export default {
                 lines = [lines]
             }
             lines.forEach(line => {
-                this.primitiveCollection.add(line)
+                this.pDataSource.entities.add(line)
             })
         },
         // 加载缺陷
@@ -299,7 +309,7 @@ export default {
                 defects = [defects]
             }
             defects.forEach(defect => {
-                this.viewer.entities.add(defect)
+                this.dDataSource.entities.add(defect)
             })
         },
         // 获取图元

+ 2 - 2
src/views/pipelineDefect/manage/defect/widget.vue

@@ -538,8 +538,8 @@ export default {
       }
     },
     // 打开缩略提示框
-    openPromptBox(row, column, cell, event) {
-
+    openPromptBox(row) {
+      this.setViewFromFeas(row.id, 0)
     },
     // 详情导航选择事件
     handleSelect(key, keyPath) {

+ 6 - 20
src/views/pipelineDefect/manage/engineer/components/detail.vue

@@ -105,8 +105,7 @@
         >
           <el-button size="small" type="primary" slot="trigger">选择文件</el-button>
         </el-upload>
-        <p
-          v-show="isEdit"
+        <p v-show="isEdit"
           style="
                 height: 20px;
                 font-size: 12px;
@@ -117,21 +116,9 @@
                 line-height: 20px;
               "
         >已上传的文件列表</p>
-        <div
-          v-show="isDetails || isEdit"
-          class="hideScrollBar"
-          style="max-height: 120px; overflow-y: scroll; border: 1px solid #dedede; padding-left: 10px; margin-top:10px"
-        >
-          <div
-            v-for="(item, i) in fileListData"
-            :key="i"
-            class="text-space"
-            style="height: 20px; line-height: 20px; margin:5px"
-          >
-            <el-link
-              :href="fileLinkToStreamDownload(item.id)"
-              type="primary"
-            >{{ item.originalName }}</el-link>
+        <div v-show="isDetails || isEdit" class="hideScrollBar" style="max-height: 120px; overflow-y: scroll; border: 1px solid #dedede; padding-left: 10px; margin-top:10px" >
+          <div v-for="(item, i) in fileListData" :key="i" class="text-space" style="height: 20px; line-height: 20px; margin:5px" >
+            <el-link :href="fileLinkToStreamDownload(item.id)" type="primary" >{{ item.originalName }}</el-link>
             <el-link v-show="isEdit" type="danger" @click="removeFile(item)">删除</el-link>
           </div>
         </div>
@@ -157,7 +144,6 @@
 
 <script lang="ts">
 import { Vue, Component, Prop } from 'vue-property-decorator'
-// import { baseAddress } from '@/utils/request.ts'
 import { baseAddress } from '@/utils/request'
 
 import {
@@ -178,8 +164,7 @@ export default class Detail extends Vue {
     return rest
   }
   get uploadHeaders() {
-    // return { Authorization: 'bearer ' + sessionStorage.getItem('token') }
-    return { Authorization: 'bearer 5600924c-b2d1-4a2c-a488-0160179add17' }
+    return { Authorization: 'bearer ' + sessionStorage.getItem('token') }
   }
 
   get baseAddress() {
@@ -414,6 +399,7 @@ export default class Detail extends Vue {
 
   // 修改数据
   editData(row) {
+    console.log('修改数据')
     this.showFooter = true
     this.isDetails = false
     this.isEdit = true

+ 1 - 205
src/views/pipelineDefect/manage/evaluate/widget.vue

@@ -594,24 +594,6 @@ export default {
       }
       console.log('url', !url)
     },
-
-    addEvent () {
-      this.clickEvent = this.map.on('click', (evt) => {
-        let feas = this.map.getFeaturesAtPixel(evt.pixel)
-        if (feas.length !== 0) {
-          let filterFea = feas.filter(fea => fea.get('expNo') && fea.getGeometry() instanceof LineString)
-          if (filterFea.length === 0) return
-          this.openPromptBox(filterFea[0].values_)
-        } else {
-          this.currentInfoCard = false
-          this.popup && this.popup.setPosition(null)
-          this.lightLayer.getSource().clear()
-        }
-      })
-    },
-    removeEvent() {
-      this.clickEvent && unByKey(this.clickEvent)
-    },
     clearAll() {
       this.vectorLayer && this.map.removeLayer(this.vectorLayer)
       this.lightLayer && this.map.removeLayer(this.lightLayer)
@@ -621,166 +603,6 @@ export default {
       this.drawer && this.drawer.end()
       this.lightLayer = this.clickEvent = this.vectorLayer = null
     },
-    /**
-     * 添加、更新地图管道缺陷
-     * */
-    setMainMap () {
-      let map = this.data.mapView
-      if (this.vectorLayer && this.lightLayer) {
-          this.$store.dispatch('map/mapLaoding', true)
-          getDefectData().then(res => {
-            this.hasLoad = true
-            this.$store.dispatch('map/mapLaoding', false)
-            if (res.code === 1 && res.result) {
-                let { strucDefectFeatures, funcDefectFeatures, pipeDefectFeatures } = this.getReportFeatures(res.result, true)
-                this.lightLayer.getSource().clear()
-                if ([...strucDefectFeatures, ...funcDefectFeatures, ...pipeDefectFeatures].length !== 0) {
-                  let center = mapUtil.getCenterFromFeatures([...strucDefectFeatures, ...funcDefectFeatures])
-                  this.themLayer = new VectorLayer({ source: new VectorSource() })
-                  this.themLayer.setVisible(false)
-                  this.themLayer.set('layername', this.themLayerName)
-                  this.map.addLayer(this.themLayer)
-                  this.themLayer.getSource().addFeatures([...strucDefectFeatures, ...funcDefectFeatures, ...pipeDefectFeatures])
-                  map.getView().setZoom(15)
-                  map.getView().setCenter(center)
-                  // 
-                  this.setThemLayer()
-                } else {
-                  this.vectorLayer.getSource().clear()
-                }
-            } else this.$message.error('管线缺陷数据请求失败')
-          })
-      }
-    },
-    /**
-     * 构造管道缺陷地图要素
-     * @param reportInfos 报告数据
-     * */
-    getReportFeatures (defectInfos, hasStyle) {
-      let style = null, features = { pipeDefectFeatures: [], funcDefectFeatures: [], strucDefectFeatures: [] }
-      if (defectInfos.length === 0) { return features }
-      defectInfos.forEach(defect => {
-        let { startPointXLocation, startPointYLocation, endPointXLocation, endPointYLocation } = defect
-        if (startPointXLocation && startPointYLocation && endPointXLocation && endPointYLocation) {
-          let startPoint = [Number(startPointXLocation), Number(startPointYLocation)]
-          let endPoint = [Number(endPointXLocation), Number(endPointYLocation)]
-          startPoint = this.projUtil.transform(startPoint, this.currentDataProjName, 'proj84')
-          endPoint = this.projUtil.transform(endPoint, this.currentDataProjName, 'proj84')
-          let lineCoors = [startPoint, endPoint]
-          let feature = new Feature({ geometry: new LineString(lineCoors) })
-          // 健康等级颜色
-            let colors = [
-              { level: 'Ⅰ', color: 'green' },
-              { level: 'Ⅱ', color: 'blue' },
-              { level: 'Ⅲ', color: 'pink' },
-              { level: 'Ⅳ', color: 'red' }
-            ]
-            let findFuncColor = colors.find(colorObj => defect['funcClass'] && defect['funcClass'].includes(colorObj.level))
-            let findStrucColor = colors.find(colorObj => defect['structClass'] && defect['structClass'].includes(colorObj.level))
-              // 功能性缺陷
-            if (!isExit(defect.expNo, 'funcDefectFeatures')) {
-              let fFea = feature.clone()
-              let fColor = findFuncColor ? findFuncColor.color : "#070358"
-              hasStyle && fFea.setStyle(comSymbol.getLineStyle(5, fColor))
-              for (let i in defect) {
-                i !== 'geometry' && fFea.set(i, defect[i])
-              }
-              features.funcDefectFeatures.push(fFea)
-            }
-              // 结构性缺陷
-            if (!isExit(defect.expNo, 'strucDefectFeatures')) {
-              let sFea = feature.clone()
-              let sColor = findStrucColor ? findStrucColor.color : "#070358"
-              hasStyle && sFea.setStyle(comSymbol.getLineStyle(5, sColor))
-              for (let i in defect) {
-                i !== 'geometry' && sFea.set(i, defect[i])
-              }
-              features.strucDefectFeatures.push(sFea)
-            }
-            // 缺陷点
-            if (defect.geometry) {
-              let coors = JSON.parse(defect.geometry)
-              let point = this.projUtil.transform([coors.x, coors.y], this.currentDataProjName, 'proj84')
-              let feature = new Feature({ geometry: new Point(point) })
-              let imgs = [
-                { level: ['一级', '1'], img: defectImg1, index: 0 },
-                { level: ['二级', '2'], img: defectImg2, index: 1 },
-                { level: ['三级', '3'], img: defectImg3, index: 2 },
-                { level: ['四级', '4'], img: defectImg4, index: 3 },
-                // { level: '/', img: defectImg0, index: 4 }
-              ]
-              let findimg = null
-              if (defect.defectLevel) {
-                findimg = imgs.find((colorObj) => colorObj.level.includes(defect['defectLevel']))
-              }
-              // 缺少 defectLevel 字段
-              if (findimg) {
-                let rotation = getIconRat(lineCoors)
-                hasStyle && feature.setStyle( new Style({ image: new Icon({ size: [48, 48], anchor: [0.5, 0], src: findimg.img, scale: 0.4, rotation }) }) )
-                for (let i in defect) {
-                  i !== 'geometry' && feature.set(i, defect[i])
-                }
-                features.pipeDefectFeatures.push(feature)
-              }
-            }
-
-        }
-      })
-      return features
-      function isExit(pipeId, feasType) {
-        return features[feasType].some(fea => fea.get('expNo') === pipeId)
-      }
-      function getIconRat([startPoint, endPoint]) {
-        let rotation = 0
-        // 因为要垂直管线显示,所以图片旋转 90°
-        let imgRt = Math.PI / 2
-
-        // 计算旋转弧度
-        if (endPoint[0] === startPoint[0]) {
-          // 竖直
-          rotation = endPoint[1] > startPoint[1] ? -imgRt : Math.PI - imgRt
-        } else if (endPoint[1] === startPoint[1]) {
-          // 水平
-          rotation = endPoint[1] > startPoint[1] ? Math.PI / 2 - imgRt : (Math.PI * 3) / 2 - imgRt
-        } else {
-          // 其他角度
-          rotation = Math.atan((endPoint[0] - startPoint[0]) / (endPoint[1] - startPoint[1])) - imgRt
-        }
-        return rotation
-      }
-    },
-    // 上一张照片
-    lastImg() {
-      if (this.imgArrIndex <= 0) {
-        this.imgArrIndex = 0
-        return
-      }
-      this.imgArrIndex--
-    },
-    // 下一张照片
-    nextImg() {
-      if (this.imgArrIndex + 1 >= this.getCurrentForm.pipeDefects.length) {
-        this.imgArrIndex = this.getCurrentForm.pipeDefects.length - 1
-        return
-      }
-      this.imgArrIndex++
-    },
-    // 上一页
-    lastPage() {
-      if (this.currentIndex <= 0) {
-        this.currentIndex = 0
-        return
-      }
-      this.currentIndex--
-    },
-    // 下一页
-    nextPage() {
-      if (this.currentIndex + 1 >= this.currentForm.length) {
-        this.currentIndex = this.currentForm.length - 1
-        return
-      }
-      this.currentIndex++
-    },
     setPositionByPipeId(id) {
       let features = this.vectorLayer.getSource().getFeatures()
       let filterFea = features.find((fea) => fea.get('expNo') === id && fea.getGeometry() instanceof LineString)
@@ -826,33 +648,7 @@ export default {
     },
     // 打开缩略提示框
     openPromptBox(row) {
-      console.log('打开弹框')
-      this.handleRowClick(row)
-      if(!(this.vectorLayer && this.lightLayer)) return
-      if (!this.hasLoad) return this.$message.warning('地图数据未加载完')
-      histroyPipeData({ expNo: row.expNo, wordInfoState: 1 }).then(res => {
-        if (res.code === 1) {
-          // 定位
-          let position = this.setPositionByPipeId(row.expNo)
-          if (position) {
-            this.activeName = 'picnum'
-            this.currentForm = res.result
-            this.currentIndex = 0
-            this.popup = new Overlay({
-              element: document.getElementById('popupCardEva'),
-              //当前窗口可见
-              autoPan: true,
-              positioning: 'bottom-center',
-              stopEvent: true,
-              offset: [18, -25],
-              autoPanAnimation: { duration: 250 }
-            })
-            this.map.addOverlay(this.popup)
-            this.popup.setPosition(position)
-            this.currentInfoCard = true
-          } else this.$message.warning('该管段无位置信息')
-        } else this.$message.error('查询详细数据出错!')
-      })
+      this.setViewFromFeas(row.expNo, 1)
     },
 
     // 详情

+ 11 - 11
src/views/pipelineDefect/manage/report/widget.vue

@@ -464,7 +464,7 @@
     <!-- 撤回提示框 -->
     <div class="delete-box">
       <!-- 撤回提示框 -->
-      <el-dialog title="提示" :visible.sync="withdrawDialogVisible" width="30%">
+      <el-dialog title="提示" :visible.sync="withdrawDialogVisible" width="30%" :modal='false'>
         <div style="display: flex; align-items: center">
           <!-- <i class="el-icon-info" style="color: #e6a23c"></i> -->
           <span class="iconfont icondtbz" style="font-size: 22px; color: #e6a23c"></span>
@@ -523,6 +523,7 @@ import simpleMap from '@/views/pipelineDefect/components/simpleMap.vue'
 import * as echarts from 'echarts'
 import { appconfig } from 'staticPub/config'
 import { mapMixin } from '@/views/pipelineDefect/mixin/map'
+import CesiumUtil from '../../common/cesiumUtil'
 
 export default {
   props: ['data'],
@@ -938,14 +939,8 @@ export default {
       }
     },
     lightFea(row) {
-      let feas = this.vectorLayer.getSource().getFeatures()
-      feas = feas.filter(fea => fea.get('wordId') === row.id)
-      if (feas.length !== 0) {
-        let cloneFeas = feas.map(fea => new Feature({ geometry: fea.getGeometry().clone() })).filter(fea => fea.getGeometry() instanceof LineString)
-        this.lightLayer.getSource().addFeatures(cloneFeas)
-        let center = mapUtil.getCenterFromFeatures(cloneFeas)
-        new mapUtil(this.map).setZoomAndCenter(17, center)
-      }
+      console.log('高亮')
+      this.setViewFromFeas(row.id, 2)
     },
     /**
      * 小地图完成加载后
@@ -960,7 +955,7 @@ export default {
      * */
     setMainMap () {
       this.removeCesiumGraphics()
-      this.init()
+      this.initDefectMap()
     },
     /**
      * 构造管道缺陷地图要素
@@ -1070,7 +1065,12 @@ export default {
             let { strucDefectFeatures, funcDefectFeatures, pipeDefectFeatures } = map.getFeatures(res.result)
             if ([...strucDefectFeatures, ...funcDefectFeatures, ...pipeDefectFeatures].length !== 0) {
                 map.addLines([...strucDefectFeatures, ...funcDefectFeatures])
-                map.addDefects(pipeDefectFeatures)
+                setTimeout(() => { 
+                  map.addDefects(pipeDefectFeatures)
+                  new CesiumUtil(this.$refs.myMap.viewer).flyTo(pipeDefectFeatures[0])
+                }, 1000)
+                console.log('跳转子地图')
+                
             }
         } else this.$message.error('管线缺陷数据请求失败')
       })

+ 84 - 32
src/views/pipelineDefect/mixin/map.ts

@@ -39,15 +39,11 @@ export const mapMixin = {
         }
     },
     methods: {
-        // 设置相机位置
-        setCamera() {
-            let center = CesiumUtil.degrees2Car3(104.1629, 30.0039, 3e3)
-            this.cesiumUitl.setView(center)
-        },
         // 初始化
         initDefectMap() {
-            let psource = this.viewer.dataSources.getByName(this.pSname)[0], 
-                dsource = this.viewer.dataSources.getByName(this.dSname)[0]
+            console.log('加载管线')
+            let psource = this.getSource(this.pSname), 
+                dsource = this.getSource(this.dSname)
             if (psource && dsource && [...dsource.entities.values, ...psource.entities.values].length !== 0) {
                 this.setPipeAndDefectVisible()
             } else {
@@ -58,9 +54,8 @@ export const mapMixin = {
                     let { strucDefectFeatures, funcDefectFeatures, pipeDefectFeatures } = this.getFeatures(data)
                     if ([...strucDefectFeatures, ...funcDefectFeatures, ...pipeDefectFeatures].length !== 0) {
                         let lines = [...strucDefectFeatures, ...funcDefectFeatures]
-                        lines.length = 1000
+                        this.cesiumUitl.flyTo(lines[0])
                         this.addLines(lines)
-                        pipeDefectFeatures.length = 5000
                         this.addDefects(pipeDefectFeatures)
                         this.setPipeAndDefectVisible()
                     }
@@ -70,7 +65,7 @@ export const mapMixin = {
         },
         // 设置图层显隐
         setSourceVisible (sourceName, visible) {
-            let source = this.viewer.dataSources.getByName(sourceName)[0]
+            let source = this.getSource(sourceName)
             let entities = source.entities.values
             entities.forEach(e => { e.show = visible })
         },
@@ -85,15 +80,10 @@ export const mapMixin = {
         removeEvent () {
             this.handleManage.remove(this.clkHanderIndex)
             this.removeListener && this.removeListener()
-            this.data.that.$refs.popupwindow.removePopupWindow()
+            this.data.that.$refs.popupwindow && this.data.that.$refs.popupwindow.removePopupWindow()
         },
         removeLightFeas () {
-            let primitives = this.lightPrimitiveCollection
-            let l = primitives.length
-            for(let i = 0; i < l; i++) {
-                let p = primitives.get(i)
-                primitives.remove(p)
-            }
+            this.lightPrimitiveCollection.removeAll()
         },
         // 初始化事件
         initEvent () {
@@ -106,7 +96,6 @@ export const mapMixin = {
                     type = data[this.geometryType]
                     this.data.that.$refs.popupwindow.showPopupWindow(rayPoint, pick.id[this.propertyName], type)
                 }
-
                 this.removeLightFeas()
                 // 高亮
                 let fieldText = this.lightFeaText
@@ -146,7 +135,6 @@ export const mapMixin = {
                     let sFea = this.getEntity('line', lineCar3, { color: scolor }, { ...defect, lineCar3 })
                     sFea && features.strucDefectFeatures.push(sFea)
 
-
                     // 功能性
                     // let fcolor = findFuncColor ? findFuncColor.color : defaultColor
                     // let fFea = this.getPrimity('line', lineCar3, { color: fcolor }, { ...defect, lineCar3 })
@@ -193,21 +181,27 @@ export const mapMixin = {
             if (!Array.isArray(lines)) {
                 lines = [lines]
             }
+            let dataSource = this.getSource(this.pSname)
             lines.forEach(line => {
-                this.pDataSource.entities.add(line)
+                dataSource.entities.add(line)
             })
         },
+        // 获取图层
+        getSource(name) {
+            return this.viewer.dataSources.getByName(name)[0]
+        },
         // 加载缺陷
         addDefects (defects) {
             if (!Array.isArray(defects)) {
                 defects = [defects]
             }
+            let dataSource = this.getSource(this.dSname)
             defects.forEach(defect => {
-                this.dDataSource.entities.add(defect)
+                dataSource.entities.add(defect)
             })
         },
         // 获取图元
-        getPrimity (type, positions, style, data) {
+        getPrimity (type, positions, style, data = {}) {
             data[this.geometryType] = 'line'
             let primitive = this.graphicUtil.getPrimity(type, positions, style, {[this.propertyName]: data})
             return primitive
@@ -219,13 +213,70 @@ export const mapMixin = {
             entity[this.propertyName] = data
             return entity
         },
-        cesiumDestroy (){
-            this.removeEvent()
-            let sources = this.viewer.dataSources
-            let pS = sources.getByName(this.pSname)
-            let dS = sources.getByName(this.dSname)
-            pS.entities.values.forEach(e => pS.entities.remove(e))
-            dS.entities.values.forEach(e => pS.entities.remove(e))
+        removeCesiumGraphics (){
+            let pS = this.getSource(this.pSname)
+            let dS = this.getSource(this.dSname)
+            pS.entities.removeAll()
+            dS.entities.removeAll()
+        },
+        // 高亮并设置相机位置
+        // 0: 缺陷 1: 管线 2: 报告
+        setViewFromFeas(id, type) {
+            this.data.that.$refs.popupwindow.removePopupWindow()
+            this.removeLightFeas()
+            let idText = ['id', 'expNo', 'wordId'][type], 
+                height = [150, 500, 6000],
+                center,
+                findFeas = []
+            if (type) {
+                let pEntities = this.getSource(this.pSname).entities.values
+                findFeas = pEntities.filter(e => e[this.propertyName][idText] === id).map(i => i[this.propertyName])
+                let features = this.getLightFeatures(findFeas)
+                center = this.cesiumUitl.getCenterFormFeas(features.map(f => f.geometryInstances.id[this.propertyName].coors))
+                features.forEach(f => this.lightPrimitiveCollection.add(f))
+            } else {
+                let dEntities = this.getSource(this.dSname).entities.values
+                findFeas = dEntities.filter(e => e[this.propertyName][idText] === id).map(i => i[this.propertyName])
+                let { x, y } = JSON.parse(findFeas[0]['geometry'])
+                let [lon, lat] = this.projUtil.transform([x, y], this.currentDataProjName, 'proj84')
+                center = [lon, lat]
+            }
+
+            if (center) {
+                if (type !== 2) {
+                    this.cesiumUitl.setView(CesiumUtil.degrees2Car3(center[0], center[1], height[type]), () => {
+                        let car3 =  CesiumUtil.degrees2Car3(center[0], center[1], 0)
+                        let winPos = this.cesiumUitl.car32WindowPosition(car3)
+                        let geotype = type ? 'line' : 'point'
+                        let rayPoint = this.viewer.scene.globe.pick(this.viewer.scene.camera.getPickRay(winPos), this.viewer.scene);
+                        this.data.that.$refs.popupwindow.showPopupWindow(rayPoint, findFeas[0], geotype)
+                    })
+                }
+            } else {
+                this.$message.error('该点无位置信息');
+            }
+        },
+        // 获取高亮的要素
+        getLightFeatures(data) {
+            let that = this
+            let features = [], lightColor = 'rgba(0, 255, 255, 0.6)'
+            data.forEach(defect => {
+                let { endPointXLocation, endPointYLocation, startPointXLocation, startPointYLocation } = defect
+                if (startPointXLocation && startPointYLocation && endPointXLocation && endPointYLocation) {
+                    let startPoint = this.projUtil.transform([Number(startPointXLocation), Number(startPointYLocation)], this.currentDataProjName, 'proj84')
+                    let endPoint = this.projUtil.transform([Number(endPointXLocation), Number(endPointYLocation)], this.currentDataProjName, 'proj84')
+
+                    let lineCar3 = CesiumUtil.degreesArray2Car3([startPoint, endPoint].flat())
+                    let fea = this.getPrimity('line', lineCar3, { color: lightColor, width: 7 }, { ...defect, coors: [startPoint, endPoint]})
+                    if (!isExist(defect.expNo)) {
+                        features.push(fea)
+                    }
+                }
+            })
+            return features
+            function isExist (expNo) {
+                return features.some(f => f.geometryInstances.id[that.propertyName].expNo === expNo)
+            }
         },
     },
     mounted() {
@@ -248,17 +299,17 @@ export const mapMixin = {
         this.viewer.scene.primitives.add(this.lightPrimitiveCollection)
         
         // 缺陷,管道
-        if (!dataSources.getByName(this.pSname)[0]) {
+        if (!this.getSource(this.pSname)) {
             this.pDataSource = new Cesium.CustomDataSource(this.pSname)
             dataSources.add(this.pDataSource)
         }
-        if (!dataSources.getByName(this.dSname)[0]) {
+        if (!this.getSource(this.dSname)) {
             this.dDataSource = new Cesium.CustomDataSource(this.dSname)
             dataSources.add(this.dDataSource)
         }
         
         // 设置相机
-        this.setCamera()
+        // this.setCamera()
         // 加载管线,缺陷
         this.initDefectMap()
         // 点击事件
@@ -271,6 +322,7 @@ export const mapMixin = {
     },
     watch: {
         '$store.state.app.activeSideItem': function(n, o) {
+            if (n === '工程管理') { this.$store.dispatch('map/mapLaoding', false) }
             this.setPipeAndDefectVisible()
         }
     }

+ 3 - 0
src/views/prjSelection/index.vue

@@ -26,6 +26,7 @@ import { Vue, Component } from 'vue-property-decorator'
 import { ElTableColumn } from 'element-ui/types/table-column'
 import { elTableAlignLeft } from '@/utils/constant'
 import { fetchProjects, IOrgProjectCombine, setProjectKey, addMenu } from '@/api/common'
+import { appconfig } from 'staticPub/config'
 
 @Component({ name: 'Project', components: {} })
 export default class Project extends Vue {
@@ -50,6 +51,8 @@ export default class Project extends Vue {
   }
 
   async onProjectSelect(row: IOrgProjectCombine) {
+    // 这里设置当前项目
+    // appconfig.currPRJ = appconfig.prjBox[row.]
     const { id } = row || {}
     this.$store.commit('project/UPDATE', row)
 

+ 2 - 2
src/views/zhpt/index.vue

@@ -241,8 +241,8 @@ import HandleManage from '../pipelineDefect/common/cesiumEvent'
 
     removeDefectGraphic () {
       console.log('移除缺陷')
-      if (this.currTitle !== 'pipelineDefect') {
-        let viewer = (<any>window).viewer
+      let viewer = (<any>window).viewer
+      if (this.currTitle !== 'pipelineDefect' && viewer) {
         let sources = viewer.dataSources
         let pS = sources.getByName('pipeline')[0]
         let dS = sources.getByName('defect')[0]