安琪酵母(西藏)益生菌信息采集中心智能实验室
longyvfengyun
2023-08-21 66bae94879a1ef44abe28833627564086d74ee13
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
<script setup>
import {onMounted, onUnmounted, ref, watch, nextTick} from "vue";
import MapPin from "@/components/MapPin.vue";
import slideMenu from "@/views/mainLayout/js/slideMenu";
import homeContentModule from "@/views/home/js/homeContentModule";
import homeInfoModule from "@/views/home/js/homeInfoModule";
import homeDetailModule from "@/views/home/js/homeDetailModule";
import HomeDetail from "@/views/home/components/homeDetail.vue";
import {ElMessage} from "element-plus";
 
const isShowMapPin = ref(true);
 
const {
    isCollapse
} = slideMenu();
 
const {
    homeContentDom,
    cWidth, cHeight,
    dWidth, dHeight,
    setContainerSize
} = homeContentModule();
 
const {homeInfo} = homeInfoModule();
const {getHomeDetailInfo} = homeDetailModule();
const homeItemDialog = ref(false);
const homeDetailInfo = ref({});
const homeVals = ref({});
const handleClick = (info)=>{
    let rs = getHomeDetailInfo(info.num);
    if(rs.code === 1) {
        homeDetailInfo.value = rs.data;
        homeVals.value = info;
        homeItemDialog.value = true;
    }else {
        ElMessage(rs.msg);
    }
 
}
 
watch(isCollapse, ()=>{
    isShowMapPin.value = false;
    setTimeout(()=>{
        isShowMapPin.value = true;
        setContainerSize();
    }, 500);
});
 
onMounted(()=>{
    setContainerSize();
    // 监听windows窗口的缩放,绑定resize事件
    window.addEventListener("resize", setContainerSize);
});
 
 
onUnmounted(()=>{
    // 销毁resize事件
    window.removeEventListener("resize", setContainerSize);
});
</script>
 
<template>
    <div class="home-content" ref="homeContentDom">
        <map-pin
            v-if="isShowMapPin"
            v-for="(item, index) in homeInfo" :key="'key'+index"
            :visible="item.pos.visible"
            :name="item.name"
            :c-width="cWidth" :c-height="cHeight"
            :d-width="dWidth" :d-height="dHeight"
            :x="item.pos.x" :y="item.pos.y"
            :info="item.info" @click="handleClick"></map-pin>
        <el-dialog
            v-model="homeItemDialog"
            title="机房详情"
            width="auto"
            class="center-dialog"
            modal-class="high-level-dialog"
            align-center>
            <home-detail :info="homeDetailInfo" :vals="homeVals"></home-detail>
        </el-dialog>
    </div>
 
</template>
 
<style scoped>
.home-content {
    position: relative;
    height: 100%;
    background-image: url("./images/home-plus.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
</style>