179 lines
5.1 KiB
JavaScript
179 lines
5.1 KiB
JavaScript
import { ref, computed } from 'vue'
|
||
|
||
/**
|
||
* 灾害数据状态管理
|
||
*/
|
||
export function useDisasterData() {
|
||
// 灾害基本信息
|
||
const disasterInfo = ref({
|
||
type: '边坡垮塌',
|
||
volume: '10022',
|
||
volumeUnit: 'm³',
|
||
length: '13',
|
||
lengthUnit: 'm',
|
||
width: '5',
|
||
widthUnit: 'm',
|
||
casualties: '0',
|
||
vehicles: '0',
|
||
location: '巴南G348武大线三峭湾'
|
||
})
|
||
|
||
// 力量预置信息
|
||
const forcePreset = ref({
|
||
equipment: 0,
|
||
bases: 0,
|
||
personnel: 0,
|
||
searchRadius: 30, // km
|
||
stations: [
|
||
{
|
||
id: 1,
|
||
name: '大进养护站',
|
||
distance: 8,
|
||
type: 'maintenance'
|
||
},
|
||
{
|
||
id: 2,
|
||
name: '郭家养护站',
|
||
distance: 8,
|
||
type: 'maintenance'
|
||
}
|
||
]
|
||
})
|
||
|
||
// 力量调度信息
|
||
const forceDispatch = ref({
|
||
responseLevel: 3, // 三级
|
||
estimatedClearTime: '2025/10/21 22:00',
|
||
plan: {
|
||
name: '智能应急方案',
|
||
status: 'ready'
|
||
}
|
||
})
|
||
|
||
// 协同信息
|
||
const collaborationInfo = ref([
|
||
{
|
||
id: 1,
|
||
source: '气象预警',
|
||
content:
|
||
'巫溪县气象台2025年10月17日12时30分升级发布"暴雨黄色预警信号",过去6小时,文峰、红池坝、天元、长桂等乡镇累计降雨量已达70毫米以上。',
|
||
timestamp: '2025-10-17 12:30'
|
||
},
|
||
{
|
||
id: 2,
|
||
source: '公安部门',
|
||
content: '对巴南G348武大线三峭湾进行交通管制。',
|
||
timestamp: '2025-10-17 13:00'
|
||
},
|
||
{
|
||
id: 3,
|
||
source: '融媒体中心',
|
||
content:
|
||
'发布了阻断信息:巴南G348武大线三湾于6月28日发生山体滑坡,边坡有继续垮塌风险,需断道观察,车辆从桥口坝绕行金田村,预计2025年10月17日18时30分恢复通行。',
|
||
timestamp: '2025-10-17 14:30'
|
||
}
|
||
])
|
||
|
||
// 调度力量建议(根据力量预置数据动态计算)
|
||
const dispatchSuggestion = computed(() => {
|
||
// 根据实际资源计算建议调度力量
|
||
const stationsCount = forcePreset.value.stations?.length || 0
|
||
|
||
return {
|
||
// 应急物资建议数:基于装备数量
|
||
supplies: forcePreset.value.equipment,
|
||
|
||
// 应急人员建议数:取总人员的一部分(约5-10%)作为调度建议
|
||
personnel: Math.min(Math.ceil(forcePreset.value.personnel * 0.06), forcePreset.value.personnel),
|
||
|
||
// 养护站建议数:使用实际可用养护站数量
|
||
stations: stationsCount,
|
||
|
||
// 挖掘机建议数:每2个养护站配置1台挖掘机
|
||
excavators: Math.max(1, Math.ceil(stationsCount / 2)),
|
||
|
||
// 阻断信息:固定建议
|
||
blockInfo: '需发布',
|
||
|
||
// 交通管制:固定建议
|
||
trafficControl: '需要'
|
||
}
|
||
})
|
||
|
||
// 计算属性
|
||
const totalResources = computed(() => {
|
||
return (
|
||
forcePreset.value.equipment +
|
||
forcePreset.value.bases +
|
||
forcePreset.value.personnel
|
||
)
|
||
})
|
||
|
||
/**
|
||
* 更新搜索半径
|
||
* @param {number} radius - 新的搜索半径(km)
|
||
*/
|
||
const updateSearchRadius = (radius) => {
|
||
if (typeof radius === 'number' && radius > 0) {
|
||
forcePreset.value.searchRadius = radius
|
||
console.log(`[useDisasterData] 搜索半径已更新为: ${radius}km`)
|
||
} else {
|
||
console.warn('[useDisasterData] 无效的搜索半径值:', radius)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 更新力量预置数据
|
||
* @param {Object} emergencyResourcesData - 接口返回的应急资源数据
|
||
* @param {number} emergencyResourcesData.equipmentCount - 应急装备数量
|
||
* @param {number} emergencyResourcesData.personnelCount - 应急人员数量
|
||
* @param {Array} emergencyResourcesData.stations - 养护站列表
|
||
* @param {string} emergencyResourcesData.stations[].stationId - 养护站ID
|
||
* @param {string} emergencyResourcesData.stations[].stationName - 养护站名称
|
||
* @param {number} emergencyResourcesData.stations[].distance - 距离(km)
|
||
*/
|
||
const updateForcePreset = (emergencyResourcesData) => {
|
||
if (!emergencyResourcesData) {
|
||
console.warn('[useDisasterData] 应急资源数据为空,跳过更新')
|
||
return
|
||
}
|
||
|
||
const { equipmentCount, personnelCount, stations } = emergencyResourcesData
|
||
|
||
// 更新装备和人员数量
|
||
if (typeof equipmentCount === 'number') {
|
||
forcePreset.value.equipment = equipmentCount
|
||
}
|
||
if (typeof personnelCount === 'number') {
|
||
forcePreset.value.personnel = personnelCount
|
||
}
|
||
|
||
// 更新养护站列表
|
||
if (Array.isArray(stations)) {
|
||
// 根据养护站列表更新应急基地数
|
||
forcePreset.value.bases = stations.length
|
||
forcePreset.value.stations = stations.map((station) => ({
|
||
id: station.stationId,
|
||
name: station.stationName?.trim() || '未命名养护站',
|
||
distance: typeof station.distance === 'number'
|
||
? Number(station.distance.toFixed(2))
|
||
: 0,
|
||
type: 'maintenance'
|
||
}))
|
||
}
|
||
|
||
console.log('[useDisasterData] 力量预置数据已更新:', forcePreset.value)
|
||
}
|
||
|
||
return {
|
||
disasterInfo,
|
||
forcePreset,
|
||
forceDispatch,
|
||
collaborationInfo,
|
||
dispatchSuggestion,
|
||
totalResources,
|
||
updateForcePreset,
|
||
updateSearchRadius
|
||
}
|
||
}
|