let sys_workreportid = null;
const _Http = getApp().globalData.http;

Page({
    data: {

    },
    onLoad(options) {
        sys_workreportid = options.id;
        _Http.basic({
            "id": "20230524092002",
            "content": {
                sys_workreportid
            },
        }).then(res => {
            console.log("汇报详情", res)
            if (res.msg != '成功') {
                wx.showToast({
                    title: res.msg,
                    icon: "none",
                    mask: true
                })
                setTimeout(() => {
                    wx.navigateBack()
                }, 500)
            } else {
                if (res.data.attinfos.length != 0) this.selectComponent("#Yl_Files").handleFiles(res.data.attinfos)
                this.setData({
                    detail: res.data,
                    type: res.data.userid == wx.getStorageSync('userMsg').userid ? '我发出的' : '我收到的'
                })
            }
        })
    },
    onDetele() {
        let that = this;
        wx.showModal({
            title: '提示',
            content: '是否确认删除本次汇报?',
            complete: ({
                confirm
            }) => {
                if (confirm) _Http.basic({
                    "id": "20230602105902",
                    "content": {
                        "sys_workreportid": that.data.detail.sys_workreportid
                    }
                }).then(res => {
                    console.log("删除汇报", res)
                    wx.showToast({
                        title: res.msg != '成功' ? res.msg : "删除成功",
                        icon: "none",
                        mask: true
                    });
                    if (res.msg == '成功') return setTimeout(() => {
                        wx.navigateBack();
                    }, 500)
                })
            }
        })
    },
    onUnload() {
        const page = getCurrentPages().find(v => v.__route__ == 'packageA/report/index');
        if (!page) return;
        page.updateList();
    }
})