LeftSideMenuLv2.vue 1.92 KB
<template>
  <div class="com-left-side-menu-lv2">
    <GLScroll class="com-left-side-menu-lv2-scroll-y">
      <el-menu class="flex-1 none-border" background-color="#fff" active-text-color="#409EFF" text-color="#999" :default-openeds="cur.openeds" :default-active="cur.active" :collapse-transition="false">
        <LeftSideMenuLv2Item></LeftSideMenuLv2Item>
      </el-menu>
    </GLScroll>
  </div>
</template>

<script>
import { currentId } from './mixins/index'
export default {
  name: 'LeftSideMenuLv2',
  mixins: [currentId],
  inject: ['bus'],
  created() {
    this.bus.$on('current', this.handleCurrentChange)
    this.bus.$on('menuOpenedsChanged', this.handleMenuOpenedsChanged)
  },
  mounted() {
    this.handleCurrentChange(this.current)
  },
  beforeDestroy() {
    this.bus.$off('current', this.handleCurrentChange)
    this.bus.$off('menuOpenedsChanged', this.handleMenuOpenedsChanged)
  },
  data() {
    return {
      cur: {
        openeds: [],
        active: ''
      }
    }
  },
  methods: {
    handleCurrentChange({ lv1, lv2, lv3 }) {
      this.cur.active = `${lv1}-${lv2}-${lv3}`
    },
    handleMenuOpenedsChanged({ menus }) {
      const _ids = menus.map(({ id, children = [] }) => {
        if (children.noHidden().length) {
          return id
        }
      })
      if (this.cur.openeds.toString() == _ids.toString()) return
      this.cur.openeds = _ids
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/assets/style/collapse.scss';
.com-left-side-menu-lv2 {
  width: 100%;
  user-select: none;
  overflow-y: auto;
  flex: 1;
  // .menu-wrap {
  // height: 100%;
  /deep/.el-menu {
    height: 100%;
    width: calc(#{$menu_width} - #{$menu_width_collapse} - 1px);
  }
  // }
  &-scroll-y {
    /deep/.el-scrollbar__wrap {
      margin-bottom: 0 !important ;
      .el-scrollbar__view {
        min-height: 52px;
        max-height: calc(100vh - #{$logo-height});
      }
    }
    height: 100%;
  }
}
</style>