p-menu-item.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div>
  3. <template v-for="(menu, index) in menuData">
  4. <el-submenu
  5. :key="menu.index"
  6. :index="
  7. menu.rountPath == '' || menu.rountPath == '#'
  8. ? menu.name + index
  9. : menu.rountPath
  10. "
  11. v-if="menu.children"
  12. @click="handelRouterTo(menu)"
  13. >
  14. <template slot="title">
  15. <i style="color: #409eff !important" class="el-icon-location"></i>
  16. <el-tooltip
  17. class="item"
  18. effect="dark"
  19. :content="menu.name"
  20. placement="right"
  21. v-if="menu.name.length > 9"
  22. ><span>{{ menu.name }}</span>
  23. </el-tooltip>
  24. <span v-else>{{ menu.name }}</span>
  25. </template>
  26. <MenuTree :menuData="menu.children"></MenuTree>
  27. </el-submenu>
  28. <el-menu-item
  29. v-show="menu.systemflag != 1"
  30. @click="handelRouterTo(menu)"
  31. :index="menu.rountPath == '' ? menu.name : menu.rountPath"
  32. :key="menu.index"
  33. v-else
  34. >
  35. <el-tooltip
  36. class="item"
  37. effect="dark"
  38. :content="menu.name"
  39. placement="right"
  40. v-if="menu.name.length > 9"
  41. ><span>{{ menu.name }}</span>
  42. </el-tooltip>
  43. <span v-else>{{ menu.name }}</span>
  44. </el-menu-item>
  45. </template>
  46. </div>
  47. </template>
  48. <script>
  49. export default {
  50. name: "MenuTree",
  51. props: ["menuData"],
  52. methods: {
  53. handleOpen(e) {
  54. if (e.indexOf("/") != -1) {
  55. if (this.$route.path != e) {
  56. this.$router.push(e);
  57. }
  58. }
  59. },
  60. handleClose() {},
  61. handelRouterTo(item) {
  62. if (item.systemflag == "1") {
  63. return;
  64. }
  65. for (let i = 0; i < this.$store.state.tabList.length; i++) {
  66. if (this.$store.state.tabList[i].rountPath === item.rountPath) {
  67. this.$store.state.tabList[i] = item;
  68. }
  69. }
  70. let set = new Set([...this.$store.state.tabList, item]);
  71. set.add(item);
  72. this.$store.commit("setDefaultActive", item.rountPath);
  73. this.$store.commit("setTabList", Array.from(set));
  74. },
  75. },
  76. };
  77. </script>
  78. <style lang="scss" scoped>
  79. .el-submenu {
  80. border-bottom: 1px solid #ececec;
  81. }
  82. .is-opened .el-submenu__title {
  83. /* background-color: #ecf5ff !important; */
  84. background-color: #dddddd !important;
  85. border-left: 3px solid #34a0ce;
  86. }
  87. .el-submenu__title:hover {
  88. background-color: #bbbbbb !important;
  89. border-left: 3px solid #34a0ce;
  90. }
  91. .is-opened .el-submenu__title:hover {
  92. background-color: #bbbbbb !important;
  93. border-left: 3px solid #34a0ce;
  94. }
  95. ::v-deep .el-submenu__title {
  96. padding-left: 30px !important;
  97. .el-submenu__icon-arrow {
  98. position: absolute;
  99. right: 8px;
  100. }
  101. /* background-color: #ecf5ff;
  102. border-radius: 30px;
  103. margin-bottom: 10px; */
  104. }
  105. .el-submenu.is-active .el-submenu__title {
  106. /* background-color: #ecf5ff; */
  107. }
  108. </style>
  109. <style lang="scss" scoped>
  110. .el-menu-item {
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. width: 50px;
  115. padding-left: 60px !important;
  116. background: #2e7dcf;
  117. span {
  118. padding-right: 10px;
  119. color: #bdddff;
  120. }
  121. }
  122. .el-menu-item:hover {
  123. background: #577494;
  124. }
  125. .el-menu--vertical {
  126. .el-menu-item {
  127. width: auto !important;
  128. span {
  129. padding-right: 0;
  130. }
  131. }
  132. }
  133. .bgc {
  134. background-color: #f56c6c;
  135. }
  136. .bgcChild {
  137. background-color: #f56c6c;
  138. }
  139. </style>