feat: 在运动监控页面中新增多楼层场景支持,优化场景加载和楼层切换逻辑

This commit is contained in:
xudan 2025-10-10 15:20:08 +08:00
parent b1d8806a59
commit 10c3af9477

View File

@ -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>