<template>
    <!-- <div id="sjgl">
        <div class="left-nav">
            <el-menu default-active="1" class="el-menu-vertical-demo second-router" @open="handleOpen" @close="handleClose" background-color="transparent" text-color="#fff" @select="handleSelect">
                <template v-for="(item, index) in module">
                    <el-menu-item :class="index == choice_status ? 'change-bg' : 'change-bg1'" :index="(index + 1).toString()" @click="href_choice(item, index)">
                        <div>
                            <i :class="item.icon"></i>
                            <span v-text="item.name"></span>
                        </div>
                    </el-menu-item>
                </template>
            </el-menu>
        </div>
        <div class="right-nav">
            <keep-alive>
                <router-view v-if="isRouterAlive"> </router-view>
            </keep-alive>
        </div>
    </div> -->
    <el-container class="myContainer">
        <el-header class="myHeader">
            <el-menu default-active="1" class="second-router" mode="horizontal" @open="handleOpen" @close="handleClose"
                background-color="transparent" text-color="#fff" @select="handleSelect">
                <template v-for="(item, index) in module">
                    <el-menu-item :class="index == choice_status ? 'change-bg' : 'change-bg1'"
                        :index="(index + 1).toString()" @click="href_choice(item, index)">
                        <div>
                            <i :class="item.icon"></i>
                            <span v-text="item.name"></span>
                        </div>
                    </el-menu-item>
                </template>
            </el-menu>
        </el-header>
        <el-main class="myMain">
            <keep-alive>
                <router-view v-if="isRouterAlive"> </router-view>
            </keep-alive>
        </el-main>
    </el-container>
</template>

<style lang="scss">
.myContainer {
    width: 100%;
    height: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;

    .myHeader {
        width: 100%;
        height: 40px !important;
        padding: 0px 60px;

        .el-menu.el-menu--horizontal {
            border: none;

            &>.el-menu-item {
                height: 40px;
                line-height: 40px;
                border-bottom: none !important;

                &:not(:first-child) {
                    margin-left: 10px;
                }
            }
        }
    }

    .myMain {
        width: 100%;
        height: calc(100% - 40px);
        padding: 0px 20px !important;
        background-color: transparent;
        overflow: hidden;
    }
}
</style>

<script>
import li_hover from "../../assets/img/main/04.png";
import bottom from "../../assets/img/main/bottom.png";
export default {
    name: 'user',
    provide() {
        return {
            reload: this.reload
        }
    },
    data() {
        return {
            li_hover: li_hover,
            bottom: bottom,
            module: [],
            index: 0,
            choice_status: 0,
            isRouterAlive: true
        }
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        href_choice(item, index) {
            this.choice_status = index;
            this.$router.push(item.path);
        },
        handleSelect(key, keyPath) { },
        reload() {
            this.isRouterAlive = false;
            this.$nextTick(function () {
                this.isRouterAlive = true;
            })
        }
    },
    mounted() {
        this.module = this.$store.state.navList[0].children.
            filter(e => e.meta && e.meta.code == this.$route.meta.parentCode)[0].children.
            filter(e => e.icon);
    },
    computed: {
    }
}
</script>