当前位置:   article > 正文

el-menu写菜单栏_el-sub-menu

el-sub-menu
  1. <template>
  2. <div>
  3. <div class="rightSide" @mouseenter="onMouseenter"></div>
  4. <el-drawer v-model="isShowDrawer" direction="ltr" custom-class="drawer" :size="250">
  5. <el-menu background-color="rgba(19, 27, 60, 0.95)" text-color="#fff" active-text-color="#409eff" router :default-active="activePath" style="border-right: none" :unique-opened="true" :collapse-transition="true">
  6. <!-- 一级菜单 -->
  7. <el-sub-menu v-for="item in menulist" :key="item.id" :index="'/'+item.path">
  8. <template #title>
  9. <i :class="icons[item.id]"></i>
  10. <span>{{item.authName}}</span>
  11. </template>
  12. <!-- 二级菜单 -->
  13. <el-sub-menu v-for="item2 in item.children" :key="item2.id" :index="'/'+item2.path">
  14. <template #title>
  15. <i class="iconfont icon-caidan"></i>
  16. <span>{{item2.authName}}</span>
  17. </template>
  18. <!-- 三级菜单 -->
  19. <el-menu-item v-for="item3 in item2.children" :key="item3.id" :index="'/'+item3.path" @click="saveNavState('/' + item3.path)">
  20. <i class="iconfont icon-erjicaidan-shubiaohuadong" style="font-size:1.2rem;margin-right:0.5rem"></i>
  21. <span>{{item3.authName}}</span>
  22. </el-menu-item>
  23. </el-sub-menu>
  24. </el-sub-menu>
  25. </el-menu>
  26. </el-drawer>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. isShowDrawer: true,
  34. activePath: "/screen", //保存跳转链接
  35. icons: {
  36. 1: "iconfont icon-zonghenengyuan",
  37. 2: "iconfont icon-jiankongshexiangtou-xianxing",
  38. 3: "iconfont icon-gaojing",
  39. 4: "iconfont icon-yunwei",
  40. 5: "iconfont icon-xitong",
  41. },
  42. menulist: [
  43. {
  44. id: 1,
  45. authName: "能源管理",
  46. path: "screen",
  47. children: [
  48. {
  49. id: 101,
  50. authName: "能耗总览",
  51. path: "screen",
  52. children: [
  53. {
  54. id: 10101,
  55. authName: "驾驶舱",
  56. path: "screen",
  57. children: [],
  58. },
  59. {
  60. id: 10102,
  61. authName: "驾驶舱2",
  62. path: "cockpit",
  63. children: [],
  64. },
  65. {
  66. id: 10103,
  67. authName: "GIS地图",
  68. path: "home",
  69. children: [],
  70. },
  71. ],
  72. },
  73. {
  74. id: 102,
  75. authName: "能耗数据",
  76. path: "inquire",
  77. children: [
  78. {
  79. id: 10201,
  80. authName: "能耗查询",
  81. path: "inquire",
  82. children: [],
  83. },
  84. {
  85. id: 10202,
  86. authName: "能耗对比",
  87. path: "compared",
  88. children: [],
  89. },
  90. ],
  91. },
  92. {
  93. id: 103,
  94. authName: "能耗分析",
  95. path: "sub-option",
  96. children: [
  97. {
  98. id: 10301,
  99. authName: "能耗分项",
  100. path: "sub-option",
  101. children: [],
  102. },
  103. {
  104. id: 10302,
  105. authName: "能耗分项2",
  106. path: "sub-option2",
  107. children: [],
  108. },
  109. ],
  110. },
  111. ],
  112. },
  113. {
  114. id: 2,
  115. authName: "设备监控",
  116. path: "cold-heat",
  117. children: [
  118. {
  119. id: 201,
  120. authName: "暖通空调系统",
  121. path: "cold-heat",
  122. children: [
  123. {
  124. id: 20101,
  125. authName: "冷热源系统",
  126. path: "cold-heat",
  127. children: [],
  128. },
  129. {
  130. id: 20102,
  131. authName: "空调箱系统",
  132. path: "air-conditioning",
  133. children: [],
  134. },
  135. {
  136. id: 20103,
  137. authName: "风机盘管系统",
  138. path: "fan-coil",
  139. children: [],
  140. },
  141. ],
  142. },
  143. {
  144. id: 202,
  145. authName: "智能监控系统",
  146. path: "low-voltage",
  147. children: [
  148. {
  149. id: 20201,
  150. authName: "低压配电系统",
  151. path: "low-voltage",
  152. children: [],
  153. },
  154. {
  155. id: 20202,
  156. authName: "公区照明系统",
  157. path: "public-lighting",
  158. children: [],
  159. },
  160. {
  161. id: 20203,
  162. authName: "景观照明系统",
  163. path: "land-lighting",
  164. children: [],
  165. },
  166. {
  167. id: 20204,
  168. authName: "电热水器系统",
  169. path: "water-heater",
  170. children: [],
  171. },
  172. {
  173. id: 20205,
  174. authName: "电梯监控系统",
  175. path: "elevator-monitor",
  176. children: [],
  177. },
  178. {
  179. id: 20206,
  180. authName: "广场喷泉系统",
  181. path: "square-fountain",
  182. children: [],
  183. },
  184. {
  185. id: 20207,
  186. authName: "给排水监控系统",
  187. path: "drainage",
  188. children: [],
  189. },
  190. {
  191. id: 20208,
  192. authName: "电动遮阳帘系统",
  193. path: "electric-sun-shade",
  194. children: [],
  195. },
  196. ],
  197. },
  198. ],
  199. },
  200. {
  201. id: 3,
  202. authName: "告警管理",
  203. path: "warn-alarm",
  204. children: [
  205. {
  206. id: 301,
  207. authName: "告警管理",
  208. path: "warn-alarm",
  209. children: [
  210. {
  211. id: 30101,
  212. authName: "当日告警",
  213. path: "warn-alarm",
  214. children: [],
  215. },
  216. {
  217. id: 30102,
  218. authName: "历史告警",
  219. path: "warn-history",
  220. children: [],
  221. },
  222. {
  223. id: 30103,
  224. authName: "告警设置",
  225. path: "warn-set",
  226. children: [],
  227. },
  228. {
  229. id: 30104,
  230. authName: "时间策略",
  231. path: "warn-time",
  232. children: [],
  233. },
  234. ],
  235. },
  236. ],
  237. },
  238. {
  239. id: 4,
  240. authName: "运维管理",
  241. path: "gd-order-repair",
  242. children: [
  243. {
  244. id: 401,
  245. authName: "报修管理",
  246. path: "gd-order-repair",
  247. children: [
  248. {
  249. id: 40101,
  250. authName: "工单报修管理",
  251. path: "gd-order-repair",
  252. children: [],
  253. },
  254. {
  255. id: 40102,
  256. authName: "工单关单管理",
  257. path: "gd-closing",
  258. children: [],
  259. },
  260. {
  261. id: 40103,
  262. authName: "工单受单管理",
  263. path: "gd-acceptance-sp",
  264. children: [],
  265. },
  266. {
  267. id: 40104,
  268. authName: "工单派单管理",
  269. path: "gd-orders",
  270. children: [],
  271. },
  272. {
  273. id: 40105,
  274. authName: "工单执行管理",
  275. path: "gd-implement",
  276. children: [],
  277. },
  278. {
  279. id: 40106,
  280. authName: "工单综合管理",
  281. path: "production-orders",
  282. children: [],
  283. },
  284. ],
  285. },
  286. {
  287. id: 402,
  288. authName: "巡检管理",
  289. path: "inspect-item",
  290. children: [
  291. {
  292. id: 40201,
  293. authName: "巡检条目",
  294. path: "inspect-item",
  295. children: [],
  296. },
  297. {
  298. id: 40202,
  299. authName: "巡检内容",
  300. path: "inspect-content",
  301. children: [],
  302. },
  303. {
  304. id: 40203,
  305. authName: "巡检线路",
  306. path: "inspect-line",
  307. children: [],
  308. },
  309. {
  310. id: 40204,
  311. authName: "巡检计划",
  312. path: "inspect-plan",
  313. children: [],
  314. },
  315. {
  316. id: 40205,
  317. authName: "综合管理",
  318. path: "inspect-manage",
  319. children: [],
  320. },
  321. {
  322. id: 40206,
  323. authName: "异常查询",
  324. path: "inspect-abnormal",
  325. children: [],
  326. },
  327. ],
  328. },
  329. {
  330. id: 403,
  331. authName: "工程仓库",
  332. path: "provider",
  333. children: [
  334. {
  335. id: 40301,
  336. authName: "供货管理",
  337. path: "provider",
  338. children: [],
  339. },
  340. {
  341. id: 40302,
  342. authName: "物品类别",
  343. path: "goods-cate",
  344. children: [],
  345. },
  346. {
  347. id: 40303,
  348. authName: "物品管理",
  349. path: "goods",
  350. children: [],
  351. },
  352. {
  353. id: 40304,
  354. authName: "入库管理",
  355. path: "enter-warehouse",
  356. children: [],
  357. },
  358. {
  359. id: 40305,
  360. authName: "出库管理",
  361. path: "out-of-warehouse",
  362. children: [],
  363. },
  364. {
  365. id: 40306,
  366. authName: "库存清单",
  367. path: "stock",
  368. children: [],
  369. },
  370. {
  371. id: 40307,
  372. authName: "台账记录",
  373. path: "ledger-rep",
  374. children: [],
  375. },
  376. {
  377. id: 40308,
  378. authName: "材料报表",
  379. path: "material-rep",
  380. children: [],
  381. },
  382. {
  383. id: 40309,
  384. authName: "月度结转",
  385. path: "carry-over",
  386. children: [],
  387. },
  388. ],
  389. },
  390. {
  391. id: 404,
  392. authName: "设备管理",
  393. path: "equip-ledger",
  394. children: [
  395. {
  396. id: 40401,
  397. authName: "设备台账",
  398. path: "equip-ledger",
  399. children: [],
  400. },
  401. {
  402. id: 40402,
  403. authName: "设备档案属性",
  404. path: "equip-attr",
  405. children: [],
  406. },
  407. {
  408. id: 40403,
  409. authName: "设备模板管理",
  410. path: "definition",
  411. children: [],
  412. },
  413. {
  414. id: 40404,
  415. authName: "设备档案模板",
  416. path: "template",
  417. children: [],
  418. },
  419. {
  420. id: 40405,
  421. authName: "生命周期管理",
  422. path: "life-time",
  423. children: [],
  424. },
  425. {
  426. id: 40406,
  427. authName: "设备预警管理",
  428. path: "warn",
  429. children: [],
  430. },
  431. {
  432. id: 40407,
  433. authName: "字典管理",
  434. path: "dictionary",
  435. children: [],
  436. },
  437. ],
  438. },
  439. {
  440. id: 405,
  441. authName: "知识库管理",
  442. path: "knowledge-uphold",
  443. children: [
  444. {
  445. id: 40501,
  446. authName: "知识库维护",
  447. path: "knowledge-uphold",
  448. children: [],
  449. },
  450. {
  451. id: 40502,
  452. authName: "知识库检索",
  453. path: "knowledge-search",
  454. children: [],
  455. },
  456. ],
  457. },
  458. ],
  459. },
  460. {
  461. id: 5,
  462. authName: "运维管理",
  463. path: "staff-manage",
  464. children: [
  465. {
  466. id: 501,
  467. authName: "运维配置",
  468. path: "staff-manage",
  469. children: [
  470. {
  471. id: 50101,
  472. authName: "员工管理",
  473. path: "staff-manage",
  474. children: [],
  475. },
  476. {
  477. id: 50102,
  478. authName: "角色管理",
  479. path: "role-manage",
  480. children: [],
  481. },
  482. {
  483. id: 50103,
  484. authName: "部门管理",
  485. path: "dep-manage",
  486. children: [],
  487. },
  488. {
  489. id: 50104,
  490. authName: "仓库管理",
  491. path: "ware-manage",
  492. children: [],
  493. },
  494. {
  495. id: 50105,
  496. authName: "仓库权限管理",
  497. path: "ware-permission",
  498. children: [],
  499. },
  500. {
  501. id: 50106,
  502. authName: "维修工时管理",
  503. path: "maintain-Hour",
  504. children: [],
  505. },
  506. {
  507. id: 50107,
  508. authName: "维修项目",
  509. path: "maintain-pro",
  510. children: [],
  511. },
  512. {
  513. id: 50108,
  514. authName: "地点管理",
  515. path: "place-manage",
  516. children: [],
  517. },
  518. {
  519. id: 50109,
  520. authName: "电话管理",
  521. path: "phone-manage",
  522. children: [],
  523. },
  524. ],
  525. },
  526. {
  527. id: 502,
  528. authName: "用户信息",
  529. path: "change-pwd",
  530. children: [
  531. {
  532. id: 50201,
  533. authName: "修改密码",
  534. path: "change-pwd",
  535. children: [],
  536. },
  537. {
  538. id: 50202,
  539. authName: "登录日志",
  540. path: "login-log",
  541. children: [],
  542. },
  543. ],
  544. },
  545. {
  546. id: 503,
  547. authName: "新闻配置",
  548. path: "add-news",
  549. children: [
  550. {
  551. id: 50301,
  552. authName: "添加新闻",
  553. path: "add-news",
  554. children: [],
  555. },
  556. {
  557. id: 50302,
  558. authName: "栏目管理",
  559. path: "news-program",
  560. children: [],
  561. },
  562. {
  563. id: 50303,
  564. authName: "新闻管理",
  565. path: "news",
  566. children: [],
  567. },
  568. ],
  569. },
  570. ],
  571. },
  572. ],
  573. };
  574. },
  575. created() {
  576. if (window.sessionStorage.getItem("activePath") === null) {
  577. this.activePath = "/screen";
  578. } else {
  579. this.activePath = window.sessionStorage.getItem("activePath");
  580. console.log("created-activePath", this.activePath);
  581. }
  582. },
  583. methods: {
  584. onMouseenter() {
  585. this.isShowDrawer = true;
  586. },
  587. //保存链接的激活状态
  588. saveNavState(activePath) {
  589. console.log("activePath", activePath);
  590. window.sessionStorage.setItem("activePath", activePath);
  591. this.activePath = activePath;
  592. },
  593. },
  594. };
  595. </script>
  596. <style lang="less" scoped>
  597. .rightSide {
  598. position: fixed;
  599. top: 0;
  600. left: 0;
  601. bottom: 0;
  602. width: 5px;
  603. opacity: 0;
  604. }
  605. /deep/.drawer {
  606. background: rgba(19, 27, 60, 0.95);
  607. }
  608. /deep/.el-drawer__body {
  609. overflow-y: auto;
  610. }
  611. // /*定义滚动条样式(高宽及背景)*/
  612. // ::-webkit-scrollbar {
  613. // width: 5px !important; //对应竖滚动条的宽度
  614. // }
  615. // /*定义滑块 样式*/
  616. // ::-webkit-scrollbar-thumb {
  617. // border-radius: 3px !important;
  618. // min-height: 50px !important; /* 滚动条滑块长度 */
  619. // background-color: rgba(42, 213, 252, 0.5) !important;
  620. // }
  621. .el-menu-item:hover {
  622. background: rgba(84, 122, 179, 0.5);
  623. }
  624. i {
  625. margin-right: 0.3rem;
  626. }
  627. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/225789
推荐阅读