第二步:将隐患预警点分类显示数据(无风险点)
This commit is contained in:
@@ -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,21 +140,45 @@
|
||||
};
|
||||
});
|
||||
|
||||
// 监听脉冲点变化并更新表格数据
|
||||
// 监听脉冲点变化和下拉选项变化,过滤并更新表格数据
|
||||
watch(
|
||||
[
|
||||
() => aroundAnalysisState.pulsePoints.value,
|
||||
(newPulsePoints: PointResource[]) => {
|
||||
() => 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),
|
||||
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
|
||||
position:
|
||||
point.lon !== undefined && point.lat !== undefined
|
||||
? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}`
|
||||
: '未知位置',
|
||||
scaleGrade: String(point.scale_grade || '未知'),
|
||||
@@ -162,7 +191,8 @@
|
||||
county: '',
|
||||
village: '',
|
||||
isDelete: 0,
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
console.log('convertedData:', convertedData);
|
||||
setTableDatas(convertedData);
|
||||
|
||||
Reference in New Issue
Block a user