index.vue 8.1 KB

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