const _Http = getApp().globalData.http;

Page({
    data: {
        deletereason: "",
    },

    onLoad(options) {
        if (options.item) this.setData({
            ...JSON.parse(options.item)
        })
    },
    onInput(e) {
        this.setData({
            deletereason: e.detail.value
        })
    },
    handleDetele() {
        _Http.basic({
            "id": 20221010164402,
            "content": {
                ...this.data
            }
        }).then(res => {
            console.log("作废", res);
            if (res.msg != '成功') return wx.showToast({
                title: res.data,
                icon: "none"
            });
            wx.showToast({
                title: '作废成功',
                icon: "none"
            })
            getCurrentPages().forEach(v => {
                switch (v.__route__) {
                    //如果页面历史有详情，退出详情
                    case 'packageA/setclient/detail':
                        wx.navigateBack();
                        break;
                        //如果页面历史有列表页 刷新列表
                    case 'packageA/setclient/index':
                        v.setData({
                            list: v.data.list.filter(s => s.sa_customersid != this.data.sa_customersids[0]),
                            'content.total': v.data.content.total - 1
                        })
                        break;
                }
            });
            wx.navigateBack();
        })
    }
})