2026-04-11 18:58:43 +08:00
|
|
|
<!-- 风险点组件 -->
|
|
|
|
|
<template>
|
2026-04-13 10:30:03 +08:00
|
|
|
<div>
|
|
|
|
|
<!-- 加载风险点 -->
|
|
|
|
|
<LoadingPoints
|
|
|
|
|
v-if="
|
|
|
|
|
useViewerStore().getViewerLoadingCompleted() && riskPoints.length > 0
|
|
|
|
|
"
|
|
|
|
|
:base-points="riskPoints"
|
|
|
|
|
:get-disaster-icon="getDisasterIcon"
|
|
|
|
|
:prefix="config.prefix.riskPointId"
|
|
|
|
|
/>
|
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"
|
|
|
|
|
v-if="useLoadingInformationStore().getLoadingRiskPointInformationStatus()"
|
|
|
|
|
:title="informationBoxTitle"
|
|
|
|
|
:offset-x="offsetX"
|
|
|
|
|
:offset-y="offsetY"
|
|
|
|
|
:key="useLoadingInformationStore().getRiskPointId()"
|
|
|
|
|
/>
|
|
|
|
|
</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';
|
|
|
|
|
import type { Point } from '@/types/base/Point';
|
|
|
|
|
import LoadingPoints from '@/component/rain-earthquake/LoadingPoints.vue';
|
|
|
|
|
import riskArea from '@/assets/images/icon/risk-area.png';
|
|
|
|
|
import config from '@/config/config.json';
|
|
|
|
|
import InformationBox from '@/component/common/InformationBox.vue';
|
|
|
|
|
import { useViewerStore } from '@/stores/useViewerStore';
|
|
|
|
|
import { useLoadingInformationStore } from '@/stores/useLoadingInformation';
|
|
|
|
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
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-04-13 10:30:03 +08:00
|
|
|
const informationBoxTitle = '风险区域';
|
|
|
|
|
const offsetX = ref(0);
|
|
|
|
|
const offsetY = ref(0);
|
|
|
|
|
const riskPointDetail = ref<Point>();
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
const field = {
|
2026-04-11 18:58:43 +08:00
|
|
|
riskName: '风险区名称',
|
|
|
|
|
unitCode: '统一编号',
|
|
|
|
|
housing: '住房(间)',
|
|
|
|
|
permanentPopulation: '常住人口(人)',
|
|
|
|
|
residentCounts: '居民户数(户)',
|
|
|
|
|
riskProperty: '威胁财产(万元)',
|
|
|
|
|
inspectorName: '巡查员姓名',
|
|
|
|
|
inspectorTele: '巡查员手机号',
|
|
|
|
|
position: '位置',
|
|
|
|
|
lon: '经度',
|
2026-04-13 10:30:03 +08:00
|
|
|
lat: '纬度',
|
|
|
|
|
};
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
$api.riskSpots.getBasePoins().then((res) => {
|
|
|
|
|
riskPoints.value = res.data;
|
|
|
|
|
});
|
2026-04-11 18:58:43 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
// 监听id变化
|
|
|
|
|
watch(
|
|
|
|
|
() => useLoadingInformationStore().getRiskPointId(),
|
|
|
|
|
async (newId: number) => {
|
|
|
|
|
if (newId === -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 获取风险点数据
|
|
|
|
|
const clickObject = useLoadingInformationStore().getClickObject();
|
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(
|
|
|
|
|
useLoadingInformationStore().getRiskPointId()
|
|
|
|
|
);
|
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;
|
|
|
|
|
|
|
|
|
|
// 显示新的信息框
|
|
|
|
|
useLoadingInformationStore().setLoadingRiskPointInformationStatus(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-11 18:58:43 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
2026-04-13 10:30:03 +08:00
|
|
|
function getDisasterIcon(): string {
|
2026-04-11 18:58:43 +08:00
|
|
|
return riskArea;
|
2026-04-13 10:30:03 +08:00
|
|
|
}
|
2026-04-11 18:58:43 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|