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.
120 lines
4.9 KiB
120 lines
4.9 KiB
// pages/process/order-check/index.js
|
|
import Scene from '../../index/scene'
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { repeatSideOrder, getPaperList, getSideOrderInfo} 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,
|
|
safeBottom: app.globalData.safeBottom,
|
|
paperList: [],
|
|
form: null,
|
|
intoview: ''
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(options.id){
|
|
var height = app.globalData.fragmentHeight - app.globalData.safeBottom - 120
|
|
wx.showLoading({ title: '正在获取', mask: true })
|
|
getPaperList({pageNum: 1, pageSize: 100}).then(result => {
|
|
this.setData({ safeBottom: app.globalData.safeBottom, paperList: result.data.records, height })
|
|
}).catch(err => {
|
|
this.setData({ safeBottom: app.globalData.safeBottom, height })
|
|
util.showToast(err)
|
|
})
|
|
getSideOrderInfo({ id: options.id }).then(result => {
|
|
result.data.settleTotalAmount = 0
|
|
for (let index = 0; index < result.data.productCategoryInfos.length; index++) {
|
|
const element = result.data.productCategoryInfos[index]
|
|
element.settlePrice = math.times(element.settleWeight, element.settleUnitPrice)
|
|
result.data.settleTotalAmount = math.plus(result.data.settleTotalAmount, element.settlePrice)
|
|
}
|
|
this.setData({ form: result.data })
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
},
|
|
onProductChange: function({detail}){
|
|
this.data.form.productCategoryInfos[detail.index] = detail.item
|
|
var estimatedAmount = 0
|
|
for (let index = 0; index < this.data.form.productCategoryInfos.length; index++) {
|
|
const element = this.data.form.productCategoryInfos[index]
|
|
if(!util.isEmpty(element.settlePrice) && Number(element.settlePrice) > 0){
|
|
estimatedAmount = math.plus(estimatedAmount, element.settlePrice)
|
|
}
|
|
}
|
|
this.setData({ ['form.settleTotalAmount']: estimatedAmount.toFixed(2) })
|
|
},
|
|
checkForm: function(){
|
|
if(this.data.form.onsideGrossWeight) {
|
|
this.checkOrder()
|
|
} else {
|
|
var message = '此订单没有厂内毛重数据,按照正常流程请刷卡过磅,获取厂内毛重数据,如果已经无法获取,请仔细查验纸品和相关数据,确定没有问题后,进行审核。'
|
|
Dialog.confirm({ title: '温馨提示', message, confirmButtonText: '确定审核' }).then(() => {
|
|
this.checkOrder()
|
|
})
|
|
}
|
|
},
|
|
findCateById: function(productId){
|
|
for (let index = 0; index < this.data.paperList.length; index++) {
|
|
const element = this.data.paperList[index]
|
|
if(element.id == productId){
|
|
return element
|
|
}
|
|
}
|
|
return null
|
|
},
|
|
checkOrder: 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.settleUnitPrice) || Number(element.settleUnitPrice) <= 0){
|
|
util.showToast('请输入第' + (index + 1) + '项废纸品类结算单价')
|
|
this.setData({ intoview: 'item' + index })
|
|
return
|
|
}
|
|
if(!util.isEmpty(this.data.form.scrapPaperReceiptId)){
|
|
var cate = this.findCateById(element.productId)
|
|
if(cate){
|
|
element.highestUnitPrice = cate.highestUnitPrice
|
|
element.lowestUnitPrice = cate.lowestUnitPrice
|
|
}
|
|
}
|
|
if(element.highestUnitPrice && Number(element.settleUnitPrice) > Number(element.highestUnitPrice)){
|
|
util.showToast('第' + (index + 1) + '项废纸品类单价不得高于:' + element.highestUnitPrice + '元/公斤')
|
|
this.setData({ intoview: 'item' + index })
|
|
return
|
|
}
|
|
if(element.lowestUnitPrice && Number(element.settleUnitPrice) < Number(element.lowestUnitPrice)){
|
|
util.showToast('第' + (index + 1) + '项废纸品类单价不得低于:' + element.lowestUnitPrice + '元/公斤')
|
|
this.setData({ intoview: 'item' + index })
|
|
return
|
|
}
|
|
var item = { productId: element.productId, scrapPaperPurchaseOrderId: element.scrapPaperPurchaseOrderId }
|
|
item.deductWeight = element.deductWeight
|
|
item.deductPercent = element.deductPercent
|
|
item.settleUnitPrice = element.settleUnitPrice
|
|
weightNoteList.push(item)
|
|
}
|
|
repeatSideOrder({scrapPaperReceiptId: this.data.form.scrapPaperReceiptId, productCategorySettleInfoDtoList: weightNoteList }).then(result => {
|
|
wx.hideLoading()
|
|
event.emit('OrderMessage', { what: 12, desc: 'repeatSideOrder' })
|
|
util.showBackToast('订单审核已通过')
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
})
|