Browse Source

空值校验

caozhaorui 1 year ago
parent
commit
3c40ef54ff
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/views/gis/business/enterprise/index.vue

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

@@ -208,11 +208,15 @@ export default defineComponent({
       const qyLayer = store.state.gis.map.getLayers().getArray().filter(v => v.get('layerName') === 'qy')?.[0]
       if (qyLayer) {
         const f = qyLayer.getSource().getFeatureById(item.id)
-        f?.get('mockClick')()
-        store.state.gis.map.getView().animate({
-          center: f.getGeometry().getCoordinates(),
-          zoom: store.state.gis.map.getView().getMaxZoom(),
-        });
+        if (f) {
+          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)
     }