index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="right-menu">
  3. <div class="menu-container">
  4. <div style="position: relative; margin-top: 60px">
  5. <div ref="scrollListRef" :class="!menuState.showMenu ? 'menu-list' : 'menu-list menu-list-right'">
  6. <div
  7. v-for="(item, index) in menuState.menuData"
  8. :key="index"
  9. :class="menuState.activeIndex === index ? 'menu-item menu-active' : 'menu-item'"
  10. @click="clickMenu(index)"
  11. >
  12. <div :class="item.meta?.icon + ' ' + item.meta?.icon + '_checked'"></div>
  13. <div class="gradient-text text">{{ item.name }}</div>
  14. </div>
  15. </div>
  16. <div v-show="menuState.menuData.length > 0" :class="menuState.showMenu ? 'right-btn' : 'left-btn'" @click="clickContractMenu"></div>
  17. <div v-show="menuState.menuData.length > 7" class="btn-box">
  18. <div class="up-btn" @click="clickBtn('up')"></div>
  19. <div class="down-btn" @click="clickBtn('down')"></div>
  20. </div>
  21. </div>
  22. <div v-show="menuState.showMenu">
  23. <!--图层分析-->
  24. <LayerAnalysis v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '图层分析'" :point-type="pointType" />
  25. <!--空间分析-->
  26. <SpatialAnalysis v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '空间分析'" :updateLocation="location" @handle-menu="handleMenu" />
  27. <!--江湖河库-->
  28. <Reservoir v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '江湖河库'" />
  29. <!--路网视频-->
  30. <RoadNetworkVideo v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '路网视频'" />
  31. <!--防溺水视频-->
  32. <PreventDrowning v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '防溺水'" />
  33. <!--水库监测-->
  34. <ReservoirMonitor v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '水库监测'" />
  35. <!--河道监测-->
  36. <RiverMonitor v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '河道监测'" />
  37. <!--无人机-->
  38. <UAV v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '无人机'" @handle-menu="handleMenu" />
  39. <!--实时标绘-->
  40. <OnlinePlotting v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '实时标绘'" />
  41. <!--雨情监测-->
  42. <RainMonitor v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '雨情监测'" />
  43. <!--预警信息-->
  44. <WarningInfo v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '预警信息'" @handle-menu="handleMenu" />
  45. <!--森林防火-->
  46. <Fireproofing v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '森林防火'" @handle-menu="handleMenu" />
  47. <!--防灾救援-->
  48. <Mitigation v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '防灾救援'" @handle-menu="handleMenu" />
  49. <!--易涝隐患点-->
  50. <PotentialFloodHazard v-if="menuState.showMenu && menuState.menuData[menuState.activeIndex]?.name === '易涝隐患点'" @handle-menu="handleMenu" />
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script lang="ts" setup name="rightMenu">
  56. import RiverMonitor from './RiverMonitor.vue';
  57. import ReservoirMonitor from './ReservoirMonitor.vue';
  58. import RoadNetworkVideo from './RoadNetworkVideo.vue';
  59. import Reservoir from './Reservoir.vue';
  60. import SpatialAnalysis from './SpatialAnalysis.vue';
  61. import LayerAnalysis from './LayerAnalysis.vue';
  62. import OnlinePlotting from './OnlinePlotting/index.vue';
  63. import UAV from './UAV.vue';
  64. import WarningInfo from './WarningInfo.vue';
  65. import { PointType } from '@/api/globalMap/type';
  66. import RainMonitor from './RainMonitor/index.vue';
  67. import PreventDrowning from './PreventDrowning.vue';
  68. import Fireproofing from './Fireproofing.vue';
  69. import Mitigation from './Mitigation.vue';
  70. import PotentialFloodHazard from './PotentialFloodHazard.vue';
  71. interface Props {
  72. pointType: PointType[];
  73. }
  74. withDefaults(defineProps<Props>(), {});
  75. const emits = defineEmits(['update:drawing']);
  76. const scrollListRef = ref();
  77. const menuState = reactive({
  78. showMenu: false,
  79. activeIndex: 0,
  80. menuData: []
  81. });
  82. const activeName = computed(() => {
  83. let name = '';
  84. if (!!menuState.menuData && menuState.menuData.length > 0 && !!menuState.menuData[menuState.activeIndex]) {
  85. name = menuState.menuData[menuState.activeIndex].name;
  86. }
  87. return name;
  88. });
  89. // 点击收缩展开
  90. const clickContractMenu = () => {
  91. menuState.showMenu = !menuState.showMenu;
  92. };
  93. // 菜单上下移动
  94. const clickBtn = (direction: string) => {
  95. const len = menuState.menuData.length;
  96. if (direction === 'up' && scrollListRef.value.scrollTop - 168 >= 0) {
  97. scrollListRef.value.scrollTop -= 168;
  98. } else if (direction === 'down' && scrollListRef.value.scrollTop + 168 <= 168 * len) {
  99. scrollListRef.value.scrollTop += 168;
  100. }
  101. };
  102. // 点击菜单
  103. const clickMenu = (index) => {
  104. menuState.showMenu = true;
  105. menuState.activeIndex = index;
  106. };
  107. let location = ref([]);
  108. // 显示菜单
  109. const handleMenu = (name, data) => {
  110. let index = menuState.menuData.findIndex((item) => {
  111. return item.name === name;
  112. });
  113. if (name === '空间分析') {
  114. menuState.showMenu = true;
  115. menuState.activeIndex = index;
  116. nextTick(() => {
  117. location.value = data;
  118. });
  119. } else if (index > -1) {
  120. clickMenu(index);
  121. }
  122. };
  123. // 新增菜单 type 1 新增 2 删除
  124. const updateMenu = (type, menu) => {
  125. if (type === '1') {
  126. if (menu.name === '图层分析') {
  127. let index = menuState.menuData.findIndex((item) => {
  128. return item.name === menu.name;
  129. });
  130. if (index === -1) {
  131. menuState.menuData.push(menu);
  132. }
  133. } else {
  134. menuState.menuData.push(menu);
  135. }
  136. clickMenu(menuState.menuData.length - 1);
  137. } else if (type === '2') {
  138. let index = menuState.menuData.findIndex((item) => item.name === menu.name);
  139. if (index > -1) {
  140. menuState.menuData.splice(index, 1);
  141. menuState.activeIndex = 0;
  142. }
  143. }
  144. };
  145. const getMenuState = () => {
  146. return menuState;
  147. };
  148. defineExpose({ handleMenu, clickContractMenu, updateMenu, getMenuState });
  149. </script>
  150. <style lang="scss" scoped>
  151. .right-menu {
  152. position: absolute;
  153. top: 100px;
  154. right: 0;
  155. z-index: 20;
  156. }
  157. .expand-btn {
  158. width: 70px;
  159. height: 240px;
  160. font-size: 32px;
  161. background: #d7d7d7;
  162. padding: 10px 18px;
  163. cursor: pointer;
  164. display: flex;
  165. align-items: center;
  166. }
  167. .menu-container {
  168. display: flex;
  169. .menu-list-right {
  170. margin-right: -115px;
  171. }
  172. .menu-list {
  173. position: relative;
  174. max-height: 1176px;
  175. overflow: hidden;
  176. .menu-item {
  177. width: 470px;
  178. height: 168px;
  179. font-size: 32px;
  180. padding: 30px 18px 10px 40px;
  181. cursor: pointer;
  182. display: flex;
  183. align-items: center;
  184. background: url('@/assets/images/map/rightMenu/box.png') no-repeat;
  185. .text {
  186. font-size: 48px;
  187. }
  188. &:hover {
  189. background: url('@/assets/images/map/rightMenu/box_checked.png') no-repeat;
  190. }
  191. }
  192. .menu-active {
  193. background: url('@/assets/images/map/rightMenu/box_checked.png') no-repeat;
  194. }
  195. }
  196. .left-btn,
  197. .right-btn {
  198. position: absolute;
  199. top: 50%;
  200. right: -80px;
  201. transform: translateY(-50%);
  202. z-index: 2;
  203. }
  204. .right-btn {
  205. width: 177px;
  206. height: 151px;
  207. cursor: pointer;
  208. background: url('@/assets/images/map/rightMenu/right.png') no-repeat;
  209. cursor: pointer;
  210. }
  211. .left-btn {
  212. right: 20px;
  213. width: 125px;
  214. height: 151px;
  215. background: url('@/assets/images/map/rightMenu/left.png') no-repeat;
  216. cursor: pointer;
  217. }
  218. .btn-box {
  219. width: 100%;
  220. display: flex;
  221. margin-left: 45px;
  222. .up-btn {
  223. width: 151px;
  224. height: 178px;
  225. background: url('@/assets/images/map/rightMenu/up.png') no-repeat;
  226. cursor: pointer;
  227. }
  228. .down-btn {
  229. height: 177px;
  230. width: 151px;
  231. background: url('@/assets/images/map/rightMenu/down.png') no-repeat;
  232. cursor: pointer;
  233. }
  234. }
  235. }
  236. .icon1 {
  237. width: 99px;
  238. height: 92px;
  239. background: url('@/assets/images/map/rightMenu/icon2.png') no-repeat;
  240. cursor: pointer;
  241. }
  242. .icon1_checked {
  243. background: url('@/assets/images/map/rightMenu/icon2_checked.png') no-repeat;
  244. }
  245. .icon2 {
  246. width: 99px;
  247. height: 92px;
  248. background: url('@/assets/images/map/rightMenu/icon2.png') no-repeat;
  249. cursor: pointer;
  250. }
  251. .icon2_checked {
  252. background: url('@/assets/images/map/rightMenu/icon2_checked.png') no-repeat;
  253. }
  254. .icon3 {
  255. width: 92px;
  256. height: 92px;
  257. background: url('@/assets/images/map/rightMenu/icon3.png') no-repeat;
  258. cursor: pointer;
  259. }
  260. .icon3_checked {
  261. background: url('@/assets/images/map/rightMenu/icon3_checked.png') no-repeat;
  262. }
  263. .icon4 {
  264. width: 90px;
  265. height: 85px;
  266. background: url('@/assets/images/map/rightMenu/icon4.png') no-repeat;
  267. cursor: pointer;
  268. }
  269. .icon4_checked {
  270. background: url('@/assets/images/map/rightMenu/icon4_checked.png') no-repeat;
  271. }
  272. .icon5 {
  273. width: 91px;
  274. height: 82px;
  275. background: url('@/assets/images/map/rightMenu/icon5.png') no-repeat;
  276. cursor: pointer;
  277. }
  278. .icon5_checked {
  279. background: url('@/assets/images/map/rightMenu/icon5_checked.png') no-repeat;
  280. }
  281. .icon6 {
  282. width: 89px;
  283. height: 87px;
  284. background: url('@/assets/images/map/rightMenu/icon6.png') no-repeat;
  285. cursor: pointer;
  286. }
  287. .icon6_checked {
  288. background: url('@/assets/images/map/rightMenu/icon6_checked.png') no-repeat;
  289. }
  290. </style>