<template>
    <awsui-layout id="create" v-loading="loading" :element-loading-text="loadingText">
        <awsui-main id="createMain" :style="{width: '100%',padding:0,height:bodyHeight}">
            <!--空白页面-->
            <div style="width:100%;height: 100%;">
                <div style="width:100%;height: 300px;margin: auto;position: relative;top: 35%">
                    <div style="text-align: center;">
                        <span><i class="iconfont" style="color: #C2C2C2;font-size: 60px;">&#xe65e;</i></span>
                        <p class="text-general-color" style="margin: 15px 0;">您还没加入任何小组！</p>
                    </div>
                    <div v-if="isManage" style="text-align:center;">
                        <awsui-button class="button-general-color text-general-color" type="primary" @click="createTeam">创建小组</awsui-button>
                    </div>
                </div>
            </div>
        </awsui-main>
        <cooperation-update
                ref="cooperationUpdate"
                :visible.sync="update.visible"
                :teamId="update.teamId"
                v-on:cancel="update.visible = false"
                v-on:getResult="updateDone"
                :title="update.title"
        />
    </awsui-layout>
</template>

<script>
    import CooperationUpdate from "../../components/CooperationUpdate/component";
    import awsuiAxios from "../../awsuiAxios";
    export default {
        name: "Create",
        components: {CooperationUpdate},
        data() {
            return {
                bodyHeight : (document.documentElement.clientHeight) + 'px',
                isManage: isManage,
                update: {
                    visible: false,
                    teamId: '',
                    title: '创建小组'
                },
                loading: false,
                loadingText: '正在保存',
            }
        },
        mounted() {
            const that = this;
            that.resize();
        },
        methods : {
            createTeam() {
                this.update.teamId = '';
                this.update.visible = true;
            },
            updateDone(result) {// 新建、更新保存
                const that = this;
                if (result == 'ok') {
                    this.update.visible = false;
                    parent.location.reload();
                }
            },
            resize() {// 窗口监听window.resize
                const that = this
                let resizeTimer = null;
                window.onresize = () => {
                    return (() => {
                        if (resizeTimer) clearTimeout(resizeTimer);
                        resizeTimer = setTimeout(function(){
                            that.bodyHeight = (document.documentElement.clientHeight) + 'px';
                        } , 400);
                    })()
                }
            },
        }
    }
</script>

<style scoped>

</style>