纸通宝SAAS仓库
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.
 

147 lines
5.5 KiB

// pages/storage/index/index.js
import Scene from '../../index/scene'
import Dialog from '../../../components/dialog/dialog'
import { getOutOrderInfo, auditOutOrder, printOrder } from "../../../api/saas"
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
form: null,
poundInfo: null,
orderInfo: null,
activeNames: [],
auditable: false,
fileList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({ title: '正在获取', mask: true })
getOutOrderInfo(options.id).then(result => {
result.data.weightNote.emptyWeighingPicture = []
if(result.data.weightNote.firstWeightImageUrl1){
result.data.weightNote.emptyWeighingPicture.push(result.data.weightNote.firstWeightImageUrl1)
}
if(result.data.weightNote.firstWeightImageUrl2){
result.data.weightNote.emptyWeighingPicture.push(result.data.weightNote.firstWeightImageUrl2)
}
result.data.weightNote.totalWeighingPicture = []
if(result.data.weightNote.secondWeightImageUrl1){
result.data.weightNote.totalWeighingPicture.push(result.data.weightNote.secondWeightImageUrl1)
}
if(result.data.weightNote.secondWeightImageUrl2){
result.data.weightNote.totalWeighingPicture.push(result.data.weightNote.secondWeightImageUrl2)
}
if(result.data.outboundDeliveryOrderSettlementInfo.id){
this.data.fileList = []
if(result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr){
for (let index = 0; index < result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr.length; index++) {
const element = result.data.outboundDeliveryOrderSettlementInfo.weightNoteImageUrlsArr[index]
if(!util.isEmpty(element)){
this.data.fileList.push({ url: element})
}
}
}
if(app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0){
if(result.data.outboundDeliveryOrder.status == 0){
this.data.auditable = true
}
}
this.setData({
safeBottom: app.globalData.safeBottom,
poundInfo: result.data.weightNote,
orderInfo: result.data.outboundDeliveryOrder,
form: result.data.outboundDeliveryOrderSettlementInfo,
auditable: this.data.auditable,
fileList: this.data.fileList
})
} else {
if(app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0){
if(result.data.outboundDeliveryOrder.status == 0){
this.data.auditable = true
}
}
var activeNames = ['1']
if(result.data.outboundDeliveryOrder.status == 2){
activeNames = ['2']
} else if(result.data.outboundDeliveryOrder.status == 3){
activeNames = ['2', '1']
}
this.setData({
safeBottom: app.globalData.safeBottom,
poundInfo: result.data.weightNote,
orderInfo: result.data.outboundDeliveryOrder,
auditable: this.data.auditable,
activeNames: activeNames
})
}
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
printOrderInfo: function(){
wx.showLoading({ title: '正在处理', mask: true })
printOrder({id: this.data.orderInfo.id, printType: 3 }).then(result => {
wx.hideLoading()
util.showToast('即将打印,请稍后')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
onChange: function({detail}) {
this.setData({ activeNames: detail })
},
submitForm: function(e){
if(e.currentTarget.id == 'refuse'){
Dialog.confirm({ title: '温馨提示', message: '确定此出货单有问题,进行驳回?' }).then(() => {
wx.showLoading({ title: '正在处理', mask: true })
auditOutOrder({id: this.data.orderInfo.id, auditStatus: 0 }).then(result => {
wx.hideLoading()
util.showBackToast('出货单已经驳回')
event.emit('OrderMessage', { what: 21, desc: 'cancelOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
})
} else {
wx.showLoading({ title: '正在处理', mask: true })
auditOutOrder({id: this.data.orderInfo.id, auditStatus: 1 }).then(result => {
wx.hideLoading()
util.showBackToast('出货单已经通过审核')
event.emit('OrderMessage', { what: 21, desc: 'cancelOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
settleForm: function(){
wx.redirectTo({ url: `/pages/storage/order-settlement/index?id=${this.data.orderInfo.id}` })
},
viewImage: function (e) {
var imgList = []
if(e.currentTarget.dataset.type == 1){
for (let index = 0; index < this.data.poundInfo.totalWeighingPicture.length; index++) {
imgList.push(this.data.poundInfo.totalWeighingPicture[index])
}
} else {
for (let index = 0; index < this.data.poundInfo.emptyWeighingPicture.length; index++) {
imgList.push(this.data.poundInfo.emptyWeighingPicture[index])
}
}
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url })
}
})