const _Http = getApp().globalData.http; Page({ /** * 页面的初始数据 */ data: { list: [], showArr: [], "content": { "sa_salesforecastmodelid": null, "pageNumber": 1, "pageSize": 20, "pageTotal": 1, "where": { "condition": "" } }, total: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ 'content.sa_salesforecastmodelid': options.id, userid: wx.getStorageSync("userMsg").userid }) this.getList(); this.getShowArr(); }, /* 去详情 */ toDetail(e) { const { item } = e.currentTarget.dataset; if (item.baseonproject == 1) { wx.navigateTo({ url: './detail?id=' + item.sa_salesforecastbillid, }) } else { const data = { sa_salesforecastbillid: item.sa_salesforecastbillid, projectname: item.title, projectnum: item.billnum, sa_projectid: 0, address: "", sa_salesforecastmodelid: this.data.content.sa_salesforecastmodelid } wx.navigateTo({ url: './reportForms?item=' + JSON.stringify(data) + '&isEdit=false', }) } }, /* 开始搜索 */ startSearch({ detail }) { this.setData({ 'content.where.condition': detail.trim() }); this.getList(true); }, cancelSearch() { this.setData({ 'content.where.condition': "" }); this.getList(true); }, /* 展示列表 */ getShowArr() { return _Http.basic({ "id": 20220906150303, "version": 1, "content": { "sa_salesforecastmodelid": this.data.content.sa_salesforecastmodelid } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) this.setData({ showArr: [{ label: "订单金额(万元)", value: res.data.orderamountsum }, { label: "出货金额(万元)", value: res.data.outamountsum }, { label: "开票金额(万元)", value: res.data.invoiceamountsum }, { label: "订货数量(个)", value: res.data.orderqtysum }, { label: "出货数量(个)", value: res.data.outqtysum }, { label: "开票数量(个)", value: res.data.invoiceqtysum }] }) }) }, getList(init = false) { //init 用于初始化分页 if (init.detail != undefined) init = init.detail; if (init) this.setData({ ['content.pageNumber']: 1 }) if (this.data.content.pageNumber > this.data.content.pageTotal) return; return _Http.basic({ "id": 20220906150403, "version": 1, content: this.data.content }).then(res => { console.log("列表", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) this.setData({ 'content.pageNumber': res.pageNumber + 1, 'content.pageTotal': res.pageTotal, list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), total: res.total }) }) }, onPullDownRefresh: function () { Promise.all([this.getList(true), this.getShowArr()]).then(res => { wx.stopPullDownRefresh() }) }, onReachBottom() { this.getList(); }, onShareAppMessage() {} })