<template>
    <div class="container">
        <banner></banner>
        <div class="center-content" style="padding-top: 60px">
            <menu-page>
                <div class="menu-content" slot="menuList">
                    <el-menu :default-active="active" class="menu-content" unique-opened router>
                        <sys-menu v-for="item in menus" :menu="item" :key="item.id"></sys-menu>
                    </el-menu>
                </div>

                <div class="main">
                    <router-view ref="child"></router-view>
                </div>
            </menu-page>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
import Banner from '../../components/Banner.vue';
import MenuPage from '../../components/page/MenuPage.vue';
import SysMenu from '../../components/SysMenu.vue';
import menu from '../../mixins/menu';
export default {
    components: { MenuPage, Banner, SysMenu },
    mixins: [menu],
    data() {
        return {};
    },
    computed: {
        ...mapState(['showAdd'])
    },
    watch: {
        $route() {
            this.scrollTo();
        }
    },
    mounted() {
        this.$http
            .post('navigation/backAll', {
                type: 'MARKET'
            })
            .then(res => {
                this.menus = res;
                this.findActive();

                this.scrollTo(true);
            });
        if (this.showAdd) {
            console.log('新增');
            this.$store.commit('updateShowAdd', false);
            this.$nextTick(() => {
                if (this.$refs.child.addInfo) {
                    this.$refs.child.addInfo();
                }
                if (this.$refs.child.btnEvent) {
                    this.$refs.child.btnEvent();
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
.container {
    background-color: @bg;
}

.main {
    min-height: 1080px;
    flex-grow: 1;
    .flex-col();
}

.menu-content {
    min-height: 800px;
    background-color: #fff;
}
</style>
