const _Http = getApp().globalData.http;

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        sat_orderclueid: Number,
        list: Array,
        endChange: Function
    },

    /**
     * 组件的初始数据
     */
    data: {
        radio: '',
        loading: false
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onChange(event) {
            this.setData({
                radio: event.detail,
            });
        },
        onClick(event) {
            const {
                name
            } = event.currentTarget.dataset;
            this.setData({
                radio: name,
            });
        },
        submit() {
            if (!this.data.radio || this.data.loading) return;
            const that = this;
            wx.showModal({
                title: "提示",
                content: "是否确认转移",
                success: ({
                    confirm
                }) => {
                    if (confirm) that.changeClue();
                }
            })
        },
        changeClue() {
            this.setData({
                loading: true
            });
            _Http.basic({
                "classname": "saletool.orderclue.web.orderclue",
                "method": "changeClue",
                "content": {
                    "sat_orderclueid": [this.data.sat_orderclueid],
                    "sa_agent_hrid": this.data.radio
                }
            }).then(res => {
                this.setData({
                    loading: false
                });
                if (res.msg != '成功') return wx.showToast({
                    title: res.msg,
                    icon: "none"
                });
                wx.showToast({
                    title: '转移成功!',
                })
                setTimeout(() => {
                    this.triggerEvent("endChange");
                    wx.navigateBack();
                }, 300);
            })
        },
    }
})