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.
178 lines
7.0 KiB
178 lines
7.0 KiB
// pages/index/index.js
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getStatisticsInfo } from "../../../api/saas"
|
|
import { headerFactoryId } from "../../../api/user"
|
|
import util from '../../../utils/util'
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
/** 页面的初始数据 */
|
|
data: {
|
|
userInfo: app.userInfo,
|
|
height: app.globalData.safeFragmentHeight,
|
|
customBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60),
|
|
tabList2: [
|
|
{ status: 1, badge: '', name: '磅单信息', icon: '/assets/image/icon_pound.png' },
|
|
{ status: 2, badge: '', name: '出货审核', icon: '/assets/image/icon_outcheck.png' },
|
|
{ status: 3, badge: '', name: '待收款', icon: '/assets/image/icon_payback.png' },
|
|
{ status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_complete.png' }
|
|
],
|
|
show: false,
|
|
vdate: [],
|
|
vdateString: '',
|
|
factoryId: '12313K78978KK',
|
|
factoryList: [
|
|
{id: '12313000KK12K', name: '济州岛打包站'},
|
|
{id: '12313K78978KK', name: '福州道打包站'},
|
|
{id: '1231345500KKK', name: '钟落潭打包站'},
|
|
{id: '12345678978KK', name: '鹤山常服打包站'},
|
|
{id: '123sdfsdf00KKK', name: '合剂打包站'},
|
|
{id: '1231332K78978K', name: '永宁街打包站'},
|
|
{id: '123242K78978KK', name: '河西路打包站'},
|
|
{id: '12313378978KK5', name: '成林道打包站'}
|
|
],
|
|
visible: false
|
|
},
|
|
lifetimes: {
|
|
attached: function () {
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
detached: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
},
|
|
methods: {
|
|
onRestart: function () {
|
|
if(!this.data.firstShow) {
|
|
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')
|
|
var height = app.globalData.safeFragmentHeight - 100
|
|
var customBar = app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60)
|
|
if(app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0){
|
|
var tabList2 = [
|
|
{ status: 1, badge: '', name: '磅单信息', icon: '/assets/image/icon_pound.png' },
|
|
{ status: 2, badge: '', name: '出货审核', icon: '/assets/image/icon_outcheck.png' },
|
|
{ status: 3, badge: '', name: '待收款', icon: '/assets/image/icon_payback.png' },
|
|
{ status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_complete.png' }
|
|
]
|
|
this.setData({userInfo: app.userInfo, height, minDate, maxDate, vdate, vdateString, tabList2, customBar})
|
|
} else {
|
|
var tabList2 = [
|
|
{ status: 1, badge: '', name: '磅单信息', icon: '/assets/image/icon_pound.png' },
|
|
{ status: 3, badge: '', name: '待收款', icon: '/assets/image/icon_payback.png' },
|
|
{ status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_complete.png' }
|
|
]
|
|
this.setData({userInfo: app.userInfo, height, minDate, maxDate, vdate, vdateString, tabList2, customBar })
|
|
}
|
|
}
|
|
this.fetchStatisticsInfo(this.data.vdate)
|
|
this.data.firstShow = true
|
|
},
|
|
onEvent: function (message) {
|
|
if (message.what == 888) {
|
|
}
|
|
},
|
|
outList: function(e){
|
|
if(e.currentTarget.dataset.status == 1){
|
|
wx.navigateTo({ url: '/pages/storage/pound-list/index' })
|
|
} else if(e.currentTarget.dataset.status == 2){
|
|
wx.navigateTo({ url: '/pages/storage/order-list/index?status=0' })
|
|
} else if(e.currentTarget.dataset.status == 3){
|
|
wx.navigateTo({ url: '/pages/storage/order-list/index?status=1' })
|
|
} else if(e.currentTarget.dataset.status == 4){
|
|
wx.navigateTo({ url: '/pages/storage/order-list/index?status=2' })
|
|
} else {
|
|
wx.navigateTo({ url: '/pages/storage/order-list/index' })
|
|
}
|
|
},
|
|
fetchStatisticsInfo: function(vdate, loading){
|
|
var param = {startTime: util.formatTime(new Date(vdate[0]), 'Y-M-D'), endTime: util.formatTime(new Date(vdate[1]), 'Y-M-D')}
|
|
getStatisticsInfo(param).then(result => {
|
|
if(Number(result.data.weightNoteNum) > 0){
|
|
this.data.tabList2[0].badge = Number(result.data.weightNoteNum)
|
|
} else {
|
|
this.data.tabList2[0].badge = ''
|
|
}
|
|
if(app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0){
|
|
if(Number(result.data.outboundDeliveryOrderAuditNum) > 0){
|
|
this.data.tabList2[1].badge = Number(result.data.outboundDeliveryOrderAuditNum)
|
|
} else {
|
|
this.data.tabList2[1].badge = ''
|
|
}
|
|
if(Number(result.data.outboundDeliveryOrderWaitReceiptNum) > 0){
|
|
this.data.tabList2[2].badge = Number(result.data.outboundDeliveryOrderWaitReceiptNum)
|
|
} else {
|
|
this.data.tabList2[2].badge = ''
|
|
}
|
|
} else {
|
|
if(Number(result.data.outboundDeliveryOrderWaitReceiptNum) > 0){
|
|
this.data.tabList2[1].badge = Number(result.data.outboundDeliveryOrderWaitReceiptNum)
|
|
} else {
|
|
this.data.tabList2[1].badge = ''
|
|
}
|
|
}
|
|
var vdateString = util.formatDate(new Date(vdate[0]), 'Y-M-D') + '至' + util.formatDate(new Date(vdate[1]), 'Y-M-D')
|
|
this.setData({ tabList2: this.data.tabList2, vdate, vdateString })
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
}).catch(err => {
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
})
|
|
},
|
|
showCalendar: function(){
|
|
this.setData({ show: true })
|
|
this.triggerEvent("zIndex", -1)
|
|
},
|
|
onClose: function() {
|
|
this.setData({ show: false })
|
|
this.trigEvent(9)
|
|
},
|
|
onSelect: function({detail}) {
|
|
const [start, end] = detail
|
|
this.onClose()
|
|
this.fetchStatisticsInfo([start.getTime(), end.getTime()])
|
|
},
|
|
toAuths: function(){
|
|
wx.navigateTo({ url: '/pages/htmls/auths/index' })
|
|
},
|
|
showFactoryList: function(){
|
|
this.setData({ visible: true })
|
|
this.triggerEvent("zIndex", -1)
|
|
},
|
|
onHide: function(){
|
|
this.setData({ visible: false })
|
|
this.trigEvent(9)
|
|
},
|
|
changeFactory: function(e){
|
|
var item = this.data.factoryList[e.currentTarget.dataset.index]
|
|
wx.showLoading({ title: '正在切换', mask: true })
|
|
headerFactoryId(item.id)
|
|
event.emit('EventMessage', { what: 999, desc: 'changeFactory' })
|
|
this.setData({ visible: false, factoryId: item.id })
|
|
this.trigEvent(9)
|
|
this.fetchStatisticsInfo(this.data.vdate, true)
|
|
},
|
|
trigEvent: function(zIndex){
|
|
setTimeout(() => {
|
|
this.triggerEvent('zIndex', zIndex)
|
|
}, 100);
|
|
}
|
|
}
|
|
})
|