基于北京SDK的方案预演功能
surprise
2024-05-07 087510aa88b0a6b6b5c648907e9dd52394621d47
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
165
166
167
168
169
170
171
172
173
174
<template>
  <div class="MenuBox">
    <!-- 菜单 -->
    <div class="menuContent"
         v-show="!menuIsShow"
         :class="{ menuActive: menuIsShow }">
      <div class="menuItemBox"
           @click="setMenuClick(item)"
           :id="item.id"
           v-for="(item, index) in menuOption"
           :key="index">
        {{ item.name }}
      </div>
      <div class="closeMenu"
           @click="setMenuIsShow">
        <el-icon :size="20">
          <DArrowRight />
        </el-icon>
      </div>
    </div>
    <div v-show="menuIsShow"
         @click="setMenuIsShow"
         class="rightMenu">
      <el-icon :size="20">
        <DArrowLeft />
      </el-icon>
    </div>
  </div>
  <!-- 二级菜单 -->
  <div class="childMenuBox"
       v-show="childMenuIsShow">
    <div @click="setChildMenuClick(item)"
         v-for="(item, key) in childMenuOption"
         :key="key">
      {{ item.name }}
    </div>
  </div>
</template>
 
<script lang="ts" setup>
import { ref, onMounted, nextTick, watch } from "vue";
import { DArrowRight, DArrowLeft } from "@element-plus/icons-vue";
import menuData from "@/assets/js/data/menuData";
import menuManager from "@/assets/js/map/menuManager";
import militaryPlotting from "@/components/plot/militaryPlotting";
const menuOption = ref([]);
const childMenuOption = ref([]);
const menuIsShow = ref(false);
const childMenuIsShow = ref(false);
const setCheckMenuFlag = ref(null);
// 菜单显隐切换
const setMenuIsShow = () => {
  menuIsShow.value = !menuIsShow.value;
};
// 菜单初始化
const setMenuStart = () => {
  menuOption.value = menuData.menuData;
};
//菜单点击事件
const setMenuClick = (res) => {
  const obj = menuManager.init(res);
  if (obj) {
    if (childMenuIsShow.value && obj == setCheckMenuFlag.value) {
      childMenuIsShow.value = false;
      setCheckMenuFlag.value = null;
      return;
    }
    setCheckMenuFlag.value = obj;
    var client = document.getElementById(obj).getBoundingClientRect().left;
    document.getElementsByClassName("childMenuBox")[0].style.left =
      client + "px";
    childMenuOption.value = menuData[obj];
    childMenuIsShow.value = true;
  } else {
    childMenuIsShow.value = false;
    setCheckMenuFlag.value = null;
  }
};
//二级菜单点击事件
const setChildMenuClick = (item) => {
  var obj = menuManager.init(item);
 
  childMenuIsShow.value = false;
  setCheckMenuFlag.value = null;
};
onMounted(() => {
  setMenuStart();
});
</script>
 
<style lang="less" scoped>
.MenuBox {
  z-index: 40;
  position: absolute;
  top: 80px;
  right: 0px;
  border-radius: 0 6px 6px 0;
  font-family: microsoft yahei;
 
  .menuContent {
    display: flex;
    height: 40px;
    border: 1px solid #30bcff;
  }
  .menuItemBox {
    color: white;
    background: rgba(26, 37, 23, 0.8);
    box-shadow: inset 0px 10px 40px 10px rgba(26, 37, 23, 1);
    line-height: 40px;
    padding: 0px 10px;
    font-size: 14px;
  }
  .menuItemBox:hover {
    color: #30bcff;
  }
  .menuActive {
    width: 0px;
    transition: width 10s linear 10s;
    /* Safari */
    -webkit-transition: width 10s linear 10s;
  }
  .closeMenu {
    width: 30px;
    height: 100%;
    background: #30bcff;
    color: white;
    display: flex;
    position: relative;
    justify-content: center;
    align-items: center;
  }
  .rightMenu {
    width: 30px;
    height: 30px;
    background: rgba(26, 37, 23, 0.8);
 
    border: 1px solid #30bcff;
    color: #30bcff;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
  }
  .rightMenu:hover {
    background: #30bcff !important;
    color: white;
    border: 1px solid #fff;
  }
}
.childMenuBox {
  padding: 10px;
  width: auto;
  color: white;
  background: rgba(35, 47, 42, 0.8);
  border: 1px solid #30bcff;
  position: absolute;
  z-index: 41;
  top: 123px;
  border-radius: 3px;
  transform: translate(-20%, 0);
  min-width: 52px;
  text-align: center;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  div {
    height: 36px;
    line-height: 36px;
    font-family: microsoft yahei;
    font-size: 12px;
  }
  div:hover {
    color: #30bcff;
  }
}
</style>