diff --git a/src/views/home/rainstorm/RainstormView.vue b/src/views/home/rainstorm/RainstormView.vue index 670ed91..75d291c 100644 --- a/src/views/home/rainstorm/RainstormView.vue +++ b/src/views/home/rainstorm/RainstormView.vue @@ -80,7 +80,11 @@ type SearchConditions, } from '@/hooks/useDisasterChainTable'; import { useStatusStore } from '@/stores/useStatusStore'; - import { DisasterType, PointType } from '@/types/common/DisasterType.ts'; + import { + DisasterType, + PointType, + HiddenDangerPointTypeMap, + } from '@/types/common/DisasterType.ts'; import { onBeforeMount, watch, provide } from 'vue'; import { useRoute } from 'vue-router'; @@ -100,6 +104,7 @@ tableColumns, tableDatas, paginationConfig, + conditions, changeConditions, setConditions, changeCurrentPage, @@ -135,34 +140,59 @@ }; }); - // 监听脉冲点变化并更新表格数据 + // 监听脉冲点变化和下拉选项变化,过滤并更新表格数据 watch( - () => aroundAnalysisState.pulsePoints.value, - (newPulsePoints: PointResource[]) => { + [ + () => 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); 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; + }); + // 将 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, - })); + const convertedData: XianHiddenDangerSpots[] = filteredPoints.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);