wujingjing
2025-02-10 e50196bff10f0196307b2567ed6c0829eadd8ff6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
    <div class="h-[60vh] relative">
        <!-- 原始地图容器 -->
        <BasicMap
            ref="normalMapRef"
            v-show="!isFullscreen"
            :isFullscreen="false"
            class="h-full"
            :data="data"
            @markerClick="markerClick"
            @closeInfoWindow="closeInfoWindow"
            @toggleFullScreen="toggleFullScreen"
            
        />
        <!-- 全屏按钮 -->
        <!-- <div class="absolute right-2 top-2 cursor-pointer" @click="toggleFullScreen">
            <el-tooltip content="全屏展开" placement="top">
                <div class="ywifont !text-[20px] text-black rounded-lg ywicon-fullscreen"></div>
            </el-tooltip>
        </div> -->
 
        <!-- Teleport 全屏地图 -->
        <Teleport to=".layout-parent">
            <Transition name="fullscreen">
                <div v-if="isRenderFullscreen" v-show="isFullscreen" class="absolute inset-0 z-50 w-full h-full">
                    <BasicMap
                        ref="fullScreenMapRef"
                        :isFullscreen="true"
                        class="h-full"
                        :data="data"
                        @markerClick="markerClick"
                        @closeInfoWindow="closeInfoWindow"
                        @toggleFullScreen="toggleFullScreen"
                    />
                    <!-- <div class="absolute right-2 top-2 cursor-pointer" @click="toggleFullScreen">
                        <el-tooltip content="退出全屏(Esc)" placement="top">
                            <div class="ywifont !text-[20px] text-black rounded-lg ywicon-tuichuquanping"></div>
                        </el-tooltip>
                    </div> -->
                    <div class="absolute bottom-0 w-full">
                        <EquipCurve
                            v-model:isShow="chartDlgIsShow"
                            class="opacity-90"
                            :data="equipCurveMapRow"
                            :quotaChartCol="data?.quota_chart?.col"
                            height="15rem"
                            :tableHeight="240"
                        />
                    </div>
                    <SmallChat class="absolute bottom-0 right-[50%] " :olMap="fullScreenOlMap" />
                </div>
            </Transition>
        </Teleport>
    </div>
</template>
 
<script setup lang="ts">
import 'ol/ol.css';
import { computed, nextTick, onDeactivated, onMounted, onUnmounted, ref } from 'vue';
import EquipCurve from '../components/EquipCurve.vue';
import BasicMap from './BasicMap.vue';
import SmallChat from '/@/components/chat/smallChat/index.vue';
import { GaoDeSourceType } from '/@/model/map/OLMap';
import { useCompRef } from '/@/utils/types';
const isRenderFullscreen = ref(false);
 
const isFullscreen = ref(false);
const props = defineProps(['data']);
const normalMapRef = useCompRef(BasicMap);
const fullScreenMapRef = useCompRef(BasicMap);
const fullScreenOlMap = computed(() => fullScreenMapRef.value?.olMap);
const emit = defineEmits(['equipClick', 'closeInfoWindow']);
 
const markerClick = (row) => {
    if (isFullscreen.value) {
        showCurve(row);
    } else {
        emit('equipClick', row);
    }
};
const closeInfoWindow = () => {
    if (isFullscreen.value) {
        closeChartDlg();
    } else {
        emit('closeInfoWindow');
    }
};
 
 
// 切换全屏
const toggleFullScreen = async () => {
    isFullscreen.value = !isFullscreen.value;
 
    await nextTick();
    if (isFullscreen.value) {
        const config = normalMapRef.value.olMap.getConfig();
        if (!isRenderFullscreen.value) {
            isRenderFullscreen.value = true;
        } else {
            // fullScreenMapRef.value.olMap.setConfig(config);
        }
        closeInfoWindow();
    } else {
        const config = fullScreenMapRef.value.olMap.getConfig();
        // normalMapRef.value.olMap.setConfig(config);
    }
};
 
//#region ====================== 设备曲线 ======================
const chartDlgIsShow = ref(false);
const equipCurveMapRow = ref(null);
const showCurve = (row) => {
    equipCurveMapRow.value = row;
    chartDlgIsShow.value = true;
};
 
const closeChartDlg = () => {
    chartDlgIsShow.value = false;
    equipCurveMapRow.value = null;
};
//#endregion
 
// 添加 ESC 键监听函数
const handleEscKey = (event: KeyboardEvent) => {
    if (event.key === 'Escape' && isFullscreen.value) {
        toggleFullScreen();
    }
};
 
onMounted(async () => {
    // 添加 ESC 键监听
    document.addEventListener('keydown', handleEscKey);
    // toggleFullScreen();
});
 
onDeactivated(async () => {
    if (isFullscreen.value) {
        await toggleFullScreen();
    }
});
 
// 在组件卸载时移除监听
onUnmounted(() => {
    // 移除 ESC 键监听
    document.removeEventListener('keydown', handleEscKey);
});
</script>
<style scoped lang="scss">
:deep(.amap-info-content) {
    padding: 0;
}
 
// 全屏过渡动画
.fullscreen-enter-active,
.fullscreen-leave-active {
    transition: all 0.3s ease;
}
 
.fullscreen-enter-from,
.fullscreen-leave-to {
    opacity: 0;
    transform: scale(0.95);
}
</style>