diff --git a/src/pages/movement-supervision.vue b/src/pages/movement-supervision.vue index 42cbd89..dec29a4 100644 --- a/src/pages/movement-supervision.vue +++ b/src/pages/movement-supervision.vue @@ -44,6 +44,13 @@ const isMonitorMode = computed(() => route.path.includes('/monitor')); // 场景标题 const title = ref(''); +// 新增:用于存储多楼层场景数据的数组 +const floorScenes = ref([]); +// 新增:当前楼层的索引 +const currentFloorIndex = ref(0); + +// 新增:判断是否为多楼层模式 +const isMultiFloor = computed(() => floorScenes.value.length > 1); const modeTitle = computed(() => { if (isPlaybackMode.value) { @@ -145,7 +152,19 @@ provide(EDITOR_KEY, editor); const readScene = async () => { const res = props.id ? await getSceneByGroupId(props.id, props.sid) : await getSceneById(props.sid); title.value = res?.label ?? ''; - editor.value?.load(res?.json); + + // 检查返回的json是数组(多楼层)还是对象(单楼层) + if (Array.isArray(res?.json)) { + // 多楼层 + floorScenes.value = res.json; + currentFloorIndex.value = 0; // 默认显示第一层 + editor.value?.load(floorScenes.value[0]); + } else if (res?.json) { + // 单楼层,包装成数组以统一处理 + floorScenes.value = [res.json]; + currentFloorIndex.value = 0; + editor.value?.load(res.json); + } }; /** @@ -485,6 +504,17 @@ const handleAutoSaveAndRestoreViewState = async () => { }; //#endregion +//#region 楼层切换 +const handleFloorChange = async (value: any) => { + const newFloorIndex = value as number; + if (editor.value && floorScenes.value[newFloorIndex]) { + await editor.value.load(floorScenes.value[newFloorIndex]); + // 切换楼层后,重新初始化机器人以确保状态正确 + await editor.value.initRobots(); + } +}; +//#endregion + //#region UI状态管理 const show = ref(true); @@ -589,6 +619,17 @@ const handleGlobalKeydown = (event: KeyboardEvent) => { 保存比例 + + + 楼层 {{ index + 1 }} + + +