Quellcode durchsuchen

互联网-社管一张图-企业一张图,企业列表,再次单机未取消选中的企业

CzRger vor 1 Jahr
Ursprung
Commit
ee7b7a8397
2 geänderte Dateien mit 17 neuen und 10 gelöschten Zeilen
  1. 9 6
      src/views/gis/business/enterprise/index.vue
  2. 8 4
      src/views/gis/layout/index.vue

+ 9 - 6
src/views/gis/business/enterprise/index.vue

@@ -215,16 +215,19 @@ export default defineComponent({
       if (qyLayer) {
         const f = qyLayer.getSource().getFeatureById(item.id)
         if (f) {
-          f.get('mockClick')()
-          store.state.gis.map.getView().animate({
-            center: f.getGeometry().getCoordinates(),
-            zoom: store.state.gis.map.getView().getMaxZoom(),
-          });
+          if (item.id === store.state.gis.activeQyId) {
+            f.get('reset')()
+          } else {
+            f.get('mockClick')()
+            store.state.gis.map.getView().animate({
+              center: f.getGeometry().getCoordinates(),
+              zoom: store.state.gis.map.getView().getMaxZoom(),
+            });
+          }
         } else {
           ElMessage.warning('未找到该企业位置!')
         }
       }
-      console.log(item)
     }
     onMounted(() => {
       state.enterprise.form = JSON.parse(JSON.stringify(state.enterprise.tempForm))

+ 8 - 4
src/views/gis/layout/index.vue

@@ -424,6 +424,10 @@ export default defineComponent({
                 state.qyParams.overlay.setPosition(feat.getGeometry().getCoordinates())
                 store.dispatch('gis/LOAD_ACTIVE_QY_ID', v.id)
               })
+              feat.set('reset', () => {
+                onCloseQy()
+                onCloseSb()
+              })
               features.push(feat)
             } catch (e) {
               console.error('异常企业:', v)
@@ -469,16 +473,16 @@ export default defineComponent({
       })
     }
     const onCloseQy = () => {
-      state.qyParams.overlay.setPosition(undefined)
-      state.qyParams.tempFeature.get('resetStyle')()
+      state.qyParams.overlay?.setPosition(undefined)
+      state.qyParams.tempFeature?.get('resetStyle')()
       state.qyParams.tempFeature = null
       state.qyParams.qyInfo = {}
       state.qyParams.analysisSource?.clear()
       store.dispatch('gis/LOAD_ACTIVE_QY_ID', null)
     }
     const onCloseSb = () => {
-      state.qyParams.sbOverlay.setPosition(undefined)
-      state.qyParams.tempSbFeature.get('resetStyle')()
+      state.qyParams.sbOverlay?.setPosition(undefined)
+      state.qyParams.tempSbFeature?.get('resetStyle')()
       state.qyParams.tempSbFeature = null
     }
     const handleRangeBlur = () => {