2026-04-11 18:58:43 +08:00
|
|
|
<!-- 风险点组件 -->
|
|
|
|
|
<template>
|
2026-04-13 10:30:03 +08:00
|
|
|
<div>
|
|
|
|
|
<!-- 加载风险点 -->
|
|
|
|
|
<LoadingPoints
|
2026-05-07 12:53:25 +08:00
|
|
|
v-if="useStatus.appLoadingCompleted && riskPoints.length > 0"
|
2026-04-13 10:30:03 +08:00
|
|
|
:base-points="riskPoints"
|
|
|
|
|
:get-disaster-icon="getDisasterIcon"
|
|
|
|
|
:prefix="config.prefix.riskPointId"
|
2026-04-14 17:05:27 +08:00
|
|
|
:is-default="true"
|
2026-04-15 22:41:06 +08:00
|
|
|
:loading-resource-field="LoadingResource.RISK_POINT"
|
2026-04-13 10:30:03 +08:00
|
|
|
/>
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
<!-- 显示信息框 -->
|
|
|
|
|
<InformationBox
|
|
|
|
|
:data="riskPointDetail as Record<string, any>"
|
|
|
|
|
:field="field"
|
2026-05-07 12:53:25 +08:00
|
|
|
v-if="useLoadingInformation.riskPoint.loading"
|
2026-04-13 10:30:03 +08:00
|
|
|
:title="informationBoxTitle"
|
|
|
|
|
:offset-x="offsetX"
|
|
|
|
|
:offset-y="offsetY"
|
2026-05-07 12:53:25 +08:00
|
|
|
:key="useLoadingInformation.riskPoint.id"
|
2026-04-13 10:30:03 +08:00
|
|
|
/>
|
|
|
|
|
</div>
|
2026-04-11 18:58:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-04-13 10:30:03 +08:00
|
|
|
import { ref, watch } from 'vue';
|
|
|
|
|
import { $api } from '@/api/api.ts';
|
2026-04-21 19:50:57 +08:00
|
|
|
import type { Point } from '@/types/base/Point.ts';
|
|
|
|
|
import LoadingPoints from '@/component/common/LoadingPoints.vue';
|
2026-04-13 10:30:03 +08:00
|
|
|
import config from '@/config/config.json';
|
|
|
|
|
import InformationBox from '@/component/common/InformationBox.vue';
|
2026-04-21 19:50:57 +08:00
|
|
|
import { useStatusStore } from '@/stores/useStatusStore.ts';
|
|
|
|
|
import { useLoadingInformationStore } from '@/stores/useLoadingInformation.ts';
|
|
|
|
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils.ts';
|
|
|
|
|
import { useRiskPoint } from '@/hooks/rain-earthquake/useRiskPoint.ts';
|
|
|
|
|
import { LoadingResource } from '@/types/common/LoadingResourceType.ts';
|
|
|
|
|
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore.ts';
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
const riskPoints = ref<Point[]>([]);
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-05-07 12:53:25 +08:00
|
|
|
const useStatus = useStatusStore();
|
|
|
|
|
const useLoadingInformation = useLoadingInformationStore();
|
|
|
|
|
const useLoadingResource = useLoadingResourceStore();
|
|
|
|
|
|
2026-04-13 21:23:24 +08:00
|
|
|
// 信息框相关配置
|
2026-04-13 10:30:03 +08:00
|
|
|
const offsetX = ref(0);
|
|
|
|
|
const offsetY = ref(0);
|
|
|
|
|
const riskPointDetail = ref<Point>();
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 21:23:24 +08:00
|
|
|
// 获取钩子函数
|
|
|
|
|
const { informationBoxTitle, field, getDisasterIcon } = useRiskPoint();
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-27 18:02:57 +08:00
|
|
|
$api.riskSpots.getBasePoints().then((res) => {
|
2026-04-13 10:30:03 +08:00
|
|
|
riskPoints.value = res.data;
|
|
|
|
|
});
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
// 监听id变化
|
|
|
|
|
watch(
|
2026-05-07 12:53:25 +08:00
|
|
|
() => useLoadingInformation.riskPoint.id,
|
2026-04-13 10:30:03 +08:00
|
|
|
async (newId: number) => {
|
|
|
|
|
if (newId === -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 获取风险点数据
|
2026-05-07 12:53:25 +08:00
|
|
|
const clickObject = useLoadingInformation.clickObject;
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
if (!clickObject || !clickObject.primitive) {
|
2026-04-11 18:58:43 +08:00
|
|
|
console.warn('点击对象或图元不存在');
|
|
|
|
|
return;
|
2026-04-13 10:30:03 +08:00
|
|
|
}
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
const res = await $api.riskSpots.getPointDetailById(
|
2026-05-07 12:53:25 +08:00
|
|
|
useLoadingInformation.riskPoint.id
|
2026-04-13 10:30:03 +08:00
|
|
|
);
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
// 更新数据
|
|
|
|
|
riskPointDetail.value = res.data;
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
try {
|
2026-04-11 18:58:43 +08:00
|
|
|
// 将坐标转换为偏移量
|
2026-04-13 10:30:03 +08:00
|
|
|
const screenPos = CesiumUtilsSingleton.convertScreenPosition(
|
|
|
|
|
clickObject.primitive.position
|
|
|
|
|
);
|
2026-04-11 18:58:43 +08:00
|
|
|
offsetX.value = screenPos.x;
|
|
|
|
|
offsetY.value = screenPos.y;
|
|
|
|
|
|
|
|
|
|
// 显示新的信息框
|
2026-05-07 12:53:25 +08:00
|
|
|
useLoadingInformation.riskPoint.loading = true;
|
2026-04-13 10:30:03 +08:00
|
|
|
} catch (error) {
|
2026-04-11 18:58:43 +08:00
|
|
|
throw new Error(`坐标转换失败:${error}`);
|
2026-04-13 10:30:03 +08:00
|
|
|
}
|
2026-04-11 18:58:43 +08:00
|
|
|
}
|
2026-04-13 10:30:03 +08:00
|
|
|
);
|
2026-04-18 17:34:46 +08:00
|
|
|
|
|
|
|
|
// 监听显示隐藏风险点
|
|
|
|
|
watch(
|
2026-05-07 12:53:25 +08:00
|
|
|
() => useStatus.mapLayers.riskPointShow.show,
|
2026-04-18 17:34:46 +08:00
|
|
|
(newValue: boolean) => {
|
|
|
|
|
if (newValue) {
|
|
|
|
|
CesiumUtilsSingleton.batchShowPrimitives(
|
2026-05-07 12:53:25 +08:00
|
|
|
useLoadingResource.getLoadingResource(
|
2026-04-18 17:34:46 +08:00
|
|
|
LoadingResource.RISK_POINT
|
2026-04-27 21:36:37 +08:00
|
|
|
).ids
|
2026-04-18 17:34:46 +08:00
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
CesiumUtilsSingleton.batchHidePrimitives(
|
2026-05-07 12:53:25 +08:00
|
|
|
useLoadingResource.getLoadingResource(
|
2026-04-18 17:34:46 +08:00
|
|
|
LoadingResource.RISK_POINT
|
2026-04-27 21:36:37 +08:00
|
|
|
).ids
|
2026-04-18 17:34:46 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2026-04-11 18:58:43 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|