<template>
        <el-tabs v-model="tabName" @tab-click="handleClick" :class="{
            'nveu-su-tab':true,
            'just-active-show':justActiveShow,
            'no-just-active-show':!justActiveShow,
        }">
            <slot/>
        </el-tabs>
</template>

<script>
export default {
    name: "index",
    data() {
        return {
            tabName: ""
        }
    },
    props: {
        value: {
            type: String
        },
        justActiveShow: {
            type: Boolean,
            default: false,
        },
        activeName: {
            type: String,
            default: '',
        }
    },
    watch: {
        activeName(newTabName) {
            this.tabName = newTabName;
        }
    },
    model: {
        prop: 'value',
        event: 'change'
    },
    created() {
        this.tabName = this.value || this.activeName;
    },
    methods: {
        handleClick(tab, event) {
            this.$emit("tab-click", {tab, event});
            this.$emit("update:activeName", this.tabName);
            this.$emit('change', this.tabName);
        }
    }
};
</script>

<style lang="less">
.nveu-su-tab{
    display: inline-block;
    width: 100%;
    &.just-active-show {
        & > .el-tabs__header {
            .el-tabs__item:not(.is-active) {
                display: none;
            }

            .el-tabs__item.is-active {
                text-align: left;
                padding: 0;
            }
        }
    }
     .el-tabs__nav {
        width: 100%;
        display: flex;
    }

     .el-tabs__item {
        height: 54px;
        line-height: 54px;
        font-size: 16px;
        flex: 1;
        text-align: center;
    }

     .el-tabs__header {
        margin: 0;
    }

     .el-tabs__nav-wrap::after {
        height: 0;
    }

     .el-tabs__new-tab {
        display: none;
    }
}
</style>
