const _Http = getApp().globalData.http;

Page({
    data: {
        deletereason: "",
    },
    onLoad(options) {
        getApp().globalData.Language.getLanguagePackage(this, '删除原因');

        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);
            wx.showToast({
                title: res.code != '1' ? res.msg : getApp().globalData.Language.getMapText("删除成功"),
                icon: "none"
            });
            if (res.code != '1') return;
            getCurrentPages().forEach(v => {
                //如果页面历史有详情，退出详情
                if (['prsx/trace/detail/index', "pages/trace/detail"].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()
                }
                if (v.route == 'prsx/hospital/detail') v.getDetail();
            });
            setTimeout(() => {
                wx.navigateBack();
            }, 500)
        })
    }
})