Menu.vue 8.5 KB

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