<template>
  <div id="mainLeft">
    <el-row>
      <el-col :span="24">
        <el-menu :default-active="path" class="el-menu-vertical-demo" :router="true">
          <template v-for="(item, index) in subMenu">
            <template v-if="item.children&&item.children.length>0">
                <template v-for="(sec) in item.children">
                  <el-menu-item :index="sec.path" :key="sec.id" v-if="sec.type !== 'url'">{{ sec.title }}</el-menu-item>
                  <el-menu-item :index="``" :key="sec.id" @click="turnTo(sec.url)" v-else> {{ sec.title }}</el-menu-item>
                </template>
            </template>
            <el-menu-item :index="item.path" :key="index" v-else-if="item.type === 'content'||item.type==='column'">{{ item.title }}</el-menu-item>
            <el-menu-item :index="`${index}-${subIndex}`" :key="index" @click="turnTo(item.url)" v-else> {{ item.title }}</el-menu-item>
          </template>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapActions, mapState,mapMutations } from 'vuex';
export default {
  name: 'mainLeft',
  props: {},
  components: {},
  data: () => ({}),
  created() {this.getSubMenu()},
  watch:{
    path: 'getSubMenu',
  },
  computed: {
    ...mapState(['subMenu']),
    path(){
      return this.$route.path;
    },
  },
  methods: {
    ...mapMutations(['setSubMenu']),
    getSubMenu(){
      this.setSubMenu(this.path);
    },
  },
};
</script>

<style lang="less" scoped>
.info {
  height: 44px;
  line-height: 44px;
  padding: 0 15px;
}
.info .title {
  border-bottom: 1px dashed #ccc;
  display: inline-block;
  height: 40px;
  width: 260px;
  padding: 0 0px;
}
</style>
