Menu.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="menu">
  3. <ul class="menu-list">
  4. <li class="menu-item" v-for="(menu, index) of currentMenu" :key="menu" @click="click(index)" :class="{ active: activeIndex == index }"
  5. @mouseenter="subMenuShow(menu.children, index)">
  6. <router-link v-if="!menu.children" :to="menu.path">
  7. <el-tooltip class="item" effect="dark" :content="menu.text" placement="right" :show-after="500">
  8. <div class="menu-icon svg-icon" :class="activeIndex == index ? 'svg-icon-green' : 'svg-icon-gray'">
  9. <SvgIcon :svgid="menu.icon"></SvgIcon>
  10. </div>
  11. </el-tooltip>
  12. </router-link>
  13. <div v-if="menu.children" class="sub-menu-item">
  14. <div class="menu-icon svg-icon" :class="activeIndex == index ? 'svg-icon-green' : 'svg-icon-gray'">
  15. <SvgIcon :svgid="menu.icon"></SvgIcon>
  16. </div>
  17. </div>
  18. </li>
  19. </ul>
  20. </div>
  21. <!-- <div class="sub-menu" v-show="isShowSubMenu">
  22. <ul class="menu-list">
  23. <li class="menu-item" v-for="(menu, index) of subMenu" @click="subclick(index)" :key="menu" :class="{ active: subIndex == index }">
  24. <router-link :to="menu.path">
  25. <div class="menu-icon svg-icon">
  26. <SvgIcon :svgid="menu.icon"></SvgIcon>
  27. </div>
  28. <div class="sub-menu-text" :class="subIndex == index ? 'green' : 'gray'">{{ menu.text }}</div>
  29. </router-link>
  30. </li>
  31. </ul>
  32. </div> -->
  33. </template>
  34. <script>
  35. import SvgIcon from "@com/coms/icon/svg-icon.vue";
  36. export default {
  37. components: {
  38. SvgIcon,
  39. },
  40. props: {},
  41. data () {
  42. return {
  43. currRoot: "monitor",
  44. menuData: [
  45. {
  46. id: "monitor",
  47. text: "状态监视",
  48. data: [
  49. {
  50. text: "驾驶舱",
  51. icon: "svg-lead-cockpit",
  52. path: "/monitor/home",
  53. },
  54. {
  55. text: "基础矩阵",
  56. icon: "svg-matrix",
  57. path: "/monitor/lightmatrix1",
  58. },
  59. {
  60. text: "明细矩阵",
  61. icon: "svg-mx-matrix",
  62. path: "/monitor/lightmatrix3",
  63. },
  64. {
  65. text: "欠发矩阵",
  66. icon: "svg-qf-matrix",
  67. path: "/monitor/lightmatrix2",
  68. },
  69. {
  70. text: "光伏矩阵",
  71. icon: "svg-gf-matrix",
  72. path: "/monitor/lightmatrix",
  73. },
  74. {
  75. text: "状态监视",
  76. icon: "svg-state-watch",
  77. path: "/monitor/status",
  78. },
  79. {
  80. text: "Agc",
  81. icon: "svg-agc",
  82. path: "/monitor/agc",
  83. },
  84. {
  85. text: "风场",
  86. icon: "svg-wind-site",
  87. path: "/monitor/windsite/home",
  88. },
  89. ],
  90. },
  91. {
  92. id: "datacenter",
  93. text: "数据管理",
  94. data: [],
  95. },
  96. {
  97. id: "statistic",
  98. text: "统计分析",
  99. data: [],
  100. },
  101. {
  102. id: "health",
  103. text: "健康管理",
  104. data: [
  105. {
  106. text: "健康管理1",
  107. icon: "svg-wind-site",
  108. path: "/health/health1",
  109. },
  110. // {
  111. // text: "健康管理2",
  112. // icon: "svg-wind-site",
  113. // path: "/health/health2",
  114. // },
  115. // {
  116. // text: "健康管理3",
  117. // icon: "svg-wind-site",
  118. // path: "/health/health3",
  119. // },
  120. // {
  121. // text: "健康管理4",
  122. // icon: "svg-wind-site",
  123. // path: "/health/health4",
  124. // },
  125. // {
  126. // text: "健康管理5",
  127. // icon: "svg-wind-site",
  128. // path: "/health/health5",
  129. // },
  130. // {
  131. // text: "健康管理6",
  132. // icon: "svg-wind-site",
  133. // path: "/health/health6",
  134. // },
  135. // {
  136. // text: "健康管理7",
  137. // icon: "svg-wind-site",
  138. // path: "/health/health7",
  139. // },
  140. ],
  141. },
  142. {
  143. id: "decision",
  144. text: "决策支持",
  145. data: [
  146. {
  147. text: "决策支持1",
  148. icon: "svg-matrix",
  149. path: "/decision/decision1",
  150. },
  151. {
  152. text: "决策支持2",
  153. icon: "svg-matrix",
  154. path: "/decision/decision2",
  155. },
  156. {
  157. text: "决策支持3",
  158. icon: "svg-matrix",
  159. path: "/decision/decision3",
  160. },
  161. {
  162. text: "决策支持4",
  163. icon: "svg-matrix",
  164. path: "/decision/decision4",
  165. },
  166. ],
  167. },
  168. {
  169. id: "knowledge",
  170. text: "知识管理",
  171. data: [],
  172. },
  173. {
  174. id: "report",
  175. text: "智能报表",
  176. data: [],
  177. },
  178. ],
  179. activeIndex: 0,
  180. isShowSubMenu: false,
  181. parentIndex: null,
  182. subMenu: [],
  183. subIndex: null,
  184. };
  185. },
  186. methods: {
  187. click (index) {
  188. this.activeIndex = index;
  189. this.subIndex = null;
  190. },
  191. subMenuShow (children, index) {
  192. if (children) {
  193. this.isShowSubMenu = true;
  194. this.parentIndex = index;
  195. } else {
  196. this.isShowSubMenu = false;
  197. this.parentIndex = null;
  198. }
  199. this.subMenu = children;
  200. },
  201. subclick (index) {
  202. this.activeIndex = this.parentIndex;
  203. this.subIndex = index;
  204. },
  205. },
  206. computed: {
  207. currentMenu () {
  208. let data = this.menuData.filter((t) => {
  209. return t.id == this.currRoot;
  210. })[0].data;
  211. return data;
  212. },
  213. },
  214. watch: {
  215. // 监听路由
  216. $route: {
  217. handler: function (val, oldVal) {
  218. this.menuData.some((element, index) => {
  219. if (val.path.includes(element.id)) {
  220. this.currRoot = element.id;
  221. return true;
  222. }
  223. });
  224. },
  225. //深度观察监听
  226. deep: true,
  227. },
  228. },
  229. };
  230. </script>
  231. <style lang="less">
  232. .menu {
  233. padding-top: 1.481vh;
  234. .menu-list {
  235. margin: 0;
  236. padding: 0;
  237. list-style: none;
  238. .menu-item {
  239. padding: 1.481vh 0;
  240. text-align: center;
  241. .menu-icon {
  242. display: flex;
  243. justify-content: center;
  244. }
  245. &.active i {
  246. color: #05bb4c;
  247. transition: color 1s;
  248. }
  249. }
  250. }
  251. i {
  252. font-size: 2.222vh;
  253. color: rgba(255, 255, 255, 50%);
  254. }
  255. }
  256. .sub-menu {
  257. position: absolute;
  258. top: 0;
  259. left: 5.3704vh;
  260. width: 138px;
  261. height: 100%;
  262. padding-top: 1.481vh;
  263. background: fade(#192a26, 75);
  264. border-right: 1px solid fade(@green, 50);
  265. box-shadow: inset 11px 0px 20px 0px fade(#021412, 60);
  266. .menu-list {
  267. margin: 0;
  268. padding: 0;
  269. list-style: none;
  270. .menu-item {
  271. display: flex;
  272. text-align: center;
  273. line-height: 1.5;
  274. padding: 8px 0;
  275. background: #121d1c;
  276. a {
  277. display: flex;
  278. width: 100%;
  279. height: 100%;
  280. padding: 0 1.4815vh;
  281. font-size: @fontsize-s;
  282. text-decoration: unset;
  283. .menu-icon {
  284. display: flex;
  285. align-items: center;
  286. svg {
  287. width: 14px;
  288. height: 14px;
  289. use {
  290. fill: fade(@green, 75);
  291. }
  292. }
  293. }
  294. }
  295. &.active {
  296. background: #323e70;
  297. .menu-icon {
  298. display: flex;
  299. svg use {
  300. fill: fade(@white, 75);
  301. }
  302. }
  303. }
  304. .sub-menu-text {
  305. margin-left: 1.1111vh;
  306. color: @gray-l;
  307. }
  308. & + .menu-item {
  309. border-top: 1px solid fade(@darkgray, 40);
  310. }
  311. }
  312. }
  313. i {
  314. font-size: 2.222vh;
  315. color: rgba(255, 255, 255, 50%);
  316. }
  317. }
  318. </style>