Files
xian_vue_new/src/hooks/rainstorm/useRainDisasterChain.ts
T

422 lines
12 KiB
TypeScript
Raw Normal View History

2026-04-23 15:56:59 +08:00
import { ref, watch } from 'vue';
2026-04-13 20:55:32 +08:00
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
import type { PaginationType } from '@/types/common/PaginationType';
2026-04-14 08:08:01 +08:00
import { PointType } from '@/types/common/DisasterType';
2026-05-04 21:51:58 +08:00
import { ControlPanelCategory } from '@/types/common/ControlPanelCategory';
import { useStatusStore } from '@/stores/useStatusStore';
2026-04-16 09:09:00 +08:00
import {
debrisFlowIcon,
flashFloodIcon,
landslideIcon,
riskAreaIcon,
waterLoggingIcon,
2026-04-28 10:22:40 +08:00
hospitalIcon,
dangerousSourceIcon,
emergencyShelterIcon,
firefighterIcon,
storePointsIcon,
schoolIcon,
bridgeIcon,
reservoirIcon,
subwayIcon,
2026-04-16 09:09:00 +08:00
} from '@/assets';
import { useLayerControl } from '../rain-earthquake/useLayerControl.ts';
import { useRightHandle } from '../rain-earthquake/useRightHandle.ts';
import { useLeftHandle } from '../rain-earthquake/useLeftHandle.ts';
2026-05-04 22:29:53 +08:00
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore.ts';
import { LoadingResource } from '@/types/common/LoadingResourceType.ts';
2026-04-13 20:55:32 +08:00
/**
2026-04-16 09:09:00 +08:00
* 暴雨灾害链
* @returns
*/
export const useRainDisasterChain = () => {
2026-04-16 09:09:00 +08:00
// ================灾害链影响点列表================================
/**
* 搜索条件
*/
2026-04-13 20:55:32 +08:00
const conditions = ref({
tableData: '',
2026-04-14 08:08:01 +08:00
hiddenPoint: PointType.LANDSLIDE,
2026-04-13 20:55:32 +08:00
});
/**
* 下拉选项
*/
2026-04-23 09:27:59 +08:00
const selectOptions = ref([
2026-04-14 08:08:01 +08:00
{ value: PointType.LANDSLIDE, label: '滑坡' },
{ value: PointType.DEBRIS_FLOW, label: '泥石流' },
{ value: PointType.FLASH_FLOOD, label: '山洪' },
{ value: PointType.WATER_LOGGING, label: '内涝' },
2026-04-23 09:27:59 +08:00
]);
2026-04-13 20:55:32 +08:00
/**
* 表格数据
*/
2026-04-13 20:55:32 +08:00
const tableDatas = ref<XianHiddenDangerSpots[]>([]);
/**
* 表头配置
*/
2026-04-23 09:27:59 +08:00
const tableColumns = ref([
2026-04-13 20:55:32 +08:00
{ title: '名称', key: 'disasterName' },
{ title: '位置', key: 'position' },
{ title: '规模等级', key: 'scaleGrade' },
{ title: '险情等级', key: 'riskGrade' },
2026-04-23 09:27:59 +08:00
]);
2026-04-13 20:55:32 +08:00
/**
* 分页配置
*/
2026-04-13 20:55:32 +08:00
const paginationConfig = ref<PaginationType>({
currentPage: 1,
pageSize: 10,
total: 10,
totalPage: 1,
});
/**
* 修改搜索条件
* @param value - 新的搜索条件
*/
2026-04-14 16:00:39 +08:00
const changeConditions = (value: {
2026-04-13 20:55:32 +08:00
tableData: string;
2026-04-14 08:08:01 +08:00
hiddenPoint: PointType;
2026-04-14 16:00:39 +08:00
}): void => {
2026-04-13 20:55:32 +08:00
conditions.value = value;
2026-04-14 16:00:39 +08:00
};
2026-04-13 20:55:32 +08:00
/**
* 修改页码
* @param value - 新的页码
*/
2026-04-14 16:00:39 +08:00
const changeCurrentPage = (value: number) => {
2026-04-13 20:55:32 +08:00
paginationConfig.value.currentPage = value;
2026-04-14 16:00:39 +08:00
};
2026-04-16 09:09:00 +08:00
// ================左侧按钮================================
2026-04-14 16:00:39 +08:00
/**
* 左侧按钮信息
*/
const leftButtonInfo = [
{
name: '周边分析',
callback: useLeftHandle().clickAroundAnalysis,
2026-04-14 16:00:39 +08:00
},
{
name: '关联分析',
callback: () => {
console.log('关联分析');
},
},
{
name: '次生衍生灾害链分析',
callback: () => {
console.log('次生衍生灾害链分析');
},
},
{
name: '历史相似性分析',
callback: () => {
console.log('历史相似性分析');
},
},
{
name: '灾害链模型库测试',
callback: () => {
console.log('灾害链模型库测试');
},
},
{
name: '承灾体信息提取',
callback: () => {
console.log('承灾体信息提取');
},
},
{
name: '暴雨内涝灾害链(50mm)',
callback: () => {
console.log('暴雨内涝灾害链(50mm)');
},
},
{
name: '暴雨滑坡灾害链(80mm)',
callback: () => {
console.log('暴雨滑坡灾害链(80mm)');
},
},
{
name: '暴雨洪涝灾害链(100mm)',
callback: () => {
console.log('暴雨洪涝灾害链(100mm)');
},
},
{
name: '暴雨山洪灾害链(110mm)',
callback: () => {
console.log('暴雨山洪灾害链(110mm)');
},
},
];
2026-04-13 20:55:32 +08:00
2026-04-16 09:09:00 +08:00
// ================右侧按钮================================
2026-04-14 16:33:23 +08:00
/**
* 右侧按钮信息
*/
const rightButtonInfo = [
2026-04-28 16:41:24 +08:00
{
name: '暴雨模拟',
2026-05-05 17:09:32 +08:00
callback: (status: unknown) =>
useRightHandle().rainstormSimulation(status),
2026-04-28 16:41:24 +08:00
selected: true,
},
2026-04-14 16:33:23 +08:00
{
name: '暴雨触发',
2026-04-14 16:33:23 +08:00
callback: () => {
console.log('暴雨触发');
2026-04-14 16:33:23 +08:00
},
},
{
name: '图件下载',
callback: () => {
console.log('图件下载');
},
},
{
name: '雷达云图',
callback: () => {
console.log('雷达云图');
},
},
{
name: '场景重置',
2026-04-18 17:34:46 +08:00
callback: () => useRightHandle().resetScene(),
2026-04-14 16:33:23 +08:00
executeOnce: true,
},
{
name: '视角重置',
2026-04-18 17:34:46 +08:00
callback: () => useRightHandle().resetView(),
2026-04-14 16:33:23 +08:00
executeOnce: true,
},
];
2026-04-16 09:09:00 +08:00
// ================控制面板================================
/**
* 控制面板信息
*/
/**
* 控制面板信息
*/
const getControlPanel = () => {
const statusStore = useStatusStore();
const layerControl = useLayerControl();
2026-05-04 22:29:53 +08:00
const resourceStore = useLoadingResourceStore();
return [
2026-05-04 21:46:36 +08:00
// 灾害隐患点类别
2026-04-28 10:05:49 +08:00
{
2026-05-04 22:05:03 +08:00
name: '滑坡隐患点',
2026-04-28 10:05:49 +08:00
statusStore: statusStore.poiLayers,
statusKey: 'showLandslideHiddenPoint' as const,
callback: layerControl.clickLandslideHiddenPoint,
2026-05-04 21:46:36 +08:00
link: landslideIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.DISASTER_HAZARD,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(
LoadingResource.LANDSLIDE_HIDDEN_POINT
),
2026-04-28 10:05:49 +08:00
},
{
2026-05-04 22:05:03 +08:00
name: '泥石流隐患点',
2026-04-28 10:05:49 +08:00
statusStore: statusStore.poiLayers,
statusKey: 'showDebrisFlowHiddenPoint' as const,
callback: layerControl.clickDebrisFlowHiddenPoint,
2026-05-04 21:46:36 +08:00
link: debrisFlowIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.DISASTER_HAZARD,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(
LoadingResource.DEBRIS_FLOW_HIDDEN_POINT
),
2026-04-28 10:05:49 +08:00
},
{
2026-05-04 22:05:03 +08:00
name: '内涝隐患点',
2026-04-28 10:05:49 +08:00
statusStore: statusStore.poiLayers,
statusKey: 'showWaterLoggingHiddenPoint' as const,
callback: layerControl.clickWaterLoggingHiddenPoint,
2026-05-04 21:46:36 +08:00
link: waterLoggingIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.DISASTER_HAZARD,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(
LoadingResource.WATER_LOGGING_HIDDEN_POINT
),
2026-04-28 10:05:49 +08:00
},
{
2026-05-04 22:05:03 +08:00
name: '山洪隐患点',
2026-04-28 10:05:49 +08:00
statusStore: statusStore.poiLayers,
statusKey: 'showFlashFloodHiddenPoint' as const,
callback: layerControl.clickFlashFloodHiddenPoint,
2026-05-04 21:46:36 +08:00
link: flashFloodIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.DISASTER_HAZARD,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(
LoadingResource.FLASH_FLOOD_HIDDEN_POINT
),
2026-04-28 10:05:49 +08:00
},
{
2026-05-04 22:05:03 +08:00
name: '风险点',
2026-04-28 10:05:49 +08:00
statusStore: statusStore.mapLayers,
statusKey: 'riskPointShow' as const,
callback: layerControl.clickRiskPoint,
2026-05-04 21:46:36 +08:00
link: riskAreaIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.DISASTER_HAZARD,
2026-05-04 22:29:53 +08:00
count: () => resourceStore.getResourceCount(LoadingResource.RISK_POINT),
2026-04-28 10:05:49 +08:00
},
2026-05-04 21:46:36 +08:00
// 基础设施类别
{
2026-05-04 22:05:03 +08:00
name: '医院',
statusStore: statusStore.poiLayers,
statusKey: 'showHospital' as const,
callback: layerControl.clickHospital,
2026-05-04 21:46:36 +08:00
link: hospitalIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-04 22:29:53 +08:00
count: () => resourceStore.getResourceCount(LoadingResource.HOSPITAL),
},
{
2026-05-04 22:05:03 +08:00
name: '危险源',
statusStore: statusStore.poiLayers,
statusKey: 'showDangerSource' as const,
2026-04-18 19:03:06 +08:00
callback: layerControl.clickDangerousSource,
2026-05-04 21:46:36 +08:00
link: dangerousSourceIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(LoadingResource.DANGEROUS_SOURCE),
},
{
2026-05-04 22:05:03 +08:00
name: '避难所',
statusStore: statusStore.poiLayers,
statusKey: 'showRefugeeShelter' as const,
2026-04-18 20:10:54 +08:00
callback: layerControl.clickEmergencyShelter,
2026-05-04 21:46:36 +08:00
link: emergencyShelterIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(LoadingResource.EMERGENCY_SHELTER),
},
{
2026-05-04 22:05:03 +08:00
name: '消防站',
statusStore: statusStore.poiLayers,
statusKey: 'showFireStation' as const,
2026-04-18 20:48:01 +08:00
callback: layerControl.clickFireStation,
2026-05-04 21:46:36 +08:00
link: firefighterIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(LoadingResource.FIRE_STATION),
},
{
2026-05-04 22:05:03 +08:00
name: '储备点',
statusStore: statusStore.poiLayers,
statusKey: 'showReservePoint' as const,
2026-04-18 22:35:49 +08:00
callback: layerControl.clickStorePoints,
2026-05-04 21:46:36 +08:00
link: storePointsIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(LoadingResource.STORE_POINTS),
},
{
2026-05-04 22:05:03 +08:00
name: '学校',
statusStore: statusStore.poiLayers,
statusKey: 'showSchool' as const,
2026-04-21 20:56:25 +08:00
callback: layerControl.clickSchool,
2026-05-04 21:46:36 +08:00
link: schoolIcon,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-04 22:29:53 +08:00
count: () => resourceStore.getResourceCount(LoadingResource.SCHOOL),
},
{
2026-05-04 22:05:03 +08:00
name: '桥梁',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showBridge' as const,
callback: layerControl.clickBridge,
link: bridgeIcon,
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-04 22:29:53 +08:00
count: () => resourceStore.getResourceCount(LoadingResource.BRIDGE),
2026-05-04 22:05:03 +08:00
},
{
name: '水库',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showReservoir' as const,
callback: layerControl.clickReservoir,
link: reservoirIcon,
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-04 22:29:53 +08:00
count: () => resourceStore.getResourceCount(LoadingResource.RESERVOIR),
2026-05-04 22:05:03 +08:00
},
{
name: '地铁站',
statusStore: statusStore.poiLayers,
statusKey: 'showSubwayStation' as const,
callback: layerControl.clickSubwayStation,
link: subwayIcon,
category: ControlPanelCategory.INFRASTRUCTURE,
2026-05-05 17:09:32 +08:00
count: () =>
resourceStore.getResourceCount(LoadingResource.SUBWAY_STATION),
2026-05-04 22:05:03 +08:00
},
{
name: '人口网格',
statusStore: statusStore.poiLayers,
statusKey: 'showPopulationGrid' as const,
2026-04-21 15:49:56 +08:00
callback: layerControl.clickPopulationGrid,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
},
{
2026-05-04 22:05:03 +08:00
name: '管网系统',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showNetworkSystem' as const,
2026-04-21 16:05:26 +08:00
callback: layerControl.clickWaterPipe,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
},
{
2026-05-04 22:05:03 +08:00
name: '交通道路',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showTrafficRoad' as const,
2026-04-24 20:41:41 +08:00
callback: layerControl.clickTrafficRoad,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
},
2026-05-04 22:05:03 +08:00
{
2026-05-04 22:05:03 +08:00
name: '高速',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showHighway' as const,
2026-04-25 21:05:59 +08:00
callback: layerControl.clickHighway,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
},
{
2026-05-04 22:05:03 +08:00
name: '国道',
statusStore: statusStore.infrastructureLayers,
statusKey: 'showMainRoad' as const,
2026-04-25 21:05:59 +08:00
callback: layerControl.clickNationRoad,
2026-05-04 21:51:58 +08:00
category: ControlPanelCategory.INFRASTRUCTURE,
},
];
};
2026-04-23 15:56:59 +08:00
// 监听条件变化
watch(
conditions,
() => {
console.log('条件改变');
},
{ deep: true }
);
2026-04-13 20:55:32 +08:00
return {
conditions,
selectOptions,
tableDatas,
tableColumns,
paginationConfig,
2026-04-14 16:00:39 +08:00
leftButtonInfo,
2026-04-14 16:33:23 +08:00
rightButtonInfo,
2026-04-13 20:55:32 +08:00
changeConditions,
changeCurrentPage,
controlPanel: getControlPanel(),
2026-04-13 20:55:32 +08:00
};
};