layout.vue 3.41 KB
<template>
    <Row type="flex" class-name="layout" :class="layoutClass">
        <Col :span="6" class="layout-menu-left">
            <PurviewMenu :class="menuClass"></PurviewMenu>
        </Col>
        <Col :span="18" class="layout-menu-right">
            <UserInfo @menu-trigger="menuTrigger" :class="userClass" @shop-change="shopChange"></UserInfo>
            <div class="layout-breadcrumb">
                <Breadcrumbs @menu-trigger="menuTrigger" :class="breadClass"></Breadcrumbs>
            </div>
            <div class="layout-content">
                <router-view v-if="reload"></router-view>
            </div>
            <div class="layout-copy">
                2011-2016 &copy; YOHO集团
            </div>
        </Col>
    </Row>
</template>

<script>
export default {
    name: 'layout',
    data() {
        return {
            layoutClass: {
                collapse: false
            },
            menuClass: {
                'menu-collapse': false
            },
            breadClass: {
                'bread-collapse': false
            },
            userClass: {
                'user-collapse': false
            },
            reload: true
        };
    },
    methods: {
        menuTrigger() {
            this.menuClass['menu-collapse'] = !this.menuClass['menu-collapse'];
            this.userClass['user-collapse'] = !this.userClass['user-collapse'];
            this.breadClass['bread-collapse'] = !this.breadClass['bread-collapse'];
            this.layoutClass.collapse = !this.layoutClass.collapse;
            setTimeout(() => {
                let evtStart = document.createEvent('UIEvent');

                evtStart.initUIEvent('resize', true, true);
                window.dispatchEvent(evtStart);
            }, 500);
        },
        shopChange() {
            this.reload = false;
            this.$nextTick(() => {
                this.reload = true;
            });
        }
    }
};
</script>

<style lang="scss">
body {
    color: #444;
}

.layout {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    min-width: 800px;

    &.collapse {
        .layout-menu-left {
            width: 50px;
            min-width: initial;
        }
    }

    .layout-menu-left {
        background: #464c5b;
        min-width: 170px;
        max-width: 250px;
    }

    .layout-menu-right {
        flex: 1;
        display: flex;
        flex-flow: column;

        .layout-breadcrumb {
            padding: 10px 15px;
        }

        .layout-content {
            min-height: 200px;
            padding: 25px;
            padding-top: 10px;
            overflow-y: scroll;
            background: #fff;
            border-radius: 4px;
            flex: 1;
        }

        .layout-copy {
            text-align: center;
            padding: 10px 0 20px;
            color: #9ea7b4;
        }
    }
    .clear-fixed {
        clear: both;
    }
}


.layout-menu-left {
    transition: width .1s ease-in-out;
}

.ivu-table {
    table {
    }
}


.layout-logo-left {
    width: 90%;
    height: 30px;
    border-radius: 3px;
    background-image: url(../images/logo.png);
    background-repeat: no-repeat;
    margin: 15px auto;
}

.layout-ceiling-main a {
    color: #9ba7b5;
}

.layout-hide-text .layout-text {
    display: none;
}

.ivu-menu-item-group-title {
    color: #9ea7b4 !important;
}
.ivu-menu-item {
    color: #fff !important;
}
</style>