Commit 23bd9d88 authored by dragondean@qq.com's avatar dragondean@qq.com

优化拆单货值

parent 4e49a78e
......@@ -147,10 +147,10 @@ export function deleteAllSplit(orderId) {
}
// 获取拆单订单的总货值与箱数拆分记录
export function splitItemWorthCheck(orderId) {
export function splitItemWorthCheck(orderId, orderSplitItemId) {
return request({
url: '/order/split-item/worth/check',
method: 'get',
params: {orderId}
params: {orderId, orderSplitItemId}
})
}
......@@ -625,13 +625,28 @@ export default {
// 默认取以前放入的品名
let split = this.splitData.find(item => item.id == this.splitData[this.splitIndex].id)
this.shopForm.specsRecordVOList = []
let splitItemId = undefined
let splitItem = undefined
if(split) {
let specsRecordVOList = split.orderSplitItemBackVOList.find(item => item.orderItemId == this.shopForm.orderItemId)?.specsRecordVOList || []
specsRecordVOList.forEach(item => {
const [boxGauge1, boxGauge2, boxGauge3] = item.boxGauge.split('*')
this.shopForm.specsRecordVOList.push({...item, boxGauge1, boxGauge2, boxGauge3})
})
splitItem = split.orderSplitItemBackVOList.find(item => item.orderItemId == this.shopForm.orderItemId)
if(splitItem){
let specsRecordVOList = splitItem.specsRecordVOList || []
specsRecordVOList.forEach(item => {
const [boxGauge1, boxGauge2, boxGauge3] = item.boxGauge.split('*')
this.shopForm.specsRecordVOList.push({...item, boxGauge1, boxGauge2, boxGauge3})
})
splitItemId = splitItem.id
}
}
// 填充原来的收费数据和货值
this.$set(this.shopForm, 'chargeVolume', splitItem?.chargeVolume || 0)
this.$set(this.shopForm, 'chargeWeight', splitItem?.chargeWeight || 0)
this.$set(this.shopForm, 'worth', splitItem?.worth || 0)
// 获取剩余货值,排除当前品名已放入数据
this.getOrderLeftData(splitItemId)
},
'shopForm.worth'(val, oldVal){
console.log('worth change from', oldVal, 'to', val)
......@@ -1014,6 +1029,11 @@ export default {
specsRecordVOList:this.shopForm.specsRecordVOList
}
// 货值不能超过可拆货值
if(params.worth > this.orderLeftData.splitResidueWorth){
return this.$message.error(this.$t('货值不能超过可拆货值'))
}
// 体积重量不能为0
const fields = {
'volume': this.$t('体积'),
......@@ -1155,8 +1175,8 @@ export default {
// 货值按照订单的总货值比例计算,所以需要判断是否是最后一次放入
let worth = (this.orderLeftData.totalWorth * this.putin.num / this.orderLeftData.sumNum).toFixed(2)
// 如果是最后放入
if(this.orderLeftData.splitResidueNum == this.putin.num){
// 如果是最后放入,或者超过了剩余货值,则直接取剩余货值
if(this.orderLeftData.splitResidueNum == this.putin.num || worth > this.orderLeftData.splitResidueWorth){
worth = this.orderLeftData.splitResidueWorth
}
this.$set(this.shopForm, 'worth', worth)
......@@ -1173,8 +1193,8 @@ export default {
this.$store.dispatch('tagsView/delCurrentView')
},
// 查询订单剩余数据
getOrderLeftData(){
splitItemWorthCheck(this.queryParams.orderId).then(res => {
getOrderLeftData(orderSplitItemId){
splitItemWorthCheck(this.queryParams.orderId, orderSplitItemId).then(res => {
this.orderLeftData = res.data
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment