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() {
        if (!this.data.deletereason) return;
        _Http.basic({
            "id": 20220930121701,
            "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 => {
                //如果页面历史有详情，退出详情
                if (['packageA/setclient/modules/trace/detail/index'].includes(v.__route__)) wx.navigateBack();
                //如果页面历史有列表页 刷新列表
                if (v.selectComponent("#Trace")) {
                    let page = v.selectComponent("#Trace")
                    page.setData({
                        list: page.data.list.filter(s => s.sys_datafollowupid != this.data.sys_datafollowupid)
                    })
                    page.changeTotal()
                }
            });
            wx.navigateBack();
        })
    }
})