第四步:医院数据分类显示

This commit is contained in:
2026-06-26 13:54:57 +08:00
parent a2189695ef
commit b913bea524
6 changed files with 188 additions and 110 deletions
@@ -31,7 +31,7 @@
<el-option <el-option
v-for="(opt, index) in selectOptions" v-for="(opt, index) in selectOptions"
:key="index" :key="index"
:label="opt.value === PointType.RISK_AREA ? opt.label : `${opt.label}预警点`" :label="opt.value === PointType.RISK_AREA || opt.value === InfrastructurePointType.HOSPITAL ? opt.label : `${opt.label}预警点`"
:value="opt.value" :value="opt.value"
/> />
</el-select> </el-select>
@@ -88,6 +88,7 @@
import { useStatusStore } from '@/stores/useStatusStore'; import { useStatusStore } from '@/stores/useStatusStore';
import type { Point } from '@/types/base/Point'; import type { Point } from '@/types/base/Point';
import { PointType } from '@/types/common/DisasterType'; import { PointType } from '@/types/common/DisasterType';
import { InfrastructurePointType } from '@/types/common/InfrastructurePointType';
import type { PaginationType } from '@/types/common/PaginationType'; import type { PaginationType } from '@/types/common/PaginationType';
import { ref, watch, computed, type Ref } from 'vue'; import { ref, watch, computed, type Ref } from 'vue';
@@ -95,7 +96,7 @@
// 接收父组件的参数 // 接收父组件的参数
const props = defineProps<{ const props = defineProps<{
selectOptions: { label: string; value: PointType }[]; selectOptions: { label: string; value: PointType | InfrastructurePointType }[];
tableDataList: Point[]; tableDataList: Point[];
tableColumns: { title: string; key: string }[]; tableColumns: { title: string; key: string }[];
pageOption: PaginationType; pageOption: PaginationType;
@@ -106,13 +107,13 @@
const emits = defineEmits<{ const emits = defineEmits<{
( (
e: 'changeConditions', e: 'changeConditions',
value: { tableData: string; hiddenPoint: PointType } value: { tableData: string; hiddenPoint: PointType | InfrastructurePointType }
): void; ): void;
(e: 'changeCurrentPage', value: number): void; (e: 'changeCurrentPage', value: number): void;
}>(); }>();
// 搜索条件 // 搜索条件
const conditions: Ref<{ tableData: string; hiddenPoint: PointType }> = ref({ const conditions: Ref<{ tableData: string; hiddenPoint: PointType | InfrastructurePointType }> = ref({
tableData: '', tableData: '',
hiddenPoint: PointType.LANDSLIDE, hiddenPoint: PointType.LANDSLIDE,
}); });
@@ -308,4 +309,4 @@
align-items: center; align-items: center;
line-height: 1.5; line-height: 1.5;
} }
</style> </style>
+7 -5
View File
@@ -1,14 +1,16 @@
import { ref } from 'vue'; import { ref } from 'vue';
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
import type { XianRiskSpots } from '@/types/base/XianRiskSpots'; import type { XianRiskSpots } from '@/types/base/XianRiskSpots';
import type { XianHospitals } from '@/types/base/XianHospitals';
import type { PaginationType } from '@/types/common/PaginationType'; import type { PaginationType } from '@/types/common/PaginationType';
import { PointType } from '@/types/common/DisasterType'; import { PointType } from '@/types/common/DisasterType';
import { InfrastructurePointType } from '@/types/common/InfrastructurePointType';
/** /**
* 灾害链表格数据选项 * 灾害链表格数据选项
*/ */
export interface SelectOption { export interface SelectOption {
value: PointType; value: PointType | InfrastructurePointType;
label: string; label: string;
} }
@@ -25,7 +27,7 @@ export interface TableColumn {
*/ */
export interface SearchConditions { export interface SearchConditions {
tableData: string; 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 - 表格数据数组 * @param datas - 表格数据数组
*/ */
const setTableDatas = (datas: (XianHiddenDangerSpots | XianRiskSpots)[]) => { const setTableDatas = (datas: (XianHiddenDangerSpots | XianRiskSpots | XianHospitals)[]) => {
tableDatas.value = datas; tableDatas.value = datas;
paginationConfig.value.total = datas.length; paginationConfig.value.total = datas.length;
paginationConfig.value.totalPage = Math.ceil(datas.length / paginationConfig.value.pageSize); paginationConfig.value.totalPage = Math.ceil(datas.length / paginationConfig.value.pageSize);
@@ -149,4 +151,4 @@ export const useDisasterChainTable = () => {
setTableColumns, setTableColumns,
setTableDatas, setTableDatas,
}; };
}; };
+1 -2
View File
@@ -44,8 +44,7 @@ export const usePointsHandle = () => {
const id = `${prefix}${point.id}`; const id = `${prefix}${point.id}`;
ids.push(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({ options.push({
id: id, id: id,
type: 'billboard', type: 'billboard',
+3 -1
View File
@@ -22,4 +22,6 @@ export interface Point {
risk_grade?: string; risk_grade?: string;
/** 风险区等级(风险点专用) */ /** 风险区等级(风险点专用) */
risk_level?: string; risk_level?: string;
} /** 医院等级(医院专用) */
level?: string;
}
@@ -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, string> = {
[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',
};
+133 -97
View File
@@ -73,10 +73,12 @@
import StepComponent from '@/component/rain-earthquake/StepComponent.vue'; import StepComponent from '@/component/rain-earthquake/StepComponent.vue';
import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain'; import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain';
import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis'; import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis';
import { InfrastructurePointType } from '@/types/common/InfrastructurePointType';
import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType'; import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType';
import type { PointResource } from '@/types/common/useAroundAnalysisType'; import type { PointResource } from '@/types/common/useAroundAnalysisType';
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
import type { XianRiskSpots } from '@/types/base/XianRiskSpots'; import type { XianRiskSpots } from '@/types/base/XianRiskSpots';
import type { XianHospitals } from '@/types/base/XianHospitals';
import { import {
useDisasterChainTable, useDisasterChainTable,
type SearchConditions, type SearchConditions,
@@ -123,20 +125,21 @@
onBeforeMount(() => { onBeforeMount(() => {
// 设置下拉选项 // 设置下拉选项
setSelectOptions([ setSelectOptions([
{ value: PointType.LANDSLIDE, label: '滑坡' }, {value: PointType.LANDSLIDE, label: '滑坡'},
{ value: PointType.DEBRIS_FLOW, label: '泥石流' }, {value: PointType.DEBRIS_FLOW, label: '泥石流'},
{ value: PointType.WATER_LOGGING, label: '内涝' }, {value: PointType.WATER_LOGGING, label: '内涝'},
{ value: PointType.FLASH_FLOOD, label: '山洪' }, {value: PointType.FLASH_FLOOD, label: '山洪'},
{ value: PointType.COLLAPSE, label: '崩塌' }, {value: PointType.COLLAPSE, label: '崩塌'},
{ value: PointType.RISK_AREA, label: '风险区' }, {value: PointType.RISK_AREA, label: '风险区'},
{value: InfrastructurePointType.HOSPITAL, label: '医院'},
]); ]);
// 设置表格列配置(默认显示隐患点的列) // 设置表格列配置(默认显示隐患点的列)
setTableColumns([ setTableColumns([
{ title: '名称', key: 'disasterName' }, {title: '名称', key: 'disasterName'},
{ title: '位置', key: 'position' }, {title: '位置', key: 'position'},
{ title: '规模等级', key: 'scaleGrade' }, {title: '规模等级', key: 'scaleGrade'},
{ title: '险情等级', key: 'riskGrade' }, {title: '险情等级', key: 'riskGrade'},
]); ]);
/** /**
@@ -150,106 +153,139 @@
if (value.hiddenPoint === PointType.RISK_AREA) { if (value.hiddenPoint === PointType.RISK_AREA) {
// 风险区:只显示风险区等级 // 风险区:只显示风险区等级
setTableColumns([ setTableColumns([
{ title: '名称', key: 'disasterName' }, {title: '名称', key: 'disasterName'},
{ title: '位置', key: 'position' }, {title: '位置', key: 'position'},
{ title: '风险区等级', key: 'riskLevel' }, {title: '风险区等级', key: 'riskLevel'},
]);
} else if (value.hiddenPoint === InfrastructurePointType.HOSPITAL) {
// 医院:只显示医院等级
setTableColumns([
{title: '名称', key: 'disasterName'},
{title: '位置', key: 'position'},
{title: '医院等级', key: 'level'},
]); ]);
} else { } else {
// 隐患点:显示规模等级和险情等级 // 隐患点:显示规模等级和险情等级
setTableColumns([ setTableColumns([
{ title: '名称', key: 'disasterName' }, {title: '名称', key: 'disasterName'},
{ title: '位置', key: 'position' }, {title: '位置', key: 'position'},
{ title: '规模等级', key: 'scaleGrade' }, {title: '规模等级', key: 'scaleGrade'},
{ title: '险情等级', key: 'riskGrade' }, {title: '险情等级', key: 'riskGrade'},
]); ]);
} }
}; };
});
// 监听脉冲点变化和下拉选项变化,过滤并更新表格数据 // 监听脉冲点变化和下拉选项变化,过滤并更新表格数据
watch( watch(
[ [
() => aroundAnalysisState.pulsePoints.value, () => aroundAnalysisState.pulsePoints.value,
() => conditions.value.hiddenPoint, () => conditions.value.hiddenPoint,
], ],
([newPulsePoints, hiddenPointType]: [PointResource[], PointType]) => { ([newPulsePoints, hiddenPointType]: [PointResource[], PointType | InfrastructurePointType]) => {
console.log('=== 脉冲点变化 ==='); console.log('=== 脉冲点变化 ===');
console.log('newPulsePoints:', newPulsePoints); console.log('newPulsePoints:', newPulsePoints);
console.log('newPulsePoints.length:', newPulsePoints?.length); console.log('newPulsePoints.length:', newPulsePoints?.length);
console.log('hiddenPointType:', hiddenPointType); console.log('hiddenPointType:', hiddenPointType);
if (newPulsePoints && newPulsePoints.length > 0) { if (newPulsePoints && newPulsePoints.length > 0) {
// 根据选中的隐患点类型过滤 // 根据选中的类型过滤
const englishType = HiddenDangerPointTypeMap[hiddenPointType]; const filteredPoints = newPulsePoints.filter(point => {
const filteredPoints = newPulsePoints.filter(point => { // 隐患点过滤
if (point.category === 'hidden-danger') { if (point.category === 'hidden-danger') {
return point.originalType === englishType; const englishType = HiddenDangerPointTypeMap[hiddenPointType as PointType];
} return englishType ? point.originalType === englishType : false;
if ( }
hiddenPointType === PointType.RISK_AREA && // 风险点过滤
point.category === 'risk-point' if (
) { hiddenPointType === PointType.RISK_AREA &&
return true; point.category === 'risk-point'
} ) {
return false; return true;
}); }
// 医院过滤
if (
hiddenPointType === InfrastructurePointType.HOSPITAL &&
point.category === 'hospital'
) {
return true;
}
return false;
});
// 根据类型转换数据 // 根据类型转换数据
const convertedData = filteredPoints.map(point => { const convertedData = filteredPoints.map(point => {
if (point.category === 'risk-point') { if (point.category === 'risk-point') {
// 风险点数据 // 风险点数据
return { return {
id: id:
typeof point.id === 'number' typeof point.id === 'number'
? point.id ? point.id
: parseInt(String(point.id), 10), : parseInt(String(point.id), 10),
name: point.value, name: point.value,
disasterName: point.value, disasterName: point.value,
position: position:
point.lon !== undefined && point.lat !== undefined point.lon !== undefined && point.lat !== undefined
? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}` ? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}`
: '未知位置', : '未知位置',
riskLevel: String(point.risk_level || '一般'), riskLevel: String(point.risk_level || '一般'),
lon: point.lon, lon: point.lon,
lat: point.lat, lat: point.lat,
} as XianRiskSpots; } 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 { } else {
// 隐患点数据 // 如果没有脉冲点,则清空表格数据
return { console.log('清空表格数据');
id: setTableDatas([]);
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;
} }
}); },
{ immediate: true, deep: true }
console.log('convertedData:', convertedData); );
setTableDatas(convertedData); });
} else {
// 如果没有脉冲点,则清空表格数据
console.log('清空表格数据');
setTableDatas([]);
}
},
{ immediate: true, deep: true }
);
</script> </script>
<style scoped></style> <style scoped></style>