|
|
|
@ -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;
|
|
|
|
// },
|
|
|
|
|