物资储备点
This commit is contained in:
@@ -30,6 +30,14 @@
|
||||
useStatusStore().poiLayers.showFireStation.loading
|
||||
"
|
||||
/>
|
||||
|
||||
<!-- 物资储备点 -->
|
||||
<StorePointsComponent
|
||||
v-if="
|
||||
useStatusStore().appLoadingCompleted &&
|
||||
useStatusStore().poiLayers.showReservePoint.loading
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -38,6 +46,7 @@
|
||||
import DangerousSourceComponent from './DangerousSourceComponent.vue';
|
||||
import EmergencyShelterComponent from './EmergencyShelterComponent.vue';
|
||||
import FireStationComponent from './FireStationComponent.vue';
|
||||
import StorePointsComponent from './StorePointsComponent.vue';
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<!-- 物资储备点组件 -->
|
||||
<template>
|
||||
<div>
|
||||
<!-- 加载物资储备点 -->
|
||||
<LoadingPoints
|
||||
v-if="
|
||||
useStatusStore().appLoadingCompleted && storePointsList.length > 0
|
||||
"
|
||||
:base-points="storePointsList"
|
||||
:get-disaster-icon="getDisasterIcon"
|
||||
:prefix="config.prefix.storePointsPointId"
|
||||
:is-default="false"
|
||||
:loading-resource-field="LoadingResource.STORE_POINTS"
|
||||
/>
|
||||
|
||||
<!-- 显示信息框 -->
|
||||
<InformationBox
|
||||
:data="storePointDetail as Record<string, any>"
|
||||
:field="field"
|
||||
v-if="useLoadingInformationStore().storePoints.loading"
|
||||
:title="informationBoxTitle"
|
||||
:offset-x="offsetX"
|
||||
:offset-y="offsetY"
|
||||
:key="useLoadingInformationStore().storePoints.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 { useStorePointsPoint } from '@/hooks/rain-earthquake/useStorePointsPoint';
|
||||
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
|
||||
|
||||
const storePointsList = ref<Point[]>([]);
|
||||
|
||||
// 信息框相关配置
|
||||
const offsetX = ref(0);
|
||||
const offsetY = ref(0);
|
||||
const storePointDetail = ref<Point>();
|
||||
const informationBoxTitle = ref('');
|
||||
|
||||
// 获取钩子函数
|
||||
const { field, getDisasterIcon } = useStorePointsPoint();
|
||||
|
||||
$api.storePoints.getBasePoints().then((res) => {
|
||||
storePointsList.value = res.data;
|
||||
});
|
||||
|
||||
// 监听id变化
|
||||
watch(
|
||||
() => useLoadingInformationStore().storePoints.id,
|
||||
async (newId: number) => {
|
||||
if (newId === -1) {
|
||||
return;
|
||||
}
|
||||
// 获取物资储备点数据
|
||||
const clickObject = useLoadingInformationStore().clickObject;
|
||||
|
||||
if (!clickObject || !clickObject.primitive) {
|
||||
console.warn('点击对象或图元不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await $api.storePoints.getPointDetailById(
|
||||
useLoadingInformationStore().storePoints.id
|
||||
);
|
||||
|
||||
// 更新数据
|
||||
storePointDetail.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().storePoints.loading = true;
|
||||
} catch (error) {
|
||||
throw new Error(`坐标转换失败:${error}`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 监听显示隐藏
|
||||
watch(
|
||||
() => useStatusStore().poiLayers.showReservePoint.show,
|
||||
(newValue: boolean) => {
|
||||
if (newValue) {
|
||||
// 显示物资储备点
|
||||
CesiumUtilsSingleton.batchShowPrimitives(
|
||||
useLoadingResourceStore().getLoadingResource(
|
||||
LoadingResource.STORE_POINTS
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// 隐藏物资储备点
|
||||
CesiumUtilsSingleton.batchHidePrimitives(
|
||||
useLoadingResourceStore().getLoadingResource(
|
||||
LoadingResource.STORE_POINTS
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user