const _Http = getApp().globalData.http;
Component({
    options: {
        addGlobalClass: true,
    },
    properties: {
        update: {
            type: Function
        }
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
            this.triggerEvent('update', "Client")
        }
    },
    data: {
        tabsActive: 0,
        tabsList: [{
            label: "数据概况",
            model: "#DataOverview"
        }, {
            label: "业务员营销费用TOP10",
            model: "#SPmarketingExpenses"
        }, {
            label: "营销费用类型情况统计",
            model: "#TypeOfCost"
        }, {
            label: "营销费用来源情况统计",
            model: "#SourceOfExpenses"
        }, {
            label: "医院类型营销费用情况统计",
            model: "#CustomerTypeFee"
        }, {
            label: "项目类型营销费用情况统计",
            model: "#ProjectTypeFee"
        }],
        init: false
    },
    methods: {
        getList() {
            this.partialRenewal()
            this.data.init = true;
        },
        tabsChange({
            detail
        }) {
            this.setData({
                tabsActive: detail
            });
            this.partialRenewal();
        },
        //局部数据更新 tabs
        partialRenewal() {
            try {
                const model = this.data.tabsList[this.data.tabsActive].model;
                if (model) {
                    const Component = this.selectComponent(model);
                    Component.getList(true);
                }
                this.data.model = model;
            } catch (error) {
                setTimeout(() => {
                    this.partialRenewal();
                }, 100)
            }
        },
        getContent() {
            const model = this.data.tabsList[this.data.tabsActive].model;
            if (model) return this.selectComponent(model).data.content
        }
    }
})