guonan
2025-04-28 94dc999e2107401cb9e6c65dd67bc17eecc5e548
src/views/mnfz.vue
@@ -36,12 +36,10 @@
import danger from "@/assets/img/left/danger.png";
import { checkedKeys } from "@/store/index";
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
const simStore = useSimStore();
const { rightRiverShow } = storeToRefs(simStore);
const waterSimulateParams = ref({});
const showWaterSimulate = ref(false);
@@ -51,9 +49,6 @@
const isFinish = ref(true);
const treeMap = new Map();
// 提供方法给所有子组件
provide("simulateActions", {
@@ -137,10 +132,10 @@
  });
  dataSources.length = 0;
}
// 避险点,绿色富文本
// 避险场所,绿色富文本
function addTetrahedron(visible) {
  const emergencyAreaList = [];
  //  这里是添加避险点底层面片
  //  这里是添加避险场所底层面片
  loadAreaPolygon("/json/emergency_area.geojson", true).then((entities) => {
    emergencyAreaList.push(...entities);
  });
@@ -166,10 +161,10 @@
    //   altitude: 528,
    // },
  ];
  // 这里是添加避险点富文本高亮显示
  // 这里是添加避险场所富文本高亮显示
  list.forEach((item) => {
    let point = earthCtrl.factory.createRichTextPoint(
      "避险点",
      "避险场所",
      [item.longitude, item.latitude, item.altitude - 10],
      {
        distanceDisplayCondition:
@@ -182,11 +177,11 @@
    console.log("point", point);
    emergencyAreaList.push(point);
  });
  treeMap.set("避险点", emergencyAreaList);
  treeMap.set("避险场所", emergencyAreaList);
}
// 删除避险点的富文本实体
// 删除避险场所的富文本实体
function removeEmergencyPoints() {
  const emergencyAreaList = treeMap.get("避险点"); // 获取存储的避险点实体列表
  const emergencyAreaList = treeMap.get("避险场所"); // 获取存储的避险场所实体列表
  if (emergencyAreaList && emergencyAreaList.length > 0) {
    emergencyAreaList.forEach((entity) => {
      if (entity && typeof entity.deleteObject === "function") {
@@ -200,7 +195,7 @@
        earthCtrl.coreMap.entities.remove(entity);
      }
    });
    treeMap.set("避险点", []); // 清空存储的避险点列表
    treeMap.set("避险场所", []); // 清空存储的避险场所列表
  }
}
@@ -238,7 +233,7 @@
    if (showDebuffDetail.value) {
      return;
    }
    checkedKeys.value = ["避险点"];
    checkedKeys.value = ["避险场所"];
    showDebuffDetail.value = true;
    getTimeMarkers();
    addTetrahedron();
@@ -267,32 +262,39 @@
}
// 定义全局变量存储当前正在闪动的面片
let flashingPolygon = null;
// 添加事件监听器,接收来自表格组件的事件
function setupRowClickListener(dataSources) {
  if (!Array.isArray(dataSources) || dataSources.length === 0) {
    console.error("Data sources array is undefined or empty!");
    return;
  }
  EventBus.on("row-clicked", (id) => {
    const clickedEntity = findEntityById(id, dataSources);
    if (clickedEntity) {
      // 如果点击的是同一个实体,则停止闪动并清空选择
      if (flashingPolygon && flashingPolygon === clickedEntity) {
        stopFlashing(flashingPolygon);
        flashingPolygon = null; // 清空当前选中的实体
        return;
      }
      // 如果有其他实体正在闪动,先停止它的闪动
      if (flashingPolygon && flashingPolygon !== clickedEntity) {
        stopFlashing(flashingPolygon);
      }
      // 开始新的闪动
      startFlashing(clickedEntity);
      flashingPolygon = clickedEntity;
    } else {
      console.warn(`No entity found with ID: ${id}`);
    }
  });
}
// 根据ID查找实体
function findEntityById(id, dataSources) {
  if (!Array.isArray(dataSources) || dataSources.length === 0) {
    console.error("Data sources array is undefined or empty!");
    return null;
  }
  console.log("Searching for ID:", id);
  for (const dataSource of dataSources) {
    const entities = dataSource.entities.values;
@@ -305,11 +307,13 @@
  }
  return null;
}
// 开始闪动效果
function startFlashing(polygonEntity) {
  // 存储原始颜色
  const originalColor = polygonEntity.polygon.material.color.getValue();
  polygonEntity._originalColor = originalColor; // 将原始颜色保存到实体中
  // 创建颜色变化的回调函数
  let isFlashing = true; // 标记是否正在闪动
  polygonEntity.polygon.material = new Cesium.ColorMaterialProperty(
@@ -323,6 +327,7 @@
        : originalColor;
    }, false)
  );
  // 将闪动状态保存到实体上,便于后续控制
  polygonEntity._isFlashing = isFlashing;
}
@@ -334,6 +339,7 @@
  polygonEntity.polygon.material = new Cesium.ColorMaterialProperty(
    originalColor
  );
  // 清空闪动状态
  polygonEntity._isFlashing = false;
  polygonEntity._originalColor = null; // 清除保存的原始颜色