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.
248 lines
9.6 KiB
248 lines
9.6 KiB
// pages/process/order-check/index.js
|
|
import Scene from '../../index/scene'
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { poundSideOrder, getSideOrderInfo, saveSideOrder, priceSideOrder, cancelOrder } from "../../../api/saas"
|
|
const event = require('../../../utils/event')
|
|
const util = require('../../../utils/util')
|
|
const math = require('../../../utils/math')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.fragmentHeight,
|
|
id: null,
|
|
form: null,
|
|
param: {
|
|
scrapPaperReceiptId: null,
|
|
offsiteGrossWeight: null,
|
|
offsiteTareWeight: null,
|
|
},
|
|
grossList: [],
|
|
imageList: [],
|
|
intoview: ''
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(options.id){
|
|
this.data.id = options.id
|
|
this.fetchOrderInfo()
|
|
}
|
|
},
|
|
fetchOrderInfo: function(){
|
|
wx.showLoading({ title: '正在获取', mask: true })
|
|
getSideOrderInfo({id: this.data.id}).then(result => {
|
|
wx.hideLoading()
|
|
this.data.param.offsiteGrossWeight = result.data.offsiteGrossWeight
|
|
this.data.param.offsiteTareWeight = result.data.offsiteTareWeight
|
|
var height = app.globalData.fragmentHeight - app.globalData.safeBottom - 120
|
|
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]})
|
|
}
|
|
}
|
|
// var grossList = []
|
|
// if(result.data.onsideGrossWeightImageList && result.data.onsideGrossWeightImageList.length){
|
|
// for (let index = 0; index < result.data.onsideGrossWeightImageList.length; index++) {
|
|
// grossList.push({url: result.data.onsideGrossWeightImageList[index]})
|
|
// }
|
|
// }
|
|
this.setData({ form: result.data, admin: app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0, height, imageList })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
orderLogger: function(){
|
|
wx.navigateTo({url: `/pages/process/order-logger/index?type=1&orderId=${this.data.id}` })
|
|
},
|
|
onProductChange: function({detail}){
|
|
this.data.form.productCategoryInfos[detail.index] = detail.item
|
|
var totalNetWeight = 0
|
|
var estimatedAmount = 0
|
|
for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) {
|
|
const element = this.data.form.productCategoryInfos[index]
|
|
if(this.data.form.orderStatus == 0){
|
|
if(!util.isEmpty(element.netWeight) && Number(element.netWeight) > 0){
|
|
totalNetWeight = math.plus(totalNetWeight, element.netWeight)
|
|
}
|
|
if(!util.isEmpty(element.estimatedAmount) && Number(element.estimatedAmount) > 0){
|
|
estimatedAmount = math.plus(estimatedAmount, element.estimatedAmount)
|
|
}
|
|
} else {
|
|
if(!util.isEmpty(element.settleWeight) && Number(element.settleWeight) > 0){
|
|
totalNetWeight = math.plus(totalNetWeight, element.settleWeight)
|
|
}
|
|
if(!util.isEmpty(element.settlePrice) && Number(element.settlePrice) > 0){
|
|
estimatedAmount = math.plus(estimatedAmount, element.settlePrice)
|
|
}
|
|
}
|
|
}
|
|
if(this.data.form.orderStatus == 0){
|
|
this.setData({ ['form.totalNetWeight']: totalNetWeight, ['form.estimatedAmount']: estimatedAmount.toFixed(2) })
|
|
} else {
|
|
this.setData({ ['form.settleTotalWeight']: totalNetWeight, ['form.settleTotalAmount']: estimatedAmount.toFixed(2) })
|
|
}
|
|
},
|
|
bindInput: function (e) {
|
|
this.data.param[e.currentTarget.id] = e.detail
|
|
},
|
|
cancelForm: function(e){
|
|
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => {
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
cancelOrder(this.data.form.scrapPaperReceiptId).then(result => {
|
|
wx.hideLoading()
|
|
util.showBackToast('订单已经取消')
|
|
event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
})
|
|
},
|
|
eidtForm: function(){
|
|
wx.redirectTo({url: `/pages/process/outside-add/index?id=${this.data.id}` })
|
|
},
|
|
saveForm: function(){
|
|
var weightNoteList = []
|
|
for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) {
|
|
const element = this.data.form.productCategoryInfos[index]
|
|
var item = {grossWeight: element.grossWeight, tareWeight: element.tareWeight,weightNoteImage: element.weightNoteImages }
|
|
item.netWeight = element.netWeight
|
|
item.scrapPaperPurchaseOrderId = element.scrapPaperPurchaseOrderId
|
|
weightNoteList.push(item)
|
|
}
|
|
this.data.param.scrapPaperReceiptId = this.data.form.scrapPaperReceiptId
|
|
this.data.param.weightNoteList = weightNoteList
|
|
this.data.param.orderImageList = this.data.form.orderImageList
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
saveSideOrder(this.data.param).then(result => {
|
|
wx.hideLoading()
|
|
util.showBackToast('保存成功')
|
|
// event.emit('OrderMessage', { what: 12, desc: 'saveSideOrder' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
fileChange: function({detail}){
|
|
this.data.imageList = detail.fileList
|
|
var imageUrls = []
|
|
for (let index = 0; index < this.data.imageList.length; index++) {
|
|
imageUrls.push(this.data.imageList[index].url)
|
|
}
|
|
this.data.form.orderImageList = imageUrls
|
|
},
|
|
submitForm: function(){
|
|
var weightNoteList = []
|
|
for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) {
|
|
const element = this.data.form.productCategoryInfos[index]
|
|
if(util.isEmpty(element.netWeight) || Number(element.netWeight) <= 0){
|
|
util.showToast('请输入第' + (index + 1) + '项废纸品类净重')
|
|
this.setData({ intoview: 'item' + index })
|
|
return
|
|
}
|
|
var item = {grossWeight: element.grossWeight, tareWeight: element.tareWeight,weightNoteImage: element.weightNoteImages }
|
|
item.netWeight = element.netWeight
|
|
item.scrapPaperPurchaseOrderId = element.scrapPaperPurchaseOrderId
|
|
weightNoteList.push(item)
|
|
}
|
|
if(util.isEmpty(this.data.param.offsiteTareWeight)){
|
|
this.setData({ intoview: 'offsiteTareWeight' })
|
|
util.showToast('请输入厂外皮重')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.param.offsiteGrossWeight)){
|
|
this.setData({ intoview: 'offsiteGrossWeight' })
|
|
util.showToast('请输入厂外毛重')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.orderImageList)){
|
|
util.showToast('请上传订单凭证')
|
|
this.setData({ intoview: 'orderImage' })
|
|
return
|
|
}
|
|
if(this.data.form.orderImageList.length < 3){
|
|
util.showToast('订单凭证图片必须3张或者3张以上')
|
|
this.setData({ intoview: 'orderImage' })
|
|
return
|
|
}
|
|
this.data.param.scrapPaperReceiptId = this.data.form.scrapPaperReceiptId
|
|
this.data.param.weightNoteList = weightNoteList
|
|
this.data.param.orderImageList = this.data.form.orderImageList
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
poundSideOrder(this.data.param).then(result => {
|
|
wx.hideLoading()
|
|
util.showBackToast('提交成功')
|
|
event.emit('OrderMessage', { what: 12, desc: 'pricingOrder' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
repeatForm: function(){
|
|
wx.redirectTo({url: `/pages/process/outside-check/index?id=${this.data.id}` })
|
|
},
|
|
priceForm: function(){
|
|
var productCategorySettleInfoDtoList = []
|
|
for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) {
|
|
const element = this.data.form.productCategoryInfos[index]
|
|
if(util.isEmpty(element.settleUnitPrice) || Number(element.settleUnitPrice) <= 0){
|
|
util.showToast('请输入第' + (index + 1) + '项废纸品类结算单价')
|
|
return
|
|
}
|
|
var item = { productId: element.productId, scrapPaperPurchaseOrderId: element.scrapPaperPurchaseOrderId }
|
|
item.deductWeight = element.deductWeight
|
|
item.deductPercent = element.deductPercent
|
|
item.settleUnitPrice = element.settleUnitPrice
|
|
productCategorySettleInfoDtoList.push(item)
|
|
}
|
|
var data = {scrapPaperReceiptId: this.data.form.scrapPaperReceiptId }
|
|
data.productCategorySettleInfoDtoList = productCategorySettleInfoDtoList
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
priceSideOrder(data).then(result => {
|
|
wx.hideLoading()
|
|
if(this.data.form.onsideGrossWeight) {
|
|
util.showBackToast('定价成功')
|
|
} else {
|
|
Dialog.alert({ title: '温馨提示', message: '定价成功,请过磅刷卡获取厂内毛重!' }).then(() => {
|
|
wx.navigateBack()
|
|
})
|
|
}
|
|
event.emit('OrderMessage', { what: 12, desc: 'pricingOrder' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
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)
|
|
})
|
|
},
|
|
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 })
|
|
}
|
|
},
|
|
checkForm: function(){
|
|
|
|
}
|
|
})
|