You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.6 KiB
77 lines
2.6 KiB
import Scene from '../../../pages/index/scene'
|
|
import { getGrossReport } 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: 'receiptPrice', width: 200, label: '采购金额(元)' },
|
|
{ prop: 'salesPrice', width: 200, label: '销售金额(元)' },
|
|
{ prop: 'grossProfit', width: 150, label: '毛利(元)' }
|
|
],
|
|
reportInfo:{
|
|
productGrossProfitReportList: [],
|
|
totalGrossProfit: 0,
|
|
totalSalesPrice: 0,
|
|
totalReceiptPrice: 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(today, '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(){
|
|
getGrossReport(this.data.form).then(result => {
|
|
if(result.data){
|
|
this.setData({ reportInfo: result.data })
|
|
} else {
|
|
this.setData({ reportInfo: { productGrossProfitReportList: [], totalGrossProfit: 0, totalSalesPrice: 0, totalReceiptPrice: 0 } })
|
|
}
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
})
|
|
}
|
|
})
|