Menu.vue 9.9 KB

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