<!--
  应用公共左侧菜单：
  <common-detail-left
    :tabListData="tabListData"
    @setSelectTab="setSelectTab">
  </common-detail-left>
 -->
<template>
  <div>
    <ul class="tab-left-list">
      <template v-for="(item, index) in tabListData">
        <li :class="['tab-left-list-cell color-303133 font-14 border-box p-l-14', item.tabId == activeTab ? 'active-tab' : '']" :key="index" @click="selectTab(item)"><i :class="['p-r-10 color-303133 iconfont', item.icon]"></i>{{ item.tabName }}</li>
        <ul class="child-tab-left-list" :key="'childitem' + index">
          <template v-for="(childitem, childIndex) in item.children">
            <li :class="['tab-left-list-cell color-303133 font-14 border-box', childitem.tabId == activeTab ? 'active-tab' : '']" :key="childIndex" @click="selectTab(childitem)">{{ childitem.tabName }}</li>
            <ul class="third-tab-left-list" :key="'thirditem' + childIndex">
              <template v-for="(thirditem, thirdIndex) in childitem.children">
                <li :class="['tab-left-list-cell color-303133 font-14 border-box', thirditem.tabId == activeTab ? 'active-tab' : '']" :key="thirdIndex" @click="selectTab(thirditem)">{{ thirditem.tabName }}</li>
              </template>
            </ul>
          </template>
        </ul>
      </template>
    </ul>
  </div>
</template>
<script>
export default {
  name: 'common-detail-left',
  props: {
    appName: {
      type: String,
      default() {
        return '';
      }
    },
    tabListData: {
      type: [Array, Object],
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      projectName: '', // 当前项目名
      activeTab: '1'
    };
  },

  methods: {
    /**
     * 返回
     */
    returnBack() {
      let that = this;
      that.$router.push('appcenter');
    },
    selectTab(item) {
      let that = this;
      that.activeTab = item.tabId;
      that.$emit('setSelectTab', item);
    }
  }
};
</script>
<style type="text/scss" lang="scss" scoped>
.tab-left-list {
  .tab-left-list-cell {
    position: relative;
    text-align: left;
    margin-top: 15px;
    height: 30px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;

    &:hover {
      background: rgba(24, 144, 255, 0.06);
      i {
        color: #1890ff;
      }
    }
    &.active-tab {
      background: rgba(24, 144, 255, 0.06);
      &::before {
        content: ' ';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 2px;
        background: #1890ff;
        z-index: 1;
      }
      i {
        color: #1890ff;
      }
    }

    .child-tab-left-list {
      li {
        position: relative;
        text-align: left;
        height: 30px;
        line-height: 30px;
        white-space: nowrap;
        overflow: hidden;
        cursor: pointer;

        &:hover {
          background: rgba(24, 144, 255, 0.06);
          i {
            color: #1890ff;
          }
        }
        &.active-tab {
          background: rgba(24, 144, 255, 0.06);
          &::before {
            content: ' ';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 2px;
            background: #1890ff;
            z-index: 1;
          }
          i {
            color: #1890ff;
          }
        }
      }
    }
  }
}
</style>
