96 lines
2.9 KiB
Vue
96 lines
2.9 KiB
Vue
|
|
<!-- 医院组件 -->
|
||
|
|
<template>
|
||
|
|
<div>
|
||
|
|
<!-- 加载医院 -->
|
||
|
|
<LoadingPoints
|
||
|
|
v-if="useStatusStore().appLoadingCompleted && hospitalPoints.length > 0"
|
||
|
|
:base-points="hospitalPoints"
|
||
|
|
:get-disaster-icon="getDisasterIcon"
|
||
|
|
:prefix="config.prefix.hospitalPointId"
|
||
|
|
:is-default="true"
|
||
|
|
:loading-resource-field="LoadingResource.HOSPITAL"
|
||
|
|
/>
|
||
|
|
|
||
|
|
<!-- 显示信息框 -->
|
||
|
|
<InformationBox
|
||
|
|
:data="hospitalPointDetail as Record<string, any>"
|
||
|
|
:field="field"
|
||
|
|
v-if="useLoadingInformationStore().hospital.loading"
|
||
|
|
:title="informationBoxTitle"
|
||
|
|
:offset-x="offsetX"
|
||
|
|
:offset-y="offsetY"
|
||
|
|
:key="useLoadingInformationStore().hospital.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 { useHospitalPoint } from '@/hooks/rain-earthquake/useHospitalPoint';
|
||
|
|
|
||
|
|
const hospitalPoints = ref<Point[]>([]);
|
||
|
|
|
||
|
|
// 信息框相关配置
|
||
|
|
const offsetX = ref(0);
|
||
|
|
const offsetY = ref(0);
|
||
|
|
const hospitalPointDetail = ref<Point>();
|
||
|
|
const informationBoxTitle = ref('');
|
||
|
|
|
||
|
|
// 获取钩子函数
|
||
|
|
const { field, getDisasterIcon } = useHospitalPoint();
|
||
|
|
|
||
|
|
$api.hospitals.getBasePoins().then((res) => {
|
||
|
|
hospitalPoints.value = res.data;
|
||
|
|
});
|
||
|
|
|
||
|
|
// 监听id变化
|
||
|
|
watch(
|
||
|
|
() => useLoadingInformationStore().hospital.id,
|
||
|
|
async (newId: number) => {
|
||
|
|
if (newId === -1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
// 获取医院数据
|
||
|
|
const clickObject = useLoadingInformationStore().clickObject;
|
||
|
|
|
||
|
|
if (!clickObject || !clickObject.primitive) {
|
||
|
|
console.warn('点击对象或图元不存在');
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
const res = await $api.hospitals.getPointDetailById(
|
||
|
|
useLoadingInformationStore().hospital.id
|
||
|
|
);
|
||
|
|
|
||
|
|
// 更新数据
|
||
|
|
hospitalPointDetail.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().hospital.loading = true;
|
||
|
|
} catch (error) {
|
||
|
|
throw new Error(`坐标转换失败:${error}`);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped></style>
|