fix(storage-menu): 更新存储菜单项的显示逻辑,确保根据状态动态渲染操作项
This commit is contained in:
parent
093b48d714
commit
303e5d513f
@ -51,36 +51,36 @@
|
|||||||
<div class="sub-menu-title">{{ selectedLocation.name }} - 操作</div>
|
<div class="sub-menu-title">{{ selectedLocation.name }} - 操作</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-menu-actions">
|
<div class="sub-menu-actions">
|
||||||
<div class="menu-item" @click="handleStorageAction('occupy', '占用')">
|
<div v-if="!selectedLocation.isOccupied" class="menu-item" @click="handleStorageAction('occupy', '占用')">
|
||||||
<span class="action-icon">📦</span>
|
|
||||||
<span>占用</span>
|
<span>占用</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('release', '释放')">
|
<div v-if="selectedLocation.isOccupied" class="menu-item" @click="handleStorageAction('release', '释放')">
|
||||||
<span class="action-icon">📤</span>
|
|
||||||
<span>释放</span>
|
<span>释放</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('lock', '锁定')">
|
<div v-if="!selectedLocation.isLocked" class="menu-item" @click="handleStorageAction('lock', '锁定')">
|
||||||
<span class="action-icon">🔒</span>
|
|
||||||
<span>锁定</span>
|
<span>锁定</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('unlock', '解锁')">
|
<div v-if="selectedLocation.isLocked" class="menu-item" @click="handleStorageAction('unlock', '解锁')">
|
||||||
<span class="action-icon">🔓</span>
|
|
||||||
<span>解锁</span>
|
<span>解锁</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('enable', '启用')">
|
<div v-if="selectedLocation.isDisabled" class="menu-item" @click="handleStorageAction('enable', '启用')">
|
||||||
<span class="action-icon">✅</span>
|
|
||||||
<span>启用</span>
|
<span>启用</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('disable', '禁用')">
|
<div v-if="!selectedLocation.isDisabled" class="menu-item" @click="handleStorageAction('disable', '禁用')">
|
||||||
<span class="action-icon">❌</span>
|
|
||||||
<span>禁用</span>
|
<span>禁用</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('set_empty_tray', '设为空托盘')">
|
<div
|
||||||
<span class="action-icon">📋</span>
|
v-if="!selectedLocation.isEmptyTray"
|
||||||
|
class="menu-item"
|
||||||
|
@click="handleStorageAction('set_empty_tray', '设为空托盘')"
|
||||||
|
>
|
||||||
<span>设为空托盘</span>
|
<span>设为空托盘</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu-item" @click="handleStorageAction('clear_empty_tray', '清除空托盘')">
|
<div
|
||||||
<span class="action-icon">🗑️</span>
|
v-if="selectedLocation.isEmptyTray"
|
||||||
|
class="menu-item"
|
||||||
|
@click="handleStorageAction('clear_empty_tray', '清除空托盘')"
|
||||||
|
>
|
||||||
<span>清除空托盘</span>
|
<span>清除空托盘</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -66,8 +66,10 @@ export function getMenuConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'area':
|
case 'area':
|
||||||
// 区域类型
|
// 区域类型 - 根据要求,不显示菜单
|
||||||
return getAreaMenuConfig(data);
|
return {
|
||||||
|
menuType: 'default' as const,
|
||||||
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// 对于默认情况,我们不希望显示任何菜单,
|
// 对于默认情况,我们不希望显示任何菜单,
|
||||||
@ -78,30 +80,6 @@ export function getMenuConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取区域菜单配置
|
|
||||||
* @param data 事件数据
|
|
||||||
* @returns 区域菜单配置
|
|
||||||
*/
|
|
||||||
function getAreaMenuConfig(data: ParsedEventData): AreaMenuConfig {
|
|
||||||
console.log(`处理区域类型,区域ID: ${data.id}`);
|
|
||||||
|
|
||||||
if (data.id && data.name) {
|
|
||||||
return {
|
|
||||||
menuType: 'area' as const,
|
|
||||||
areaInfo: {
|
|
||||||
id: data.id,
|
|
||||||
name: data.name,
|
|
||||||
type: '区域',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
menuType: 'default' as const,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理右键菜单的核心逻辑 - 统一处理函数
|
* 处理右键菜单的核心逻辑 - 统一处理函数
|
||||||
* @param parsedData 解析后的事件数据
|
* @param parsedData 解析后的事件数据
|
||||||
|
|||||||
@ -99,8 +99,8 @@ const DEFAULT_STORAGE_CONFIG: StorageLocationConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 提供给绘制层快速查询的全局状态映射:pointId -> (layerName -> { occupied, locked, disabled })
|
// 提供给绘制层快速查询的全局状态映射:pointId -> (layerName -> { occupied, locked, disabled, isEmptyTray })
|
||||||
export type StorageState = { occupied?: boolean; locked?: boolean; disabled?: boolean };
|
export type StorageState = { occupied?: boolean; locked?: boolean; disabled?: boolean; isEmptyTray?: boolean };
|
||||||
export const storageStateMap = reactive(new Map<string, Map<string, StorageState>>());
|
export const storageStateMap = reactive(new Map<string, Map<string, StorageState>>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -310,7 +310,8 @@ export class StorageLocationService {
|
|||||||
!currentLocation ||
|
!currentLocation ||
|
||||||
currentLocation.is_occupied !== newLocation.is_occupied ||
|
currentLocation.is_occupied !== newLocation.is_occupied ||
|
||||||
currentLocation.is_locked !== newLocation.is_locked ||
|
currentLocation.is_locked !== newLocation.is_locked ||
|
||||||
currentLocation.is_disabled !== newLocation.is_disabled
|
currentLocation.is_disabled !== newLocation.is_disabled ||
|
||||||
|
currentLocation.is_empty_tray !== newLocation.is_empty_tray
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -344,7 +345,8 @@ export class StorageLocationService {
|
|||||||
!currentLocation ||
|
!currentLocation ||
|
||||||
currentLocation.is_occupied !== newLocation.is_occupied ||
|
currentLocation.is_occupied !== newLocation.is_occupied ||
|
||||||
currentLocation.is_locked !== newLocation.is_locked ||
|
currentLocation.is_locked !== newLocation.is_locked ||
|
||||||
currentLocation.is_disabled !== newLocation.is_disabled
|
currentLocation.is_disabled !== newLocation.is_disabled ||
|
||||||
|
currentLocation.is_empty_tray !== newLocation.is_empty_tray
|
||||||
) {
|
) {
|
||||||
changedPointIds.add(pointId);
|
changedPointIds.add(pointId);
|
||||||
break;
|
break;
|
||||||
@ -397,6 +399,7 @@ export class StorageLocationService {
|
|||||||
occupied: loc.is_occupied,
|
occupied: loc.is_occupied,
|
||||||
locked: loc.is_locked,
|
locked: loc.is_locked,
|
||||||
disabled: loc.is_disabled,
|
disabled: loc.is_disabled,
|
||||||
|
isEmptyTray: loc.is_empty_tray,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
storageStateMap.set(pointId, inner);
|
storageStateMap.set(pointId, inner);
|
||||||
@ -448,6 +451,7 @@ export class StorageLocationService {
|
|||||||
occupied: new_status.is_occupied,
|
occupied: new_status.is_occupied,
|
||||||
locked: new_status.is_locked,
|
locked: new_status.is_locked,
|
||||||
disabled: new_status.is_disabled,
|
disabled: new_status.is_disabled,
|
||||||
|
isEmptyTray: new_status.is_empty_tray,
|
||||||
});
|
});
|
||||||
storageStateMap.set(pointId, inner);
|
storageStateMap.set(pointId, inner);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user