import Scene from '../../../pages/index/scene' import { getSalesReport } from "../../../api/saas" import util from '../../../utils/util' const app = getApp() Scene({ /** * 页面的初始数据 */ data: { height: app.globalData.fragmentHeight, form: {}, columns: [ { prop: 'productCategoryName', width: 200, label: '品类', color: '#55C355' }, { prop: 'outboundDeliveryNetWeight', width: 180, label: '出货重量(吨)' }, { prop: 'settleWeight', width: 180, label: '结算重量(吨)' }, { prop: 'settleAvgPrice ', width: 220, label: '结算均价(元/吨)' }, { prop: 'settlePrice', width: 180, label: '结算金额(元)' } ], reportInfo:{ productSalesDailyReportList: [], carNumber: 0, totalOutboundDeliveryNetWeight: 0, totalSettlePrice: 0, totalSettleWeight: 0 }, show: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading({ title: '加载中', mask: true }) var min = new Date() min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) max.setHours(0, 0, 0) var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) var vdate = [today.getTime(), maxDate] var vdateString = util.formatDate(new Date(), 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(today, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(max, 'Y-M-D') this.setData({ height: app.globalData.fragmentHeight - 404, minDate, maxDate, vdate, vdateString }) this.fetchStatisticsInfo() }, showCalendar: function(){ this.setData({ show: true }) }, onClose: function() { this.setData({ show: false }) }, onSelect: function({detail}) { var start = new Date(detail[0]) var end = new Date(detail[1]) var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(end, 'Y-M-D') this.setData({ show: false, vdateString }) wx.showLoading({ title: '加载中', mask: true }) this.fetchStatisticsInfo() }, fetchStatisticsInfo: function(){ getSalesReport(this.data.form).then(result => { wx.hideLoading() if(result.data){ this.setData({reportInfo: result.data}) } else { this.setData({ reportInfo: { productSalesDailyReportList: [], totalOutboundDeliveryNetWeight: 0, totalSettlePrice: 0, totalSettleWeight: 0 } }) } }).catch(err => { wx.hideLoading() }) } })