const _Http = getApp().globalData.http;
Component({
    properties: {
        list: {
            type: Array
        },
        fastCallBack: {
            type: Function
        },
        disabled: {
            type: Boolean
        }
    },
    options: {
        addGlobalClass: true
    },
    data: {
        range: [{
            show: getApp().globalData.Language.getMapText('业主'),
            value: '业主',
        }, {
            show: getApp().globalData.Language.getMapText('设计院'),
            value: '设计院',
        }, {
            show: getApp().globalData.Language.getMapText('总包'),
            value: '总包',
        }, {
            show: getApp().globalData.Language.getMapText('分包'),
            value: '分包',
        }, {
            show: getApp().globalData.Language.getMapText('监理'),
            value: '监理',
        }, {
            show: getApp().globalData.Language.getMapText('其他'),
            value: '其他',
        }],
        range1: ['业主', '设计院', '总包', '分包', '监理', '其他']
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        handleFast(e) {
            const {
                name,
                item
            } = e.currentTarget.dataset;
            this.triggerEvent("fastCallBack", {
                name,
                item
            })
        },
        bindPickerChange(e) {
            let item = e.currentTarget.dataset.item,
                type = this.data.range1[e.detail.value];
            if (item.type == type) return;
            _Http.basic({
                "id": 20221116142502,
                "content": {
                    "sa_project_partiesid": item.sa_project_partiesid,
                    sa_projectid: item.sa_projectid,
                    type
                },
            }).then(res => {
                console.log("修改关联医院类型", res)
                if (res.code != '1') return wx.showToast({
                    title: res.data,
                    icon: "none"
                });
                this.setData({
                    [`list[${this.data.list.findIndex(v=>v.sa_project_partiesid==item.sa_project_partiesid)}].type`]: type
                });
                wx.showToast({
                    title: getApp().globalData.Language.getMapText('已更改') + `“${item.enterprisename}”${getApp().globalData.Language.getMapText('医院类型为')}“${getApp().globalData.Language.getMapText(type)}”`,
                    icon: "none"
                })
            })
        },
    }
})