wangjuncheng
2025-04-21 036647fcdc936273e78597408ee3fba09534ffd8
src/views/mnfz.vue
@@ -1,23 +1,9 @@
<template>
  <Left @start="startSimulate" @end="endSimulate" />
  <echartInfo
    :isDynamicMode="isDynamicMode"
    :isFinish="isFinish"
    v-if="rightRiverShow"
  />
  <TimeLine
    v-if="showWaterSimulate"
    @time-update="timeUpdate"
    @is-playing="isPlaying"
    :waterSimulateParams="waterSimulateParams"
    @playbackFinished="playbackFinished"
    @end="endSimulate"
  />
  <DebuffDetail
    v-if="showDebuffDetail"
    @open="openDetail"
    @close="showDebuffDetail = false"
  />
  <echartInfo :isDynamicMode="isDynamicMode" :isFinish="isFinish" v-if="rightRiverShow" />
  <TimeLine v-if="showWaterSimulate" @time-update="timeUpdate" @is-playing="isPlaying"
    :waterSimulateParams="waterSimulateParams" @playbackFinished="playbackFinished" @end="endSimulate" />
  <DebuffDetail v-if="showDebuffDetail" @open="openDetail" @close="showDebuffDetail = false" />
  <DebuffTable v-if="showDebuffTable" @close="closeDebuffTable" />
</template>
@@ -121,7 +107,7 @@
    });
    await Promise.all(loadPromises);
    setupRowClickListener(dataSources);
  } catch (error) {}
  } catch (error) { }
}
// 清除隐患点
function removeDataSources() {
@@ -267,32 +253,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 +300,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 +320,7 @@
        : originalColor;
    }, false)
  );
  // 将闪动状态保存到实体上,便于后续控制
  polygonEntity._isFlashing = isFlashing;
}
@@ -334,6 +332,7 @@
  polygonEntity.polygon.material = new Cesium.ColorMaterialProperty(
    originalColor
  );
  // 清空闪动状态
  polygonEntity._isFlashing = false;
  polygonEntity._originalColor = null; // 清除保存的原始颜色