green-nav.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="green-nav">
  4. <div class="main-title">{{ Title }}</div>
  5. <!-- menu区域 -->
  6. <div class="nav-menu">
  7. <div
  8. :class="activeIndex == index ? 'nav-menu-active' : 'nav-menu-unactive'"
  9. v-for="(item, index) in menuList"
  10. :key="index"
  11. @click="menuClick(index, item)"
  12. >
  13. <div>{{ item.name }}</div>
  14. <!-- menu-item -->
  15. <div v-if="activeIndex == index && isShowMenuItem && item.MenuItemList.length != 0" class="nav-menu-item">
  16. <div class="nav-menu-content">
  17. <div
  18. :class="menuItemActive == ind ? 'menu-item-active' : 'menu-item-unactive'"
  19. v-for="(ite, ind) in item.MenuItemList"
  20. :key="ind"
  21. @click.stop="menuItemClick(ind)"
  22. >{{ ite.name }}</div
  23. >
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import { onMounted, onUnmounted, ref, watch, computed } from 'vue';
  32. let props = defineProps({
  33. Title: {
  34. type: String,
  35. default: '',
  36. },
  37. activeIndex: {
  38. type: Number,
  39. default: 0,
  40. },
  41. });
  42. let menuList = ref<any[]>([
  43. {
  44. name: '灾害预警',
  45. MenuItemList: [
  46. // { name: '光纤测温监测' },
  47. // { name: '束管监测' },
  48. // { name: '智能注氮系统' },
  49. // { name: '智能注浆系统' },
  50. // { name: '火灾监测预警' },
  51. // { name: '色谱仪报表分析' },
  52. ],
  53. },
  54. { name: '智能通风', MenuItemList: [] },
  55. { name: '火灾监控', MenuItemList: [] },
  56. { name: '粉尘监控', MenuItemList: [] },
  57. { name: '瓦斯监控', MenuItemList: [] },
  58. // { name: '综合管控', MenuItemList: [] },
  59. ]); //一级菜单列表
  60. let isShowMenuItem = ref(false); //是否显示menuItem下拉选项菜单
  61. let menuItemActive = ref(0); //menuItem当前激活选项
  62. let $emit = defineEmits(['menuToggle']);
  63. //menu选项切换
  64. function menuClick(index, item) {
  65. isShowMenuItem.value = !isShowMenuItem.value;
  66. //menu切换,界面跳转
  67. $emit('menuToggle', item, index);
  68. }
  69. //menuItem选项切换
  70. function menuItemClick(ind) {
  71. menuItemActive.value = ind;
  72. isShowMenuItem.value = false;
  73. }
  74. </script>
  75. <style lang="less" scoped>
  76. @import '/@/design/theme.less';
  77. @font-face {
  78. font-family: 'douyuFont';
  79. src: url('/@/assets/font/douyuFont.otf');
  80. }
  81. .green-nav {
  82. position: relative;
  83. width: 100%;
  84. height: 100%;
  85. background: url('../../../../../assets/images/home-green/green-nav-bg.png') no-repeat;
  86. background-size: 100% 100%;
  87. .main-title {
  88. width: 518px;
  89. height: 100%;
  90. display: flex;
  91. align-items: center;
  92. padding-left: 70px;
  93. font-family: 'douyuFont';
  94. font-size: 20px;
  95. letter-spacing: 2px;
  96. }
  97. .nav-menu {
  98. position: absolute;
  99. top: 0;
  100. left: 675px;
  101. width: 880px;
  102. height: 100%;
  103. display: flex;
  104. justify-content: flex-start;
  105. .nav-menu-active {
  106. position: relative;
  107. width: 120px;
  108. height: 60px;
  109. line-height: 60px;
  110. text-align: center;
  111. margin: 0px 20px;
  112. font-size: 18px;
  113. letter-spacing: 2px;
  114. background: url('../../../../../assets/images/home-green/green-menu-bg.png') no-repeat;
  115. background-size: 100% 100%;
  116. }
  117. .nav-menu-unactive {
  118. position: relative;
  119. width: 120px;
  120. height: 60px;
  121. line-height: 60px;
  122. text-align: center;
  123. margin: 0px 10px;
  124. font-size: 16px;
  125. letter-spacing: 2px;
  126. background-size: 100% 100%;
  127. cursor: pointer;
  128. }
  129. .nav-menu-item {
  130. position: absolute;
  131. left: -34px;
  132. top: 56px;
  133. width: 186px;
  134. height: 273px;
  135. padding: 28px 12px 12px 12px;
  136. background: url(/src/assets/images/home-green/green-menu-item.png) no-repeat;
  137. display: flex;
  138. flex-direction: column;
  139. align-items: center;
  140. box-sizing: border-box;
  141. .nav-menu-content {
  142. width: 100%;
  143. height: 100%;
  144. overflow-y: auto;
  145. .menu-item-active {
  146. width: 100%;
  147. height: 36px;
  148. line-height: 36px;
  149. font-size: 14px;
  150. background: linear-gradient(to right, transparent, rgba(47, 132, 111), transparent);
  151. }
  152. .menu-item-unactive {
  153. width: 100%;
  154. height: 40px;
  155. line-height: 40px;
  156. font-size: 14px;
  157. }
  158. }
  159. }
  160. // @keyframes fadeIn {
  161. // from {
  162. // opacity: 0;
  163. // }
  164. // to {
  165. // opacity: 1;
  166. // }
  167. // }
  168. // /* 定义淡出动画 */
  169. // @keyframes fadeOut {
  170. // from {
  171. // opacity: 1;
  172. // }
  173. // to {
  174. // opacity: 0;
  175. // }
  176. // }
  177. }
  178. }
  179. </style>