(function(){
    Vue.component('area-data-panel',{
        template: '
\
                
\
                
\
                    \
                        | {{th}} | \
                         | \
                    
\
                    \
                        \
                            | \
                                 {{row.rank}} \
                                {{col}} \
                                {{col}}\
                             | \
                             | \
                        
\
                    \
                
\
            
 ',
        props:[],
        data: function(){
            return {
                level: '',
                lowLevel: '',
                area: '',
                headers: [],
                rows: [],
                cityLevelNoShowTeamTab: false,
                districtLevelNoShowTeamTab: false
            }
        },
        mounted: function(){
            var vm = this;
            EventBus.$on("render-area-data", function(arg){
                vm.level = arg.level;
                vm.lowLevel = arg.lowLevel;
                vm.area = arg.area;
                vm.headers = arg.headers;
                vm.rows = arg.rows;
                vm.cityLevelNoShowTeamTab = arg.cityLevelNoShowTeamTab;
                vm.districtLevelNoShowTeamTab = arg.districtLevelNoShowTeamTab;
            })
        },
        computed: {
            showTeamTab: function(){
                if(this.cityLevelNoShowTeamTab){
                    if(this.level == 4){
                        return false;
                    }else{
                        if(this.districtLevelNoShowTeamTab){
                            if(this.level == 3){
                                return false;
                            }else{
                                return true;
                            }
                        }else{
                            return true;
                        }
                    }
                }else{
                    return true;
                }
            }
        },
        methods: {
            getLowLeverData: function(row){
                if(this.level > 2 && this.lowLevel != 1){
                    //跳转去下一级数据
                    if(this.lowLevel && (this.level - this.lowLevel) >= 2){
                        //从次级tab的内容查看再下一级的数据
                        this.level = this.level - 2;
                        this.lowLevel --;
                    }else{
                        this.level --;
                        this.lowLevel = '';
                    }
                    this.area = row.code;
                    this.areaTitle = row.name;
                    //触发组件监听事件,去父页面请求新的数据
                    this.$emit("getnewdata", {
                        level: this.level,
                        area: this.area,
                        areaTitle: this.areaTitle,
                        lowLevel: this.lowLevel,
                    });
                }else{
                    //弹框显示团队信息
                    Vuedals.Bus.$emit('new', {
                        title: '团队信息',
                        component: 'team-info',
                        props: {
                            teamId: row.code
                        }
                    });
                }
            },
            getLowCodeData: function(code){
                if(code == 3){
                    this.lowLevel = '';
                }else{
                    this.lowLevel = code;
                }
                
                //触发组件监听事件,去父页面请求新的数据
                this.$emit("getnewdata", {
                    level: this.level,
                    area: this.area,
                    lowLevel: this.lowLevel
                });
            }
        }
    });
})()