Jelajahi Sumber

修复弹窗弹出条件

yes-yes-yes-k 2 hari lalu
induk
melakukan
8b8d7d9114
1 mengubah file dengan 16 tambahan dan 16 penghapusan
  1. 16 16
      src/views/User/acidModel/acidmodelmap.vue

+ 16 - 16
src/views/User/acidModel/acidmodelmap.vue

@@ -652,7 +652,7 @@ const cancelAcidInversion = () => {
   currentPredictionType.value = null;
 };
 
-//  确认降酸预测(原有逻辑不变,补充pH校验)
+//  确认降酸预测
 const confirmAcidReduction = async () => {
   if (!acidReductionFormRef.value) return;
   if (currentPH.value === null) {
@@ -799,13 +799,6 @@ const handleMapClick = async (e: any) => {
   clickPoint.x = mapRect.left + containerPoint.x;
   clickPoint.y = mapRect.top + containerPoint.y;
   
-  // 设置弹窗初始位置(在点击点右侧)
-  popupPosition.x = 35;
-  popupPosition.y = 35; // 居中显示
-  
-  showPopup.value = true;
-  showConnectionLine.value=false;
-  
   // 重置预测状态
   resetPrediction();
   featureInfo.data = null;
@@ -819,14 +812,15 @@ const handleMapClick = async (e: any) => {
   // 获取地块信息
   try {
     const hasFeature = await getFeatureInfo(e.latlng, containerPoint);
-    // 如果没有获取到要素,提示
-    if (!hasFeature) {
-      featureInfo.data = {
-        village: '未知',
-        landType: '未知'
-      };
-      ElMessage.info('未查询到该地块的详细信息');
-      // 如果没有获取到地块,使用点击点作为连接线起点
+    
+    if (hasFeature) {
+      // 设置弹窗初始位置(在点击点右侧)
+       popupPosition.x = 35;
+       popupPosition.y = 35; // 居中显示
+  
+       showPopup.value = true;
+       showConnectionLine.value=false;
+      // 使用点击点作为连接线起点
       featureCenter.lng = lng;
       featureCenter.lat = lat;
       // 直接显示连接线
@@ -834,6 +828,10 @@ const handleMapClick = async (e: any) => {
       nextTick(() => {
         updateConnectionLine();
       });
+    }else{
+      showPopup.value=false;
+      showConnectionLine.value=false;
+      ElMessage.info('请点击有效地块');
     }
   } catch (error) {
     console.error('处理地块信息失败:', error);
@@ -842,6 +840,8 @@ const handleMapClick = async (e: any) => {
       map.value.removeLayer(highlightLayer.value);
       highlightLayer.value = null;
     }
+    showPopup.value=false;
+    showConnectionLine.value=false;
   }
 
   // 使用点击点作为连接线起点