第一步:将列表数据全部显示

This commit is contained in:
2026-06-25 22:07:39 +08:00
parent ef11dbcc58
commit 0403491b16
6 changed files with 101 additions and 14 deletions
+53 -3
View File
@@ -71,13 +71,17 @@
import RightButtonComponent from '@/component/rain-earthquake/RightButtonComponent.vue';
import StepComponent from '@/component/rain-earthquake/StepComponent.vue';
import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain';
import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis';
import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType';
import type { PointResource } from '@/types/common/useAroundAnalysisType';
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
import {
useDisasterChainTable,
type SearchConditions,
} from '@/hooks/useDisasterChainTable';
import { useStatusStore } from '@/stores/useStatusStore';
import { DisasterType, PointType } from '@/types/common/DisasterType.ts';
import { onBeforeMount } from 'vue';
import { onBeforeMount, watch, provide } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
@@ -87,6 +91,10 @@
const statusStore = useStatusStore();
// 在父组件中创建 useAroundAnalysis 实例并通过 provide 提供给子组件
const aroundAnalysisState = useAroundAnalysis();
provide<AroundAnalysisState>('aroundAnalysisState', aroundAnalysisState);
const {
selectOptions,
tableColumns,
@@ -97,6 +105,7 @@
changeCurrentPage,
setSelectOptions,
setTableColumns,
setTableDatas,
} = useDisasterChainTable();
onBeforeMount(() => {
@@ -104,8 +113,9 @@
setSelectOptions([
{ value: PointType.LANDSLIDE, label: '滑坡' },
{ value: PointType.DEBRIS_FLOW, label: '泥石流' },
{ value: PointType.FLASH_FLOOD, label: '山洪' },
{ value: PointType.WATER_LOGGING, label: '内涝' },
{ value: PointType.FLASH_FLOOD, label: '山洪' },
{ value: PointType.COLLAPSE, label: '崩塌' },
]);
// 设置表格列配置
@@ -124,6 +134,46 @@
setConditions(value);
};
});
// 监听脉冲点变化并更新表格数据
watch(
() => aroundAnalysisState.pulsePoints.value,
(newPulsePoints: PointResource[]) => {
console.log('=== 脉冲点变化 ===');
console.log('newPulsePoints:', newPulsePoints);
console.log('newPulsePoints.length:', newPulsePoints?.length);
if (newPulsePoints && newPulsePoints.length > 0) {
// 将 PointResource 转换为 XianHiddenDangerSpots 格式
const convertedData: XianHiddenDangerSpots[] = newPulsePoints.map(point => ({
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,
}));
console.log('convertedData:', convertedData);
setTableDatas(convertedData);
} else {
// 如果没有脉冲点,则清空表格数据
console.log('清空表格数据');
setTableDatas([]);
}
},
{ immediate: true, deep: true }
);
</script>
<style scoped></style>
<style scoped></style>