const _Http = getApp().globalData.http;
Component({
    properties: {
        list: Array,
        fastCallBack: Function,
        disabled: Boolean
    },
    options: {
        addGlobalClass: true
    },
    data: {
        range: ['业主', '设计院', '总包', '分包', '监理', '其他']
    },
    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.range[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.msg != '成功') 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: `已更改“${item.enterprisename}”客户类型为“${type}”`,
                    icon: "none"
                })
            })
        },
    }
})