From b5b7066732ea7f7618775cd76d61fb1b2eeca55c Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Wed, 16 Jun 2021 15:54:46 +0800 Subject: [PATCH] no message --- components/textarea/index.wxml | 2 +- xtends/statics/index/index.js | 98 ++++++++++++++++++++++------- xtends/statics/index/index.wxml | 20 +++--- xtends/statics/sale-report/index.js | 1 + 4 files changed, 89 insertions(+), 32 deletions(-) diff --git a/components/textarea/index.wxml b/components/textarea/index.wxml index 9451327..d5d37e2 100644 --- a/components/textarea/index.wxml +++ b/components/textarea/index.wxml @@ -1,4 +1,4 @@ {{value || placeholder }} \ No newline at end of file diff --git a/xtends/statics/index/index.js b/xtends/statics/index/index.js index bf1e5bd..99d6d4d 100644 --- a/xtends/statics/index/index.js +++ b/xtends/statics/index/index.js @@ -1,7 +1,7 @@ // xtends//statics/index/index.js import Scene from '../../../pages/index/scene' import uCharts from '../../libs/u-charts'; -import { getReceiptReport } from "../../../api/saas" +import { getReceiptReport, getSalesReport } from "../../../api/saas" const math = require('../../../utils/math') import util from '../../../utils/util' const app = getApp() @@ -19,8 +19,21 @@ Scene({ // cHeight: '', form1: {}, form2: {}, - percent: 85, - show: false + percent: 50, + show: false, + selectId: '', + reportInfo:{ + totalOffsiteSettleWeight: 0, + totalOnsideSettleWeight: 0, + totalSettlePrice: 0, + totalSettleWeight: 0 + }, + saleReportInfo:{ + carNumber: 0, + totalOutboundDeliveryNetWeight: 0, + totalSettlePrice: 0, + totalSettleWeight: 0 + } }, /** * 生命周期函数--监听页面加载 @@ -46,21 +59,14 @@ Scene({ var vdateString = util.formatDate(new Date(), 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') this.data.form1.dimensionDateStart = util.formatDate(today, 'Y-M-D') this.data.form1.dimensionDateEnd = util.formatDate(max, 'Y-M-D') - this.data.form2.startTime = util.formatDate(today, 'Y-M-D') + ' 00:00:00' - this.data.form2.endTime = util.formatDate(max, 'Y-M-D') + ' 00:00:00' - this.setData({ minDate, maxDate, vdate, vdateString }) - this.fetchSummaryInfo(this.data.form1) - }, - fetchSummaryInfo: function(form){ - getReceiptReport(form).then(result => { - // this.setData({ }) - wx.hideLoading() - }).catch(err => { - wx.hideLoading() - }) + this.data.form2.dimensionDateStart = util.formatDate(today, 'Y-M-D') + this.data.form2.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.setData({ minDate, maxDate, vdate, vdateString1: vdateString, vdateString2: vdateString }) + this.fetchSummaryInfo(false) + this.fetchStatisticsInfo(true) }, showCalendar: function(e){ - console.log(e.currentTarget.id) + this.data.selectId = e.currentTarget.id this.setData({ show: true }) }, onClose: function() { @@ -69,13 +75,63 @@ Scene({ 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.startTime = util.formatDate(start, 'Y-M-D') + ' 00:00:00' - this.data.form.endTime = util.formatDate(end, 'Y-M-D') + ' 00:00:00' - this.setData({ show: false, vdateString }) wx.showLoading({ title: '加载中', mask: true }) - this.fetchStatisticsInfo() + if(this.data.selectId == 'form1') { + var vdateString1 = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + this.data.form1.dimensionDateStart = util.formatDate(start, 'Y-M-D') + this.data.form1.dimensionDateEnd = util.formatDate(end, 'Y-M-D') + this.setData({ show: false, vdateString1 }) + this.fetchStatisticsInfo(true) + } else { + var vdateString2 = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + this.data.form2.dimensionDateStart = util.formatDate(start, 'Y-M-D') + this.data.form2.dimensionDateEnd = util.formatDate(end, 'Y-M-D') + this.setData({ show: false, vdateString2 }) + this.fetchStatisticsInfo(true) + } + }, + fetchSummaryInfo: function(hide){ + getReceiptReport(this.data.form1).then(result => { + if(result.data){ + if(result.data.totalOffsiteSettleWeight == 0 && result.data.totalOnsideSettleWeight == 0){ + this.data.percent = 50 + } else if(result.data.totalOffsiteSettleWeight == 0){ + this.data.percent = 0 + } else if(result.data.totalOnsideSettleWeight == 0){ + this.data.percent = 100 + } else { + var totalWeight = math.plus(result.data.totalOffsiteSettleWeight, result.data.totalOnsideSettleWeight) + this.data.percent = parseInt(math.times(math.divide(result.data.totalOffsiteSettleWeight, totalWeight), 100)) + } + this.setData({ reportInfo: result.data, percent: this.data.percent }) + } else { + this.setData({ reportInfo: { totalOffsiteSettleWeight: 0, totalOnsideSettleWeight: 0, totalSettlePrice: 0, totalSettleWeight: 0 }, percent: 50 }) + } + if(hide){ + wx.hideLoading() + } + }).catch(err => { + if(hide){ + wx.hideLoading() + } + }) }, + fetchStatisticsInfo: function(hide){ + getSalesReport(this.data.form2).then(result => { + if(result.data){ + this.setData({ saleReportInfo: result.data }) + } else { + this.setData({ saleReportInfo: { carNumber: 0, totalOutboundDeliveryNetWeight: 0, totalSettlePrice: 0, totalSettleWeight: 0 } }) + } + if(hide){ + wx.hideLoading() + } + }).catch(err => { + if(hide){ + wx.hideLoading() + } + }) + } // rpx2px: function(rpx) { // return rpx / 750 * windowWidth; // }, diff --git a/xtends/statics/index/index.wxml b/xtends/statics/index/index.wxml index 3eff93f..95e7db8 100644 --- a/xtends/statics/index/index.wxml +++ b/xtends/statics/index/index.wxml @@ -51,7 +51,7 @@ 收货统计 - {{vdateString}} + {{vdateString1}} @@ -65,21 +65,21 @@ 收货合计(吨) - 1230.45 + {{reportInfo.totalSettleWeight}} 场外收货(吨) - 1230.45 + {{reportInfo.totalOffsiteSettleWeight}} 收货总金额(元) - 1230.45 + {{reportInfo.totalSettlePrice}} 场内收货(吨) - 1230.45 + {{reportInfo.totalOnsideSettleWeight}} @@ -90,18 +90,18 @@ 销售统计 - {{vdateString}} + {{vdateString2}} - {{formate.formateWeight(totalInfo.totalWeight || 0)}} + {{formate.formateWeight(saleReportInfo.totalOutboundDeliveryNetWeight || 0)}} 总出货重量(吨) - {{formate.formateWeight(totalInfo.totalWeight || 0)}} + {{formate.formateWeight(saleReportInfo.totalSettleWeight || 0)}} 总结算重量(吨) @@ -111,12 +111,12 @@ - {{formate.formateWeight(totalInfo.totalWeight || 0)}} + {{formate.formateWeight(saleReportInfo.carNumber || 0)}} 总出车数(车) - {{formate.formateWeight(totalInfo.totalWeight || 0)}} + {{formate.formateWeight(saleReportInfo.totalSettlePrice || 0)}} 总结算金额(元) diff --git a/xtends/statics/sale-report/index.js b/xtends/statics/sale-report/index.js index a895bb2..07be3da 100644 --- a/xtends/statics/sale-report/index.js +++ b/xtends/statics/sale-report/index.js @@ -20,6 +20,7 @@ Scene({ ], reportInfo:{ productSalesDailyReportList: [], + carNumber: 0, totalOutboundDeliveryNetWeight: 0, totalSettlePrice: 0, totalSettleWeight: 0