index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <el-submenu v-if="menu.children && menu.children.length >= 1" :index="menu.id.toString()">
  3. <template slot="title">
  4. <i class="iconfont" :class="menu.icon"></i>
  5. <span slot="title" class="firstMenu" >{{ menu.name }}</span>
  6. </template>
  7. <MenuTree v-for="item in menu.children" :key="item.id" :menu="item"></MenuTree>
  8. </el-submenu>
  9. <el-menu-item v-else :index="menu.id.toString()" @click="handleRoute(menu)">
  10. <i class="iconfont" :class="menu.icon" ></i>
  11. <span slot="title">{{ menu.name }}</span>
  12. </el-menu-item>
  13. </template>
  14. <script>
  15. import { getIFrameUrl, getIFramePath } from '@/utils/iframe'
  16. export default {
  17. name: 'MenuTree',
  18. props: {
  19. menu: {
  20. type: Object,
  21. required: true
  22. }
  23. },
  24. data () {
  25. return {
  26. }
  27. },
  28. created() {
  29. },
  30. methods: {
  31. handleRoute(menu) {
  32. // 如果是嵌套页面,转换成iframe的path
  33. let path = getIFramePath(menu.url)
  34. if (!path) {
  35. path = menu.url
  36. }
  37. // 通过菜单URL跳转至指定路由
  38. this.$router.push("/" + path)
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped lang="scss">
  44. /deep/ {
  45. .el-menu-item {
  46. margin: 4px 0 ;
  47. }
  48. .el-menu--popup-right-start{
  49. padding: 10px;
  50. box-sizing: border-box;
  51. }
  52. .el-submenu__title:hover{
  53. background-color: rgba(212,36,38,0.1) !important;
  54. border-radius: 4px !important;
  55. }
  56. .el-menu-item:hover{
  57. background-color: rgba(212,36,38,0.1) !important;
  58. border-radius: 4px !important;
  59. }
  60. }
  61. .el-menu-item.is-active {
  62. // background-color: #428BCA !important;
  63. background: linear-gradient(90deg, #F34747 0%, #DF3739 100%);
  64. box-shadow: 2px 4px 8px 0px rgba(212, 36, 38, 0.2);
  65. border-radius: 4px;
  66. color: #fff !important;
  67. z-index: 999;
  68. }
  69. </style>