const _Http = getApp().globalData.http;
Component({
    data: {
        content: {
            nocache: true,
            "pageNumber": 1,
            "pageTotal": 1,
            "pageSize": 20
        },
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        getList(init = false) {
            let content = this.data.content;
            if (init) content.pageNumber = 1;
            const page = getCurrentPages().find(v => v.__route__ == 'packageA/report/index');
            if (content.pageNumber > content.pageTotal) return page.setData({
                total: this.data.total
            });
            content.where = page.data.where;
            _Http.basic({
                "id": "20230524103102",
                content
            }).then(res => {
                console.log("我收到的", res)
                if (res.code != '1') return wx.showToast({
                    title: res.msg,
                    icon: 'none',
                    mask: true
                })
                content.pageTotal = res.pageTotal;
                content.pageNumber = res.pageNumber + 1;
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    content,
                    total: res.total
                })
                page.selectComponent('#ListBox').RefreshToComplete();
                page.setData({
                    total: res.total
                })
            })
        },
        onRead({
            detail
        }) {
            detail.readstatus = "已读"
            let index = this.data.list.findIndex(v => v.sys_workreportid == detail.sys_workreportid)
            this.setData({
                [`list[${index}]`]: detail
            })
        }
    }
})