<template>
  <div>
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <div v-show="isShow" class="img-wrapper"><img :src="require('@/assets/img/LOGO.jpg')"></div>
      <el-menu
        :show-timeout="200"
        :default-active="$route.path"
        :collapse="isCollapse"
        mode="vertical"
        background-color="#2d323c"
        text-color="#cccccc"
        active-text-color="#2d323c"
        style="height:calc(100% - 124px)"
      >
        <sidebar-item v-for="route in permission_routers" :key="route.name" :item="route" :base-path="route.path"/>
      </el-menu>
    </el-scrollbar>
  </div>

</template>

<script>
import { mapGetters } from 'vuex'
import SidebarItem from './SidebarItem'

export default {
  components: { SidebarItem },
  data() {
    return {
      isShow: ''
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'permission_routers'
    ]),
    routes() {
      return this.$router.options.routes
    },
    isCollapse() {
      this.showLogo()
      return !this.sidebar.opened
    }
  },
  methods: {
    showLogo() {
      if (this.sidebar.opened === true) {
        this.isShow = true
      } else {
        this.isShow = false
      }
    }
  }
}
</script>
<style lang="scss" scoped>
  .img-wrapper{
    img{
      width: 100%;
      height: 97px;
      margin: 52px 0px 52px 0px;
      background-color: #A5CF4D!important;
    }
  }
</style>
