p-menu-item.vue 2.9 KB

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