Browse Source

要素测试

CzRger 1 year ago
parent
commit
e6843d5243
1 changed files with 54 additions and 53 deletions
  1. 54 53
      src/views/element/index.vue

+ 54 - 53
src/views/element/index.vue

@@ -21,7 +21,7 @@
           <div>
             <span>{{ node.label }}</span>
             <el-link v-if="!node.data._show" href="javascript:;" type="primary" @click.stop="onShow(node)">显示</el-link>
-            <el-link v-else href="javascript:;" type="primary" @click.stop="onHide(node)">隐藏</el-link>
+            <el-link v-else href="javascript:;" type="danger" @click.stop="onHide(node)">隐藏</el-link>
           </div>
         </template>
       </el-tree-v2>
@@ -253,61 +253,62 @@ export default defineComponent({
     const setSourceData = () => {
       const arr: any = []
       state.treeData.forEach(p => {
-        console.log(p)
         if (p.mapId === 'deptInfo') {
 
         } else {
           p.children.forEach(v => {
-            try {
-              const geometry: any = new format.WKT().readFeature(v.location).getGeometry()
-              const obj = {
-                type: 'Feature',
-                geometry: {
-                  type: geometry.getType(),
-                  coordinates: geometry.getCoordinates()
-                },
-                properties: v
+            if (v._show) {
+              try {
+                const geometry: any = new format.WKT().readFeature(v.location).getGeometry()
+                const obj = {
+                  type: 'Feature',
+                  geometry: {
+                    type: geometry.getType(),
+                    coordinates: geometry.getCoordinates()
+                  },
+                  properties: v
+                }
+                let fillColor = 'rgba(20, 129, 241, 0.3)'
+                let lineColor = '#2860F1'
+                let lineWidth = 1
+                let lineDasharray = globalLineDash[0]
+                if (v.regionalColor) {
+                  fillColor = v.regionalColor
+                }
+                if (v.segmentColor) {
+                  lineColor = v.segmentColor
+                }
+                if (v.segmentWidth) {
+                  lineWidth = v.segmentWidth
+                }
+                if (v.segmentType) {
+                  lineDasharray = globalLineDash[Number(v.segmentType)]
+                }
+                obj.properties.fillColor = fillColor
+                obj.properties.lineColor = lineColor
+                obj.properties.lineWidth = lineWidth
+                obj.properties.lineDasharray = lineDasharray
+                switch (p.mapId) {
+                  case 'axBayonetList': obj.properties.iconImage = 'axBayonetListImg'
+                    break
+                  case 'axSiteList': obj.properties.iconImage = 'axSiteListImg'
+                    break
+                  case 'governmentalList': obj.properties.iconImage = 'governmentalListImg'
+                    break
+                  case 'islandList': obj.properties.iconImage = 'islandListImg'
+                    break
+                  case 'monitoringList': obj.properties.iconImage = 'monitoringListImg'
+                    break
+                  case 'radarList': obj.properties.iconImage = 'radarListImg'
+                    break
+                  case 'terminalList': obj.properties.iconImage = 'terminalListImg'
+                    break
+                  case 'waterBasedFacilitiesList': obj.properties.iconImage = 'waterBasedFacilitiesListImg'
+                    break
+                }
+                arr.push(obj)
+              } catch (e) {
               }
-              let fillColor = 'rgba(20, 129, 241, 0.3)'
-              let lineColor = '#2860F1'
-              let lineWidth = 1
-              let lineDasharray = globalLineDash[0]
-              if (v.regionalColor) {
-                fillColor = v.regionalColor
-              }
-              if (v.segmentColor) {
-                lineColor = v.segmentColor
-              }
-              if (v.segmentWidth) {
-                lineWidth = v.segmentWidth
-              }
-              if (v.segmentType) {
-                lineDasharray = globalLineDash[Number(v.segmentType)]
-              }
-              obj.properties.fillColor = fillColor
-              obj.properties.lineColor = lineColor
-              obj.properties.lineWidth = lineWidth
-              obj.properties.lineDasharray = lineDasharray
-              switch (p.mapId) {
-                case 'axBayonetList': obj.properties.iconImage = 'axBayonetListImg'
-                  break
-                case 'axSiteList': obj.properties.iconImage = 'axSiteListImg'
-                  break
-                case 'governmentalList': obj.properties.iconImage = 'governmentalListImg'
-                  break
-                case 'islandList': obj.properties.iconImage = 'islandListImg'
-                  break
-                case 'monitoringList': obj.properties.iconImage = 'monitoringListImg'
-                  break
-                case 'radarList': obj.properties.iconImage = 'radarListImg'
-                  break
-                case 'terminalList': obj.properties.iconImage = 'terminalListImg'
-                  break
-                case 'waterBasedFacilitiesList': obj.properties.iconImage = 'waterBasedFacilitiesListImg'
-                  break
-              }
-              arr.push(obj)
-            } catch (e) {
             }
           })
         }
@@ -327,7 +328,7 @@ export default defineComponent({
       console.log(node)
       node.data._show = true
       node.children?.forEach(v => {
-        v._show = true
+        v.data._show = true
       })
       setSourceData()
     }
@@ -335,7 +336,7 @@ export default defineComponent({
       console.log(node)
       node.data._show = false
       node.children?.forEach(v => {
-        v._show = false
+        v.data._show = false
       })
       setSourceData()
     }