Page({
    data: {
        params: {},
    },
    onLoad(options) {
        this.setData({
            params: JSON.parse(options.params),
            enterprisename: getCurrentPages().find(v => v.__route__ == 'packageA/contract/detail').data.detail.enterprisename
        })
        wx.setNavigationBarTitle({
            title: `${this.data.params.year}年度${this.data.params.tradefield}领域目标`,
        });
    },
    onBlur(e) {
        let params = this.data.params;
        params[e.currentTarget.dataset.name] = e.detail.value || 0
        let s = null,
            i = e.currentTarget.dataset.index;
        switch (i) {
            case "1":
                s = [1, 2, 3]
                break;
            case "2":
                s = [4, 5, 6]
                break;
            case "3":
                s = [7, 8, 9]
                break;
            case "4":
                s = [10, 11, 12]
                break;
        };
        params[`s${i}l`] = 0;
        params[`s${i}h`] = 0;
        for (let index = 0; index < 3; index++) {
            params[`s${i}l`] += (params[`m${s[index]}l`] - 0)
            params[`s${i}h`] += (params[`m${s[index]}h`] - 0);
        };
        params.y1l = 0;
        params.y1h = 0;
        for (let index = 1; index <= 4; index++) {
            params.y1l += (params['s' + index + 'l'] - 0);
            params.y1h += (params['s' + index + 'h'] - 0);
        }
        this.setData({
            params: this.data.params
        })
    },
    submit() {
        let page = getCurrentPages()[getCurrentPages().length - 2].selectComponent("#Objective");
        page.submit(this.data.params)
    }
})