guonan
2025-04-18 75c5c3a056f8d8db2021c466f19e19ff4492c49b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
  <Left @start="startSimulate" @end="endSimulate" />
  <echartInfo :isDynamicMode="isDynamicMode" :isFinish="isFinish" />
  <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>
 
<script setup>
import { ref, onMounted, onUnmounted, provide } from "vue";
import TimeLine from "@/components/menu/TimeLine.vue";
import Left from "./left/Left.vue";
import echartInfo from "@/components/monifangzhen/echartInfo.vue";
import DebuffDetail from "@/components/tools/DebuffDetail.vue";
import DebuffTable from "@/components/tools/DebuffTable.vue";
import { getMaxInfluenceArea } from "@/api/index";
 
import { createPoint, geomToGeoJSON } from "@/utils/map.js";
import { checkedKeys } from "@/store/index";
const waterSimulateParams = ref({});
const showWaterSimulate = ref(false);
const showDebuffDetail = ref(false);
const showDebuffTable = ref(false);
const isDynamicMode = ref(false);
const isFinish = ref(true);
 
// 提供方法给所有子组件
provide("simulateActions", {
  startSimulate,
  endSimulate,
});
 
function startSimulate(form) {
  // console.log("form", form);
  showWaterSimulate.value = true;
  waterSimulateParams.value = form;
}
function endSimulate() {
  // showDebuffDetail.value = true
  removeDataSources();
  setTimeout(() => {
    showWaterSimulate.value = false;
    isDynamicMode.value = false;
  }, 2000);
}
const MaxInfluenceAreaList = ref([]);
const dataSources = [];
function getTimeMarkers() {
  // 将改 list数据的 gemo EPSG:4548 坐标 转为 wgs84 坐标系的 geojson 数据
  const list = MaxInfluenceAreaList.value;
  list.forEach((item, index) => {
    const geosjon = geomToGeoJSON(item.geom);
    Cesium.GeoJsonDataSource.load(geosjon, {
      stroke: Cesium.Color.RED, // 边框颜色
      strokeWidth: 2, // 边框宽度
      fill: Cesium.Color.RED.withAlpha(0.5), // 填充颜色(带透明度)
    }).then((dataSource) => {
      viewer.dataSources.add(dataSource);
      dataSources.push(dataSource);
    });
  });
}
function removeDataSources() {
  dataSources.forEach((dataSource) => {
    viewer.dataSources.remove(dataSource);
  });
}
function timeUpdate(percentage) {
  if (percentage > 99) {
    if (showDebuffDetail.value) {
      return;
    }
    checkedKeys.value = ["避险点"];
    showDebuffDetail.value = true;
    getTimeMarkers();
    
  }
}
function openDetail() {
  showDebuffTable.value = true;
}
function closeDebuffTable() {
  showDebuffTable.value = false;
  showDebuffDetail.value = true;
}
function getMaxInfluenceAreaData() {
  getMaxInfluenceArea().then((res) => {
    MaxInfluenceAreaList.value = res.data.items;
  });
}
 
function isPlaying(val) {
  isDynamicMode.value = val;
}
 
function playbackFinished(val) {
  isFinish.value = val;
}
onMounted(() => {
  getMaxInfluenceAreaData();
});
onUnmounted(() => {
  endSimulate();
});
</script>
<style lang="less" scoped>
@import url("../assets/css/home.css");
</style>