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: "项目类型分析",
            model: "#ProjectType"
        }, {
            label: "项目等级分析",
            model: "#ProjectGrade"
        }, {
            label: "近12月项目新增分析",
            model: "#NewAnalysisAdded"
        }, {
            label: "近12月项目报备分析",
            model: "#ReportAnalysis"
        }, {
            label: "近12月项目报价分析",
            model: "#ProjectQuotationQuantity"
        }, {
            label: "近12月项目跟进分析",
            model: "#followUpAnalysis"
        }, {
            label: "项目跟进情况统计",
            model: "#ProjecFollowUp"
        }, {
            label: "项目联系人情况统计",
            model: "#ProjectContact"
        }, {
            label: "项目关联客户情况统计",
            model: "#RelatedCustomer"
        }, {
            label: "项目评估情况统计",
            model: "#ProjecEvaluation"
        }, {
            label: "有效项目未跟进天数分析",
            model: "#YXXMWGJTSFX"
        }, {
            label: "项目生命周期分析",
            model: "#XMSMZQFX"
        }]
    },
    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
        }
    }
})