const _Http = getApp().globalData.http;
Component({
    properties: {},
    data: {
        show: false,
        endreason: ""
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        onClick(sa_projectid) {
            this.setData({
                show: true
            })
            let Dialog = this.selectComponent("#Dialog");
            Dialog.data.beforeClose = (action) => new Promise((resolve) => {
                if (action === 'confirm') {
                    if (!this.data.endreason) {
                        Dialog.setData({
                            "loading.confirm": false
                        })
                        getApp().globalData.Language.showToast('还未填写结案原因')
                    } else {
                        _Http.basic({
                            "id": 20221215163702,
                            "content": {
                                sa_projectid,
                                endreason: this.data.endreason
                            }
                        }).then(res => {
                            console.log('结案', res)
                            wx.showToast({
                                title: res.code == '1' ? getApp().globalData.Language.getMapText('已结案') : res.msg,
                                icon: "none"
                            });
                            resolve(true);
                            let page = getCurrentPages()[getCurrentPages().length - 1];
                            page.getDetail();
                        })
                    }
                } else {
                    resolve(false);
                    this.setData({
                        show: false
                    })
                }
            });
        },
        onChange(e) {
            this.data.endreason = e.detail.value;
        }
    }
})