<template>
  <!-- 分析项 -->
  <div class="custom-analyse-tabs-item height_100">
    <el-container>
      <el-header>
        <div class="head">
          <el-button size="small" type="primary" @click="handleAdd3">添加组</el-button>
        </div>
      </el-header>
      <el-main>
        <el-collapse v-model="activeItem2">
          <el-collapse-item v-for="menu in treeList" :key="menu.id" :name="menu.id">
            <template slot="title">
              <div class="custom-title">
                <span class="label">{{ menu.name }}</span>
                <span class="do">
                  <i class="el-icon-edit" @click.stop="handleEdit(menu,1)"></i>
                  <i class="el-icon-delete" @click.stop="handleDelete(menu,1)"></i>
                </span>
              </div>
            </template>
            <div v-for="item in menu.children" :key="item.uid" @click="handleSelect(item.uid)" class="tree-item" :class="{ 'is-active2' : item.uid === form.uid }">
              <div class="custom-title">
                <span class="label">{{ item.name }}</span>
                <span class="do">
                  <i class="el-icon-delete" @click.stop="handleDelete(item,2)"></i>
                </span>
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
      </el-main>
    </el-container>
    
  </div>
</template>

<script>
import mixins from "./mixins";

export default {
  mixins: [mixins],
  data() {
    return {
      activeItem2: this.activeItem,
    }
  },
  mounted() {
  },
  methods: {
    handleEdit(value,type) {
      this.$emit('edit', value,type)
    },
    handleDelete(value,type) {
      this.$emit('delete', value,type)
    },
    handleSelect(key) {
      this.$emit('select', key)
    },
    handleAdd3(){
      this.$emit('handleAdd3')
    },
  }
}
</script>
<style lang="scss" scoped>
  .head{
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-right:10px;
  }
</style>
<style lang="scss">
.custom-analyse-tabs-item {
  .el-collapse-item__header {
    padding: 0 15px !important;
    font-weight: bold;
    border-bottom: 1px solid #EBEEF5 !important;
  }
  .el-collapse {
    border-top: 0 !important;
  }
  .tree-item {
    padding: 0 25px;
    height: 45px;
    cursor: pointer;
  }
  .el-collapse-item__content {
    padding-bottom: 0 !important;
  }
  .is-active2 {
    background: #ecf5ff !important;
    color: #409EFF!important;
  }
  .custom-title {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 10px;
    height:100%;
    .label {
      display: flex;
      align-items: center;
      height: 100%;
    }
    .do {
      display: none;
      i {
        margin-left: 10px;
        margin-top: -5px;
        color: #999;
        font-size: 13px;
      }
      &:hover {
        color: #333;
      }
    }
    &:hover {
      .do {
        display: inline-block;
      }
    }
  }
}
</style>