Menu.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. text: "能效分析",
  101. icon: "svg-wind-site",
  102. path: "/nxfx",
  103. children: [
  104. {
  105. text: "功率曲线拟合",
  106. icon: "svg-wind-site",
  107. path: "/nxfx1",
  108. },
  109. {
  110. text: "偏航对风分析",
  111. icon: "svg-wind-site",
  112. path: "/nxfx2",
  113. },
  114. {
  115. text: "切入切出分析",
  116. icon: "svg-wind-site",
  117. path: "/cutAnalyse",
  118. },
  119. {
  120. text: "曲线偏差率分析",
  121. icon: "svg-wind-site",
  122. path: "/nxfx4",
  123. },
  124. {
  125. text: "单机性能分析",
  126. icon: "svg-wind-site",
  127. path: "/nxfx5",
  128. },
  129. {
  130. text: "单机月度分析",
  131. icon: "svg-wind-site",
  132. path: "/nxfx6",
  133. },
  134. {
  135. text: "单机饱和度",
  136. icon: "svg-wind-site",
  137. path: "/wtSaturability",
  138. }
  139. ]
  140. }
  141. ],
  142. },
  143. {
  144. id: "health",
  145. text: "健康管理",
  146. data: [
  147. {
  148. text: "健康管理",
  149. icon: "svg-wind-site",
  150. path: "/health",
  151. children: [
  152. {
  153. text: "健康推荐",
  154. icon: "svg-wind-site",
  155. path: "/health",
  156. },
  157. {
  158. text: "健康首页",
  159. icon: "svg-wind-site",
  160. path: "/health/health2",
  161. },
  162. {
  163. text: "健康总览",
  164. icon: "svg-wind-site",
  165. path: "/health/health6",
  166. },
  167. {
  168. text: "健康矩阵",
  169. icon: "svg-wind-site",
  170. path: "/health/health5",
  171. },
  172. // {
  173. // text: "健康列表",
  174. // icon: "svg-wind-site",
  175. // path: "/health/health6",
  176. // }
  177. ],
  178. },
  179. {
  180. text: "健康管理8",
  181. icon: "svg-wind-site",
  182. path: "/health/health8",
  183. },
  184. ],
  185. },
  186. {
  187. id: "decision",
  188. text: "决策支持",
  189. data: [
  190. {
  191. text: "风机绩效榜",
  192. icon: "svg-matrix",
  193. path: "/decision/decision1",
  194. },
  195. {
  196. text: "五项损失率",
  197. icon: "svg-matrix",
  198. path: "/decision/decision2",
  199. },
  200. {
  201. text: "场内对标",
  202. icon: "svg-matrix",
  203. path: "/decision/decision2Cndb",
  204. },
  205. {
  206. text: "场际对标",
  207. icon: "svg-matrix",
  208. path: "/decision/decision2Cjdb",
  209. },
  210. {
  211. text: "项目对标",
  212. icon: "svg-matrix",
  213. path: "/decision/decision2Xmdb",
  214. },
  215. {
  216. text: "线路对标",
  217. icon: "svg-matrix",
  218. path: "/decision/decision2Xldb",
  219. },
  220. // {
  221. // text: "决策支持3",
  222. // icon: "svg-matrix",
  223. // path: "/decision/decision3",
  224. // },
  225. // {
  226. // text: "决策支持4",
  227. // icon: "svg-matrix",
  228. // path: "/decision/decision4",
  229. // },
  230. ],
  231. },
  232. {
  233. id: "knowledge",
  234. text: "知识管理",
  235. data: [
  236. {
  237. text: "故障知识列表",
  238. icon: "svg-matrix",
  239. path: "/knowledge",
  240. },
  241. {
  242. text: "安全措施知识",
  243. icon: "svg-matrix",
  244. path: "/knowledge2",
  245. },
  246. ],
  247. },
  248. {
  249. id: "report",
  250. text: "智能报表",
  251. data: [],
  252. },
  253. ],
  254. activeIndex: 0,
  255. isShowSubMenu: false,
  256. parentIndex: null,
  257. subMenu: [],
  258. subIndex: null,
  259. };
  260. },
  261. methods: {
  262. click(index) {
  263. this.activeIndex = index;
  264. this.subIndex = null;
  265. },
  266. subMenuShow(children, index) {
  267. if (children) {
  268. this.isShowSubMenu = true;
  269. this.parentIndex = index;
  270. } else {
  271. this.isShowSubMenu = false;
  272. this.parentIndex = null;
  273. }
  274. this.subMenu = children;
  275. },
  276. subclick(index) {
  277. this.activeIndex = this.parentIndex;
  278. this.subIndex = index;
  279. },
  280. },
  281. computed: {
  282. currentMenu() {
  283. let data = this.menuData.filter((t) => {
  284. return t.id == this.currRoot;
  285. })[0].data;
  286. return data;
  287. },
  288. },
  289. watch: {
  290. // 监听路由
  291. $route: {
  292. handler: function(val, oldVal) {
  293. this.menuData.some((element, index) => {
  294. if (val.path.includes(element.id)) {
  295. this.currRoot = element.id;
  296. this.$nextTick(() => {
  297. this.currentMenu.some((element, index) => {
  298. if (val.path == element.path) {
  299. this.activeIndex = index;
  300. }
  301. });
  302. });
  303. return true;
  304. }
  305. });
  306. },
  307. //深度观察监听
  308. deep: true,
  309. },
  310. },
  311. };
  312. </script>
  313. <style lang="less">
  314. .menu {
  315. padding-top: 1.481vh;
  316. .menu-list {
  317. margin: 0;
  318. padding: 0;
  319. list-style: none;
  320. .menu-item {
  321. padding: 1.481vh 0;
  322. text-align: center;
  323. .menu-icon {
  324. display: flex;
  325. justify-content: center;
  326. }
  327. &.active i {
  328. color: #05bb4c;
  329. transition: color 1s;
  330. }
  331. }
  332. }
  333. i {
  334. font-size: 2.222vh;
  335. color: rgba(255, 255, 255, 50%);
  336. }
  337. }
  338. .sub-menu {
  339. position: absolute;
  340. top: 0;
  341. left: 5.3704vh;
  342. width: 138px;
  343. height: 100%;
  344. padding-top: 1.481vh;
  345. background: fade(#192a26, 75);
  346. border-right: 1px solid fade(@green, 50);
  347. box-shadow: inset 11px 0px 20px 0px fade(#021412, 60);
  348. .menu-list {
  349. margin: 0;
  350. padding: 0;
  351. list-style: none;
  352. .menu-item {
  353. display: flex;
  354. text-align: center;
  355. line-height: 1.5;
  356. padding: 8px 0;
  357. background: #121d1c;
  358. a {
  359. display: flex;
  360. width: 100%;
  361. height: 100%;
  362. padding: 0 1.4815vh;
  363. font-size: @fontsize-s;
  364. text-decoration: unset;
  365. .menu-icon {
  366. display: flex;
  367. align-items: center;
  368. svg {
  369. width: 14px;
  370. height: 14px;
  371. use {
  372. fill: fade(@green, 75);
  373. }
  374. }
  375. }
  376. }
  377. &.active {
  378. background: #323e70;
  379. .menu-icon {
  380. display: flex;
  381. svg use {
  382. fill: fade(@white, 75);
  383. }
  384. }
  385. }
  386. .sub-menu-text {
  387. margin-left: 1.1111vh;
  388. color: @gray-l;
  389. }
  390. & + .menu-item {
  391. border-top: 1px solid fade(@darkgray, 40);
  392. }
  393. }
  394. }
  395. i {
  396. font-size: 2.222vh;
  397. color: rgba(255, 255, 255, 50%);
  398. }
  399. }
  400. </style>