From b913bea524f38ea368fd1e893d5995643962456b Mon Sep 17 00:00:00 2001 From: zxyroyy <1442470094@qq.com> Date: Fri, 26 Jun 2026 13:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E6=AD=A5=EF=BC=9A=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=E6=95=B0=E6=8D=AE=E5=88=86=E7=B1=BB=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisasterChainPointComponent.vue | 11 +- src/hooks/useDisasterChainTable.ts | 12 +- src/hooks/usePointsHandle.ts | 3 +- src/types/base/Point.ts | 4 +- src/types/common/InfrastructurePointType.ts | 38 +++ src/views/home/rainstorm/RainstormView.vue | 230 ++++++++++-------- 6 files changed, 188 insertions(+), 110 deletions(-) create mode 100644 src/types/common/InfrastructurePointType.ts diff --git a/src/component/rain-earthquake/DisasterChainPointComponent.vue b/src/component/rain-earthquake/DisasterChainPointComponent.vue index d242e6c..b3c0dd9 100644 --- a/src/component/rain-earthquake/DisasterChainPointComponent.vue +++ b/src/component/rain-earthquake/DisasterChainPointComponent.vue @@ -31,7 +31,7 @@ @@ -88,6 +88,7 @@ import { useStatusStore } from '@/stores/useStatusStore'; import type { Point } from '@/types/base/Point'; import { PointType } from '@/types/common/DisasterType'; + import { InfrastructurePointType } from '@/types/common/InfrastructurePointType'; import type { PaginationType } from '@/types/common/PaginationType'; import { ref, watch, computed, type Ref } from 'vue'; @@ -95,7 +96,7 @@ // 接收父组件的参数 const props = defineProps<{ - selectOptions: { label: string; value: PointType }[]; + selectOptions: { label: string; value: PointType | InfrastructurePointType }[]; tableDataList: Point[]; tableColumns: { title: string; key: string }[]; pageOption: PaginationType; @@ -106,13 +107,13 @@ const emits = defineEmits<{ ( e: 'changeConditions', - value: { tableData: string; hiddenPoint: PointType } + value: { tableData: string; hiddenPoint: PointType | InfrastructurePointType } ): void; (e: 'changeCurrentPage', value: number): void; }>(); // 搜索条件 - const conditions: Ref<{ tableData: string; hiddenPoint: PointType }> = ref({ + const conditions: Ref<{ tableData: string; hiddenPoint: PointType | InfrastructurePointType }> = ref({ tableData: '', hiddenPoint: PointType.LANDSLIDE, }); @@ -308,4 +309,4 @@ align-items: center; line-height: 1.5; } - + \ No newline at end of file diff --git a/src/hooks/useDisasterChainTable.ts b/src/hooks/useDisasterChainTable.ts index d872716..0beaa52 100644 --- a/src/hooks/useDisasterChainTable.ts +++ b/src/hooks/useDisasterChainTable.ts @@ -1,14 +1,16 @@ import { ref } from 'vue'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { XianRiskSpots } from '@/types/base/XianRiskSpots'; +import type { XianHospitals } from '@/types/base/XianHospitals'; import type { PaginationType } from '@/types/common/PaginationType'; import { PointType } from '@/types/common/DisasterType'; +import { InfrastructurePointType } from '@/types/common/InfrastructurePointType'; /** * 灾害链表格数据选项 */ export interface SelectOption { - value: PointType; + value: PointType | InfrastructurePointType; label: string; } @@ -25,7 +27,7 @@ export interface TableColumn { */ export interface SearchConditions { tableData: string; - hiddenPoint: PointType; + hiddenPoint: PointType | InfrastructurePointType; } /** @@ -57,7 +59,7 @@ export const useDisasterChainTable = () => { /** * 表格数据 */ - const tableDatas = ref<(XianHiddenDangerSpots | XianRiskSpots)[]>([]); + const tableDatas = ref<(XianHiddenDangerSpots | XianRiskSpots | XianHospitals)[]>([]); /** * 分页配置 @@ -124,7 +126,7 @@ export const useDisasterChainTable = () => { * 设置表格数据 * @param datas - 表格数据数组 */ - const setTableDatas = (datas: (XianHiddenDangerSpots | XianRiskSpots)[]) => { + const setTableDatas = (datas: (XianHiddenDangerSpots | XianRiskSpots | XianHospitals)[]) => { tableDatas.value = datas; paginationConfig.value.total = datas.length; paginationConfig.value.totalPage = Math.ceil(datas.length / paginationConfig.value.pageSize); @@ -149,4 +151,4 @@ export const useDisasterChainTable = () => { setTableColumns, setTableDatas, }; -}; +}; \ No newline at end of file diff --git a/src/hooks/usePointsHandle.ts b/src/hooks/usePointsHandle.ts index 6727eb8..4714c28 100644 --- a/src/hooks/usePointsHandle.ts +++ b/src/hooks/usePointsHandle.ts @@ -44,8 +44,7 @@ export const usePointsHandle = () => { const id = `${prefix}${point.id}`; ids.push(id); - info.push({ id, name: point.name!, lon: point.lon, lat: point.lat, scale_grade: point.scale_grade, risk_grade: point.risk_grade, risk_level: point.risk_level }); - + info.push({ id, name: point.name!, lon: point.lon, lat: point.lat, scale_grade: point.scale_grade, risk_grade: point.risk_grade, risk_level: point.risk_level, level: point.level }); options.push({ id: id, type: 'billboard', diff --git a/src/types/base/Point.ts b/src/types/base/Point.ts index 9e47006..dcde45e 100644 --- a/src/types/base/Point.ts +++ b/src/types/base/Point.ts @@ -22,4 +22,6 @@ export interface Point { risk_grade?: string; /** 风险区等级(风险点专用) */ risk_level?: string; -} + /** 医院等级(医院专用) */ + level?: string; +} \ No newline at end of file diff --git a/src/types/common/InfrastructurePointType.ts b/src/types/common/InfrastructurePointType.ts new file mode 100644 index 0000000..b40734a --- /dev/null +++ b/src/types/common/InfrastructurePointType.ts @@ -0,0 +1,38 @@ +/** + * 基础设施点类型枚举 + */ +export enum InfrastructurePointType { + /** 医院 */ + HOSPITAL = '医院', + /** 学校 */ + SCHOOL = '学校', + /** 危险源 */ + DANGEROUS_SOURCE = '危险源', + /** 避难所 */ + REFUGEE_SHELTER = '避难所', + /** 消防站 */ + FIRE_STATION = '消防站', + /** 储备点 */ + STORE_POINTS = '储备点', + /** 桥梁 */ + BRIDGE = '桥梁', + /** 水库 */ + RESERVOIR = '水库', + /** 地铁站 */ + SUBWAY = '地铁站', +} + +/** + * 基础设施点类型映射(中文 -> 后端英文参数) + */ +export const InfrastructurePointTypeMap: Record = { + [InfrastructurePointType.HOSPITAL]: 'hospital', + [InfrastructurePointType.SCHOOL]: 'school', + [InfrastructurePointType.DANGEROUS_SOURCE]: 'dangerous_source', + [InfrastructurePointType.REFUGEE_SHELTER]: 'refugee_shelter', + [InfrastructurePointType.FIRE_STATION]: 'fire_station', + [InfrastructurePointType.STORE_POINTS]: 'store_points', + [InfrastructurePointType.BRIDGE]: 'bridge', + [InfrastructurePointType.RESERVOIR]: 'reservoir', + [InfrastructurePointType.SUBWAY]: 'subway', +}; \ No newline at end of file diff --git a/src/views/home/rainstorm/RainstormView.vue b/src/views/home/rainstorm/RainstormView.vue index 0bb1a96..48ce7ad 100644 --- a/src/views/home/rainstorm/RainstormView.vue +++ b/src/views/home/rainstorm/RainstormView.vue @@ -73,10 +73,12 @@ import StepComponent from '@/component/rain-earthquake/StepComponent.vue'; import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain'; import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis'; + import { InfrastructurePointType } from '@/types/common/InfrastructurePointType'; import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType'; import type { PointResource } from '@/types/common/useAroundAnalysisType'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { XianRiskSpots } from '@/types/base/XianRiskSpots'; + import type { XianHospitals } from '@/types/base/XianHospitals'; import { useDisasterChainTable, type SearchConditions, @@ -123,20 +125,21 @@ onBeforeMount(() => { // 设置下拉选项 setSelectOptions([ - { value: PointType.LANDSLIDE, label: '滑坡' }, - { value: PointType.DEBRIS_FLOW, label: '泥石流' }, - { value: PointType.WATER_LOGGING, label: '内涝' }, - { value: PointType.FLASH_FLOOD, label: '山洪' }, - { value: PointType.COLLAPSE, label: '崩塌' }, - { value: PointType.RISK_AREA, label: '风险区' }, + {value: PointType.LANDSLIDE, label: '滑坡'}, + {value: PointType.DEBRIS_FLOW, label: '泥石流'}, + {value: PointType.WATER_LOGGING, label: '内涝'}, + {value: PointType.FLASH_FLOOD, label: '山洪'}, + {value: PointType.COLLAPSE, label: '崩塌'}, + {value: PointType.RISK_AREA, label: '风险区'}, + {value: InfrastructurePointType.HOSPITAL, label: '医院'}, ]); // 设置表格列配置(默认显示隐患点的列) setTableColumns([ - { title: '名称', key: 'disasterName' }, - { title: '位置', key: 'position' }, - { title: '规模等级', key: 'scaleGrade' }, - { title: '险情等级', key: 'riskGrade' }, + {title: '名称', key: 'disasterName'}, + {title: '位置', key: 'position'}, + {title: '规模等级', key: 'scaleGrade'}, + {title: '险情等级', key: 'riskGrade'}, ]); /** @@ -150,106 +153,139 @@ if (value.hiddenPoint === PointType.RISK_AREA) { // 风险区:只显示风险区等级 setTableColumns([ - { title: '名称', key: 'disasterName' }, - { title: '位置', key: 'position' }, - { title: '风险区等级', key: 'riskLevel' }, + {title: '名称', key: 'disasterName'}, + {title: '位置', key: 'position'}, + {title: '风险区等级', key: 'riskLevel'}, + ]); + } else if (value.hiddenPoint === InfrastructurePointType.HOSPITAL) { + // 医院:只显示医院等级 + setTableColumns([ + {title: '名称', key: 'disasterName'}, + {title: '位置', key: 'position'}, + {title: '医院等级', key: 'level'}, ]); } else { // 隐患点:显示规模等级和险情等级 setTableColumns([ - { title: '名称', key: 'disasterName' }, - { title: '位置', key: 'position' }, - { title: '规模等级', key: 'scaleGrade' }, - { title: '险情等级', key: 'riskGrade' }, + {title: '名称', key: 'disasterName'}, + {title: '位置', key: 'position'}, + {title: '规模等级', key: 'scaleGrade'}, + {title: '险情等级', key: 'riskGrade'}, ]); } }; - }); // 监听脉冲点变化和下拉选项变化,过滤并更新表格数据 - watch( - [ - () => aroundAnalysisState.pulsePoints.value, - () => conditions.value.hiddenPoint, - ], - ([newPulsePoints, hiddenPointType]: [PointResource[], PointType]) => { - console.log('=== 脉冲点变化 ==='); - console.log('newPulsePoints:', newPulsePoints); - console.log('newPulsePoints.length:', newPulsePoints?.length); - console.log('hiddenPointType:', hiddenPointType); + watch( + [ + () => aroundAnalysisState.pulsePoints.value, + () => conditions.value.hiddenPoint, + ], + ([newPulsePoints, hiddenPointType]: [PointResource[], PointType | InfrastructurePointType]) => { + console.log('=== 脉冲点变化 ==='); + console.log('newPulsePoints:', newPulsePoints); + console.log('newPulsePoints.length:', newPulsePoints?.length); + console.log('hiddenPointType:', hiddenPointType); - if (newPulsePoints && newPulsePoints.length > 0) { - // 根据选中的隐患点类型过滤 - const englishType = HiddenDangerPointTypeMap[hiddenPointType]; - const filteredPoints = newPulsePoints.filter(point => { - if (point.category === 'hidden-danger') { - return point.originalType === englishType; - } - if ( - hiddenPointType === PointType.RISK_AREA && - point.category === 'risk-point' - ) { - return true; - } - return false; - }); + if (newPulsePoints && newPulsePoints.length > 0) { + // 根据选中的类型过滤 + const filteredPoints = newPulsePoints.filter(point => { + // 隐患点过滤 + if (point.category === 'hidden-danger') { + const englishType = HiddenDangerPointTypeMap[hiddenPointType as PointType]; + return englishType ? point.originalType === englishType : false; + } + // 风险点过滤 + if ( + hiddenPointType === PointType.RISK_AREA && + point.category === 'risk-point' + ) { + return true; + } + // 医院过滤 + if ( + hiddenPointType === InfrastructurePointType.HOSPITAL && + point.category === 'hospital' + ) { + return true; + } + return false; + }); - // 根据类型转换数据 - const convertedData = filteredPoints.map(point => { - if (point.category === 'risk-point') { - // 风险点数据 - return { - id: - typeof point.id === 'number' - ? point.id - : parseInt(String(point.id), 10), - name: point.value, - disasterName: point.value, - position: - point.lon !== undefined && point.lat !== undefined - ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` - : '未知位置', - riskLevel: String(point.risk_level || '一般'), - lon: point.lon, - lat: point.lat, - } as XianRiskSpots; + // 根据类型转换数据 + const convertedData = filteredPoints.map(point => { + if (point.category === 'risk-point') { + // 风险点数据 + return { + id: + typeof point.id === 'number' + ? point.id + : parseInt(String(point.id), 10), + name: point.value, + disasterName: point.value, + position: + point.lon !== undefined && point.lat !== undefined + ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` + : '未知位置', + riskLevel: String(point.risk_level || '一般'), + lon: point.lon, + lat: point.lat, + } as XianRiskSpots; + } else if (point.category === 'hospital') { + // 医院数据 + return { + id: + typeof point.id === 'number' + ? point.id + : parseInt(String(point.id), 10), + name: point.value, + disasterName: point.value, + position: + point.lon !== undefined && point.lat !== undefined + ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` + : '未知位置', + level: String(point.level || '未知'), + lon: point.lon, + lat: point.lat, + } as XianHospitals; + } else { + // 隐患点数据 + return { + id: + typeof point.id === 'number' + ? point.id + : parseInt(String(point.id), 10), + name: point.value, + disasterName: point.value, + position: + point.lon !== undefined && point.lat !== undefined + ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` + : '未知位置', + scaleGrade: String(point.scale_grade || '未知'), + riskGrade: String(point.risk_grade || '一般'), + lon: point.lon, + lat: point.lat, + fieldCode: String(point.id), + province: '陕西省', + city: '西安市', + county: '', + village: '', + isDelete: 0, + } as XianHiddenDangerSpots; + } + }); + + console.log('convertedData:', convertedData); + setTableDatas(convertedData); } else { - // 隐患点数据 - return { - id: - typeof point.id === 'number' - ? point.id - : parseInt(String(point.id), 10), - name: point.value, - disasterName: point.value, - position: - point.lon !== undefined && point.lat !== undefined - ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` - : '未知位置', - scaleGrade: String(point.scale_grade || '未知'), - riskGrade: String(point.risk_grade || '一般'), - lon: point.lon, - lat: point.lat, - fieldCode: String(point.id), - province: '陕西省', - city: '西安市', - county: '', - village: '', - isDelete: 0, - } as XianHiddenDangerSpots; + // 如果没有脉冲点,则清空表格数据 + console.log('清空表格数据'); + setTableDatas([]); } - }); - - console.log('convertedData:', convertedData); - setTableDatas(convertedData); - } else { - // 如果没有脉冲点,则清空表格数据 - console.log('清空表格数据'); - setTableDatas([]); - } - }, - { immediate: true, deep: true } - ); + }, + { immediate: true, deep: true } + ); + }); \ No newline at end of file