危险源点

This commit is contained in:
wzy-warehouse
2026-04-18 19:03:06 +08:00
parent f3fd716352
commit ad3ffe91b0
15 changed files with 319 additions and 8 deletions
@@ -6,11 +6,20 @@
useStatusStore().poiLayers.showHospital.loading
"
/>
<!-- 危险源 -->
<DangerousSourceComponent
v-if="
useStatusStore().appLoadingCompleted &&
useStatusStore().poiLayers.showDangerSource.loading
"
/>
</template>
<script lang="ts" setup>
import { useStatusStore } from '@/stores/useStatusStore';
import HospitalComponent from './HospitalComponent.vue';
import DangerousSourceComponent from './DangerousSourceComponent.vue';
</script>
<style scoped lang="less"></style>
@@ -0,0 +1,120 @@
<!-- 危险源组件 -->
<template>
<div>
<!-- 加载危险源 -->
<LoadingPoints
v-if="
useStatusStore().appLoadingCompleted && dangerousSourcePoints.length > 0
"
:base-points="dangerousSourcePoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.dangerousSourcePointId"
:is-default="false"
:loading-resource-field="LoadingResource.DANGEROUS_SOURCE"
/>
<!-- 显示信息框 -->
<InformationBox
:data="dangerousSourcePointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformationStore().dangerousSource.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformationStore().dangerousSource.id"
/>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { $api } from '@/api/api.ts';
import type { Point } from '@/types/base/Point';
import LoadingPoints from '@/component/rain-earthquake/LoadingPoints.vue';
import config from '@/config/config.json';
import InformationBox from '@/component/common/InformationBox.vue';
import { useStatusStore } from '@/stores/useStatusStore';
import { useLoadingInformationStore } from '@/stores/useLoadingInformation';
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
import { LoadingResource } from '@/types/common/LoadingResourceType';
import { useDangerousSourcePoint } from '@/hooks/rain-earthquake/useDangerousSourcePoint';
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
const dangerousSourcePoints = ref<Point[]>([]);
// 信息框相关配置
const offsetX = ref(0);
const offsetY = ref(0);
const dangerousSourcePointDetail = ref<Point>();
const informationBoxTitle = ref('');
// 获取钩子函数
const { field, getDisasterIcon } = useDangerousSourcePoint();
$api.dangerousSource.getBasePoints().then((res) => {
dangerousSourcePoints.value = res.data;
});
// 监听id变化
watch(
() => useLoadingInformationStore().dangerousSource.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取危险源数据
const clickObject = useLoadingInformationStore().clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
return;
}
const res = await $api.dangerousSource.getPointDetailById(
useLoadingInformationStore().dangerousSource.id
);
// 更新数据
dangerousSourcePointDetail.value = res.data;
informationBoxTitle.value = res.data.name || '危险源信息';
try {
// 将坐标转换为偏移量
const screenPos = CesiumUtilsSingleton.convertScreenPosition(
clickObject.primitive.position
);
offsetX.value = screenPos.x;
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformationStore().dangerousSource.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
}
);
// 监听显示隐藏
watch(
() => useStatusStore().poiLayers.showDangerSource.show,
(newValue: boolean) => {
if (newValue) {
// 显示危险源
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.DANGEROUS_SOURCE
)
);
} else {
// 隐藏危险源
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
LoadingResource.DANGEROUS_SOURCE
)
);
}
}
);
</script>
<style scoped></style>