const _Http = getApp().globalData.http;
Component({
    options: {
        addGlobalClass: true,
    },
    properties: {
        update: {
            type: Function
        }
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
            this.triggerEvent('update', "Clue")
        }
    },
    data: {
        tabsList: [{
            label: "数据概况",
            model: "#DataOverview"
        }, {
            label: "近12月线索新增分析",
            model: "#NewAnalysisAdded"
        }, {
            label: "近12月线索跟进分析",
            model: "#followUpAnalysis"
        }, {
            label: "近12月线索转化分析",
            model: "#AnalysisOfLeadConversion"
        }, {
            label: "有效线索未跟进天数分析",
            model: "#YXXSWGJTSFX"
        }],
        tabsActive: 0,
        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
        }
    }
})