feat: 在运动监控页面中新增多楼层场景支持,优化场景加载和楼层切换逻辑
This commit is contained in:
parent
b1d8806a59
commit
10c3af9477
@ -44,6 +44,13 @@ const isMonitorMode = computed(() => route.path.includes('/monitor'));
|
||||
|
||||
// 场景标题
|
||||
const title = ref<string>('');
|
||||
// 新增:用于存储多楼层场景数据的数组
|
||||
const floorScenes = ref<any[]>([]);
|
||||
// 新增:当前楼层的索引
|
||||
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<boolean>(true);
|
||||
|
||||
@ -589,6 +619,17 @@ const handleGlobalKeydown = (event: KeyboardEvent) => {
|
||||
<a-button type="primary" :loading="isSaving" @click="handleSaveViewState"> 保存比例 </a-button>
|
||||
<a-divider type="vertical" />
|
||||
|
||||
<a-select
|
||||
v-if="isMultiFloor"
|
||||
v-model:value="currentFloorIndex"
|
||||
style="width: 120px"
|
||||
@change="handleFloorChange"
|
||||
>
|
||||
<a-select-option v-for="(scene, index) in floorScenes" :key="index" :value="index">
|
||||
楼层 {{ index + 1 }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
|
||||
<a-date-picker v-if="isPlaybackMode" v-model:value="selectedDate" placeholder="请选择回放日期" />
|
||||
</a-space>
|
||||
</a-flex>
|
||||
|
Loading…
x
Reference in New Issue
Block a user