<template>
    <el-container class="flex-column">
        <div class="channel_menu">
            <el-menu mode="horizontal" class="channel-tabs" :default-active="activeName" @select="handleClick">
                <el-menu-item :index="item.key" v-for="(item,indx) in menuData" :key="indx">{{item.name}}</el-menu-item>
            </el-menu>
        </div>
        <div class="table-search">
            <search @success="handleSuccess"></search>
            <optionBtn @success="handleSuccess" :dataSelect="dataSelect" :dataSelectFull="dataSelectFull" ></optionBtn>
        </div>
        <el-main class="nopadding">
            <div class="table-container">
                <tablePage ref="tablePage" @success="tableHandle" @successFull="tableHandleFull"></tablePage>
            </div>
        </el-main>
    </el-container>  
</template>

<script>
import search from './components/search';
import optionBtn from './components/option';
import tablePage from './components/table';
export default {
    components: {
        search,tablePage,optionBtn
    },
    data(){
        return {
            activeName:"first",
            menuData:[],
            searchKey:{},
            dataSelect:[],
            dataSelectFull:[],
        }
    },
    mounted(){
        // this.getMenuData();
    },
    methods: {
        tableHandle(data){
            this.dataSelect = data;
        },
        tableHandleFull(data){
            this.dataSelectFull = data;
        },
        handleSuccess(data){
            this.$refs.tablePage.upData(data)
        },
        async getMenuData(){
            var resp = await this.$API.common.menu.get({"type":"account"});
            if (resp.code !== 1) {
                return this.$message.error(resp.msg);
            }
            this.activeName = resp.data.default;
            this.menuData = resp.data.menu;
        },
        handleClick(name){
            this.activeName = name;
            this.searchKey.type = name;
            this.$refs.tablePage.upData(this.searchKey)
        }
    }
}
</script>