const _Http = getApp().globalData.http;

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

    onLoad(options) {
        if (options.item) this.setData({
            ...JSON.parse(options.item)
        })
        if (options.id) this.setData({
            id: options.id
        })
    },
    onInput(e) {
        this.setData({
            deletereason: e.detail.value
        })
    },
    handleDetele() {
        _Http.basic({
            "id": this.data.id,
            "content": {
                ...this.data
            }
        }).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/setclient/detail', 'packageA/publicCustomer/detail'].includes(v.__route__)) {
                        wx.navigateBack();
                    } else if (['packageA/setclient/index', 'packageA/setclient/search', 'packageA/publicCustomer/index'].includes(v.__route__)) {
                        v.setData({
                            list: v.data.list.filter(s => s.sa_customersid != this.data.sa_customersids[0]),
                            'content.total': v.data.content.total - 1
                        })
                    } else if (['packageA/opponent/index'].includes(v.__route__)) {
                        wx.navigateBack();
                        v.getList(true);
                    }
                });
                wx.navigateBack();
            }, 300)
        })
    }
})