diff --git a/src/api/api.ts b/src/api/api.ts index f689080..30ce189 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -7,6 +7,7 @@ import { getBasePoints as getDangerousSourceBasePoints, getPointDetailById as ge import { getBasePoints as getEmergencyShelterBasePoints, getPointDetailById as getEmergencyShelterPointDetailById} from './emergency-shelter' import { getBasePoints as getFirefighterBasePoints, getPointDetailById as getFirefighterPointDetailById} from './firefighter' import { getBasePoints as getStorePointsBasePoints, getPointDetailById as getStorePointsPointDetailById} from './store-points' +import { getBasePoints as getSchoolsBasePoints, getPointDetailById as getSchoolsPointDetailById} from './schools' import type { ApiResponse } from '@/types/ApiResponse' import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots' import type { XianRiskSpots } from '@/types/base/XianRiskSpots' @@ -15,6 +16,7 @@ import type { XianDangerousSource } from '@/types/base/XianDangerousSource' import type { XianEmergencyShelter } from '@/types/base/XianEmergencyShelter' import type { XianFirefighter } from '@/types/base/XianFirefighter' import type { XianStorePoints } from '@/types/base/XianStorePoints' +import type { XianSchool } from '@/types/base/XianSchool' /** * API接口统一导出对象 @@ -142,4 +144,20 @@ export const $api = { */ getPointDetailById: (id: number): Promise> => getStorePointsPointDetailById(id), }, + + // 学校信息 + schools: { + /** + * 获取所有基础学校 + * @returns 学校数据数组 + */ + getBasePoints: (): Promise> => getSchoolsBasePoints(), + + /** + * 根据id获取学校详情 + * @param id - 学校id + * @returns 学校详情 + */ + getPointDetailById: (id: number): Promise> => getSchoolsPointDetailById(id), + }, } diff --git a/src/api/schools.ts b/src/api/schools.ts new file mode 100644 index 0000000..fb874d0 --- /dev/null +++ b/src/api/schools.ts @@ -0,0 +1,20 @@ +import type { ApiResponse } from "@/types/ApiResponse" +import type { XianSchool } from "@/types/base/XianSchool" +import httpInstance from "@/utils/request/http" + +/** + * 获取学校基础数据 + * @returns 学校数据数组 + */ +export const getBasePoints = (): Promise> => { + return httpInstance.get('/school/base-points') +} + +/** + * 根据id获取学校详情 + * @param id - 学校id + * @returns 学校详情 + */ +export const getPointDetailById = (id: number): Promise> => { + return httpInstance.get(`/school/point-detail/${id}`) +} diff --git a/src/assets/images/icon/school.png b/src/assets/images/icon/school.png new file mode 100644 index 0000000..032a87c Binary files /dev/null and b/src/assets/images/icon/school.png differ diff --git a/src/assets/index.ts b/src/assets/index.ts index 117fdd3..92c4e5f 100644 --- a/src/assets/index.ts +++ b/src/assets/index.ts @@ -10,6 +10,8 @@ export { default as hospitalIcon } from '@/assets/images/icon/hospital.png'; export { default as dangerousSourceIcon } from '@/assets/images/icon/dangerous-source.png'; export { default as emergencyShelterIcon } from '@/assets/images/icon/emergency-shelter.png'; export { default as firefighterIcon } from '@/assets/images/icon/firefighter.png'; +export { default as storePointsIcon } from '@/assets/images/icon/store-points.jpg'; +export { default as schoolIcon } from '@/assets/images/icon/school.png'; // 图片 export { default as backgroundImage } from '@/assets/images/background-image.png'; diff --git a/src/component/rain-earthquake/ControlShowDetailComponent.vue b/src/component/rain-earthquake/ControlShowDetailComponent.vue index ebd8793..1c55ed7 100644 --- a/src/component/rain-earthquake/ControlShowDetailComponent.vue +++ b/src/component/rain-earthquake/ControlShowDetailComponent.vue @@ -39,6 +39,14 @@ " /> + + + diff --git a/src/component/rain-earthquake/detail-panels/SchoolComponent.vue b/src/component/rain-earthquake/detail-panels/SchoolComponent.vue new file mode 100644 index 0000000..e9fc78e --- /dev/null +++ b/src/component/rain-earthquake/detail-panels/SchoolComponent.vue @@ -0,0 +1,114 @@ + + + + + + diff --git a/src/config/config.json b/src/config/config.json index ac24a73..3e55fe0 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -40,6 +40,7 @@ "dangerousSourcePointId": "dangerous-source-point-", "emergencyShelterPointId": "emergency-shelter-point-", "fireStationPointId": "fire-station-point-", - "storePointsPointId": "store-points-point-" + "storePointsPointId": "store-points-point-", + "schoolPointId": "school-point-" } } \ No newline at end of file diff --git a/src/hooks/earthquake/useEarthquakeDisasterChain.ts b/src/hooks/earthquake/useEarthquakeDisasterChain.ts index ad4bfe5..49a310f 100644 --- a/src/hooks/earthquake/useEarthquakeDisasterChain.ts +++ b/src/hooks/earthquake/useEarthquakeDisasterChain.ts @@ -217,9 +217,7 @@ export const useEarthquakeDisasterChain = () => { name: '显示学校', statusStore: statusStore.poiLayers, statusKey: 'showSchool' as const, - callback: (status: unknown) => { - console.log('显示学校', status); - }, + callback: layerControl.clickSchool, }, { name: '显示人口网格', diff --git a/src/hooks/map/useMap.ts b/src/hooks/map/useMap.ts index a6f34a6..c893605 100644 --- a/src/hooks/map/useMap.ts +++ b/src/hooks/map/useMap.ts @@ -74,6 +74,11 @@ export const useMap = () => { useLoadingInformationStore().storePoints.id = id; } + // 学校 + else if (pickedObject.id.startsWith(config.prefix.schoolPointId)) { + useLoadingInformationStore().school.id = id; + } + // 其他 else { // 重置状态 diff --git a/src/hooks/rain-earthquake/useLayerControl.ts b/src/hooks/rain-earthquake/useLayerControl.ts index 86c78d1..a8a2fc7 100644 --- a/src/hooks/rain-earthquake/useLayerControl.ts +++ b/src/hooks/rain-earthquake/useLayerControl.ts @@ -53,6 +53,14 @@ export const useLayerControl = () => { useStatusStore().poiLayers.showReservePoint.loading = true; }; + /** + * 点击显示学校 + */ + const clickSchool = () => { + // 加载状态为true + useStatusStore().poiLayers.showSchool.loading = true; + }; + /** * 点击显示人口网格 */ @@ -75,6 +83,7 @@ export const useLayerControl = () => { clickEmergencyShelter, clickFireStation, clickStorePoints, + clickSchool, clickPopulationGrid, clickWaterPipe, }; diff --git a/src/hooks/rain-earthquake/useSchoolPoint.ts b/src/hooks/rain-earthquake/useSchoolPoint.ts new file mode 100644 index 0000000..88ea2bf --- /dev/null +++ b/src/hooks/rain-earthquake/useSchoolPoint.ts @@ -0,0 +1,31 @@ +import { schoolIcon } from '@/assets'; + +/** + * 学校相关钩子函数 + * @returns 字段映射和获取图标方法 + */ +export const useSchoolPoint = () => { + /** + * 字段映射配置 + */ + const field = { + schoolName: '学校名称', + schoolType: '学校类型', + lon: '经度', + lat: '纬度', + students: '在校学生数', + isImportant: '是否有重点保护目标', + unitHead: '负责人', + telephone: '联系电话', + }; + + /** + * 获取学校图标 + * @returns 图标路径 + */ + function getDisasterIcon(): string { + return schoolIcon; + } + + return { field, getDisasterIcon }; +}; diff --git a/src/hooks/rain-earthquake/useStorePointsPoint.ts b/src/hooks/rain-earthquake/useStorePointsPoint.ts index ebc7073..173508c 100644 --- a/src/hooks/rain-earthquake/useStorePointsPoint.ts +++ b/src/hooks/rain-earthquake/useStorePointsPoint.ts @@ -1,4 +1,4 @@ -import storePointsIcon from '@/assets/images/icon/store-points.jpg'; +import { storePointsIcon } from '@/assets'; /** * 物资储备点相关钩子函数 diff --git a/src/hooks/rainstorm/useRainDisasterChain.ts b/src/hooks/rainstorm/useRainDisasterChain.ts index 8704802..4977d3b 100644 --- a/src/hooks/rainstorm/useRainDisasterChain.ts +++ b/src/hooks/rainstorm/useRainDisasterChain.ts @@ -240,9 +240,7 @@ export const useRainDisasterChain = () => { name: '显示学校', statusStore: statusStore.poiLayers, statusKey: 'showSchool' as const, - callback: (status: unknown) => { - console.log('显示学校', status); - }, + callback: layerControl.clickSchool, }, { name: '显示人口网格', diff --git a/src/stores/useLoadingInformation.ts b/src/stores/useLoadingInformation.ts index bb78b59..4f15c17 100644 --- a/src/stores/useLoadingInformation.ts +++ b/src/stores/useLoadingInformation.ts @@ -84,6 +84,14 @@ export const useLoadingInformationStore = defineStore( id: -1, }); + // ============================== 学校状态 ================================ + const school = reactive({ + /** 加载状态 */ + loading: false, + /** 学校ID */ + id: -1, + }); + /** * 重置所有状态 */ @@ -119,6 +127,10 @@ export const useLoadingInformationStore = defineStore( // 物资储备点状态重置 storePoints.loading = false; storePoints.id = -1; + + // 学校状态重置 + school.loading = false; + school.id = -1; }; return { @@ -130,6 +142,7 @@ export const useLoadingInformationStore = defineStore( emergencyShelter, fireStation, storePoints, + school, resetStatue, }; } diff --git a/src/types/base/XianSchool.ts b/src/types/base/XianSchool.ts new file mode 100644 index 0000000..81e11bc --- /dev/null +++ b/src/types/base/XianSchool.ts @@ -0,0 +1,97 @@ +import type { Point } from './Point'; + +/** + * 西安市学校数据接口 + */ +export interface XianSchool extends Point { + /** 学校名称 */ + schoolName?: string; + /** 学校地址 */ + schoolAddress?: string; + /** 学校编码 */ + schoolCode?: string; + /** 学校类型 */ + schoolType?: string; + /** 所属部门 */ + schoolCreater?: string; + /** 学校面积 */ + area?: number; + /** 建筑物面积 */ + constructionArea?: number; + /** 设施 */ + devices?: number; + /** 是否重点保护目标 */ + isImportant?: string; + /** 工作人员 */ + staff?: number; + /** 学生数 */ + students?: number; + /** 留校生 */ + boarder?: number; + /** 留学生 */ + foreignStudents?: number; + /** 教室数量 */ + classrooms?: number; + /** 避难所面积 */ + shelterArea?: number; + /** 是否有医院 */ + isHaveHospital?: string; + /** 医生数量 */ + doctorNum?: number; + /** 安全员数量 */ + securityStaffNum?: number; + /** 应急电力 */ + emergencyElectric?: string; + /** 供水 */ + waterMethod?: string; + /** 供暖 */ + heatingMethod?: string; + /** 应急通信 */ + emergencyConnectionMethod?: string; + /** 灾害记录 */ + isDisasterType?: string; + /** 灾害预案 */ + haveEmergencyPlanType?: string; + /** 设施编码 */ + institutionCode?: string; + /** 创造时间 */ + createTime?: string; + /** 市 */ + city?: string; + /** 区县 */ + county?: string; + /** 联系电话 */ + telephone?: string; + /** 区县编码 */ + code?: string; + /** 单位负责人 */ + unitHead?: string; + /** 街道/乡镇 */ + country?: string; + /** 负责人 */ + fillName?: string; + /** 承建单位 */ + createName?: string; + /** 省 */ + province?: string; + /** 记录人 */ + statisticsHead?: string; + /** 报告时间 */ + reportTime?: string; + /** 物理主键 */ + physicalKey?: string; + /** 省编码 */ + provinceCode?: number; + /** 市编码 */ + cityCode?: number; + /** 区县编码 */ + countyCode?: number; + /** 更新时间 */ + updateTime?: string; + /** 经度 */ + lon?: number; + /** 纬度 */ + lat?: number; + /** 逻辑删除标识,0未删除,1已删除 */ + isDelete?: number; +} diff --git a/src/types/common/LoadingResourceType.ts b/src/types/common/LoadingResourceType.ts index 0e62af9..ad69a4a 100644 --- a/src/types/common/LoadingResourceType.ts +++ b/src/types/common/LoadingResourceType.ts @@ -28,4 +28,7 @@ export enum LoadingResource { /** 物资储备点 */ STORE_POINTS = 'STORE_POINTS', + + /** 学校 */ + SCHOOL = 'SCHOOL', }