const _Http = getApp().globalData.http;

Page({
    data: {
        deletereason: "",
        sa_projectid: 0,
    },
    onLoad(options) {
        this.setData({
            sa_projectid: options.id
        })
    },
    onInput(e) {
        this.setData({
            deletereason: e.detail.value
        })
    },
    handleDetele() {
        _Http.basic({
            "id": 20221020144302,
            "content": {
                "sa_projectids": [this.data.sa_projectid],
                "deletereason": this.data.deletereason
            },
        }).then(res => {
            console.log("作废", res);
            if (res.msg != '成功') return wx.showToast({
                title: res.data,
                icon: "none"
            });
            wx.showToast({
                title: '作废成功',
                icon: "none"
            })
            setTimeout(() => {
                getCurrentPages().forEach(v => {
                    if (['packageA/project/detail'].includes(v.__route__)) {
                        wx.navigateBack();
                    } else if (['packageA/project/index', 'packageA/project/search'].includes(v.__route__)) {
                        v.setData({
                            list: v.data.list.filter(s => s.sa_projectid != this.data.sa_projectid),
                            'content.total': v.data.content.total - 1
                        })
                    }
                });
                wx.navigateBack();
            }, 300)
        })
    }
})