<template>
  <!-- 分析项 -->
  <div class="custom-analyse-tabs-item">
    <el-collapse v-model="activeItem2">
      <el-collapse-item v-for="menu in treeList" :name="menu.id">
        <template slot="title">
          <div class="custom-title">
            <span class="label">{{ menu.name }}</span>
            <span class="do" v-if="$permission('/workspace/folder/analyticSystem/chartAnalysis/groupModify') && $r(projectId,[1,2])">
              <i class="el-icon-edit" @click.stop="handleEdit(menu)"></i>
              <i class="el-icon-delete" @click.stop="handleDelete(menu)"></i>
            </span>
          </div>
        </template>
        <div v-for="item in menu.children" @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" v-if="$permission('/workspace/folder/analyticSystem/chartAnalysis/groupItemDelete') && $r(projectId,[1,2])">
              <i class="el-icon-delete" @click.stop="handleDelete(item)"></i>
            </span>
          </div>
        </div>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

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

export default {
  mixins: [mixins],
  data() {
    return {
      activeItem2: this.activeItem,
    }
  },
  mounted() {
  },
  methods: {
    handleEdit(value) {
      this.$emit('edit', value)
    },
    handleDelete(value) {
      this.$emit('delete', value)
    },
    handleSelect(key) {
      this.$emit('select', key)
    }
  }
}
</script>

<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>