<template>
  <div class="menu">
    <div class="menu-box" v-for="(item,index) in menu_tree" :key="index" @click.stop="changeShow(item,level,index)" :style="{'margin-left': level>1?'20px':'0px','text-indent':'8px','border-left':level>1? '1px solid #3a87b1' :'1px solid rgba(0,0,0,0)'}" >
        <div class="type-name">
          <p :style="{'color':item.show ? '#3a87b1' :'#8a91aa'}"> 
            <i class="el-icon-caret-bottom" v-show="item.children && item.children.length>0 && !item.show"></i> 
            <i class="el-icon-caret-top" v-show="item.children && item.children.length>0 && item.show"></i>
            <span v-show="item.children && item.children.length==0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
            {{item.name}}</p>
          <div v-show="item.children && item.children.length>0 && item.show"  class="point"></div>
        </div>
        
        <LayerTree v-show="item.children && item.children.length>0 && item.show" :menu_tree="item.children" :level="level+1" ></LayerTree>
    </div>
  </div>
</template>
<script>
export default {
  name:"LayerTree",
  props:["menu_tree","level"],
  data(){
    return {
      
    }
  },
  methods:{
    changeShow(item,level,index){
        console.log(level,index);
        console.log(item);
       if(item.children && item.children.length>0){
          item.show = !item.show;
          console.log(item.show);
       }
    }
  }
}
</script>
<style scoped>
.menu{
  width:100%;
  min-height:30px;
}
.menu-box{
  width:100%;
  min-height:30px;
  line-height:30px;
  color:#fff;
  cursor:pointer;
  /* color:#37c9fa; */
  color:#efefef;
}
.type-name{
  width:100%;
  height:30px;
  position: relative;

}
.type-name p{
  position:relative;
}
.point{
  width:5px;
  height:5px;
  border-radius: 50%;
  background:#37c9fa;
  position:absolute;
  left:18px;
  bottom:-2.5px;
}
::v-deep [class*=" el-icon-"], [class^=el-icon-]{
  text-align: center;
}
</style>