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

153 lines
5.4 KiB

// pages/process/order-check/index.js
import Scene from '../../index/scene'
import Dialog from '../../../components/dialog/dialog'
import { repeatSideOrder, getSideOrderInfo, printOrder} from "../../../api/saas"
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const math = require('../../../utils/math')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
status: null,
agent: 0,
id: null,
form: null,
imageList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
this.data.id = options.id
this.fetchOrderInfo()
}
if(options.agent){
this.data.agent = Number(options.agent)
}
if(options.status){
this.data.status = Number(options.status)
}
event.on('OrderMessage', this, this.onEvent)
},
onEvent: function(message){
if (message.what == 12) {
this.fetchOrderInfo()
}
},
fetchOrderInfo: function(){
wx.showLoading({ title: '正在获取', mask: true })
getSideOrderInfo({id: this.data.id}).then(result => {
wx.hideLoading()
result.data.settleTotalAmount = 0
result.data.settleTotalWeight = 0
for (let index = 0; index < result.data.productCategoryInfos.length; index++) {
const element = result.data.productCategoryInfos[index]
element.fileList = []
if(element.weightNoteImages){
for (let k = 0; k < element.weightNoteImages.length; k++) {
element.fileList.push({url: element.weightNoteImages[k]})
}
}
if(element.settleUnitPrice && element.settleWeight){
element.settlePrice = math.times(element.settleWeight, element.settleUnitPrice)
result.data.settleTotalAmount = math.plus(result.data.settleTotalAmount, element.settlePrice)
result.data.settleTotalWeight = math.plus(result.data.settleTotalWeight, element.settleWeight)
}
}
var imageList = []
if(result.data.orderImageList && result.data.orderImageList.length){
for (let index = 0; index < result.data.orderImageList.length; index++) {
imageList.push({url: result.data.orderImageList[index]})
}
}
if(this.data.status || this.data.status == 0){
result.data.paymentOrderInfo.receivableStatus = this.data.status
}
if(result.data.paymentOrderInfo.receivablePrice){
if(result.data.paymentOrderInfo.paidPrice){
result.data.paymentOrderInfo.lessPrice = math.minus(result.data.paymentOrderInfo.receivablePrice, result.data.paymentOrderInfo.paidPrice)
} else {
result.data.paymentOrderInfo.lessPrice = 0.00
}
}
this.setData({ form: result.data, admin: app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0, agent: this.data.agent, imageList,safeBottom: app.globalData.safeBottom })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
orderLogger: function(){
wx.navigateTo({url: `/pages/process/order-logger/index?type=1&orderId=${this.data.id}` })
},
printOrderInfo: function(){
wx.showLoading({ title: '正在处理', mask: true })
printOrder({id: this.data.id, printType: 2}).then(result => {
wx.hideLoading()
util.showToast('即将打印,请稍后')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
checkForm: function(){
wx.redirectTo({url: `/pages/process/outside-check/index?id=${this.data.id}` })
},
submitForm: function(){
if(this.data.form.onsideGrossWeight) {
this.checkPass()
} else {
var message = '此订单没有厂内毛重数据,按照正常流程请刷卡过磅,获取厂内毛重数据,如果已经无法获取,请仔细查验纸品,确定没有问题后,进行审核。'
Dialog.confirm({ title: '温馨提示', message, confirmButtonText: '确定审核' }).then(() => {
this.checkPass()
})
}
},
checkPass: function(){
var that = this
wx.requestSubscribeMessage({
tmplIds: ['DJaSy0a5TNp9v_ICQ0ZY5-hkZ91dEXZuKq_hQVBTnOA', '4IWtlcg1HhLN7AFepB3VeZF-4D0b9gbjwWBruKMhAJM'],
complete(res) {
wx.showLoading({ title: '处理中', mask: true })
repeatSideOrder({scrapPaperReceiptId: that.data.form.scrapPaperReceiptId }).then(result => {
wx.hideLoading()
util.showBackToast('订单审核已通过')
event.emit('OrderMessage', { what: 12, desc: 'pricingOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
})
},
paymentOrder: function(){
let pages = getCurrentPages() //当前页面栈
for (let index = 0; index < pages.length; index++) {
if (pages[index].route.indexOf('pages/process/payment/index') >= 0) {
wx.navigateBack()
return
}
}
wx.navigateTo({ url: `/pages/process/payment/index?id=${this.data.form.scrapPaperReceiptId}` })
},
viewImage: function (e) {
var imgList = []
for (let index = 0; index < this.data.form.onsideGrossWeightImageList.length; index++) {
var url = this.data.form.onsideGrossWeightImageList[index]
if(!util.isEmpty(url) && 'error' != url){
imgList.push(url)
}
}
if(imgList.length){
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url })
}
},
onUnload: function(){
event.remove('OrderMessage', this)
}
})