123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- 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() {}
- })
|