第三步:风险点分类显示
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
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 {
|
||||
useDisasterChainTable,
|
||||
type SearchConditions,
|
||||
@@ -127,9 +128,10 @@
|
||||
{ value: PointType.WATER_LOGGING, label: '内涝' },
|
||||
{ value: PointType.FLASH_FLOOD, label: '山洪' },
|
||||
{ value: PointType.COLLAPSE, label: '崩塌' },
|
||||
{ value: PointType.RISK_AREA, label: '风险区' },
|
||||
]);
|
||||
|
||||
// 设置表格列配置
|
||||
// 设置表格列配置(默认显示隐患点的列)
|
||||
setTableColumns([
|
||||
{ title: '名称', key: 'disasterName' },
|
||||
{ title: '位置', key: 'position' },
|
||||
@@ -143,6 +145,24 @@
|
||||
*/
|
||||
changeConditions.value = (value: SearchConditions) => {
|
||||
setConditions(value);
|
||||
|
||||
// 根据选择的类型动态改变表格列
|
||||
if (value.hiddenPoint === PointType.RISK_AREA) {
|
||||
// 风险区:只显示风险区等级
|
||||
setTableColumns([
|
||||
{ title: '名称', key: 'disasterName' },
|
||||
{ title: '位置', key: 'position' },
|
||||
{ title: '风险区等级', key: 'riskLevel' },
|
||||
]);
|
||||
} else {
|
||||
// 隐患点:显示规模等级和险情等级
|
||||
setTableColumns([
|
||||
{ title: '名称', key: 'disasterName' },
|
||||
{ title: '位置', key: 'position' },
|
||||
{ title: '规模等级', key: 'scaleGrade' },
|
||||
{ title: '险情等级', key: 'riskGrade' },
|
||||
]);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -174,31 +194,51 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
// 将 PointResource 转换为 XianHiddenDangerSpots 格式
|
||||
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,
|
||||
})
|
||||
);
|
||||
// 根据类型转换数据
|
||||
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 {
|
||||
// 隐患点数据
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user