guonan
2025-04-21 df7876b99d8e8d359909756d42e909dcc215fa38
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", {
@@ -267,32 +262,41 @@
}
// 定义全局变量存储当前正在闪动的面片
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 +309,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 +329,7 @@
        : originalColor;
    }, false)
  );
  // 将闪动状态保存到实体上,便于后续控制
  polygonEntity._isFlashing = isFlashing;
}
@@ -334,6 +341,7 @@
  polygonEntity.polygon.material = new Cesium.ColorMaterialProperty(
    originalColor
  );
  // 清空闪动状态
  polygonEntity._isFlashing = false;
  polygonEntity._originalColor = null; // 清除保存的原始颜色