Commit 36900e21 authored by dragondean@qq.com's avatar dragondean@qq.com

完善订单拆单,根据入仓记录判断超限

parent 67704ace
......@@ -4,7 +4,9 @@
<el-card>
<div slot="header">{{$t('可拆出入仓记录')}}</div>
<el-table :data="[warehouseRecord]">
<el-table-column :label="$t('箱数')" prop="cartonsNum" />
<el-table-column :label="$t('剩余') +'/'+ $t('箱数')" prop="cartonsNum">
<template slot-scope="{row}">{{leftData('num')}}/{{row.cartonsNum}}</template>
</el-table-column>
<el-table-column :label="$t('入仓类型')" prop="specificationType">
<template slot-scope="{row}">
<dict-tag :type="DICT_TYPE.WAREHOUSING_SPECIFICATION_TYPE" :value="row.specificationType" />
......@@ -206,10 +208,11 @@
import WarehouseAreaSelect from "@/components/WarehouseAreaSelect/index.vue";
import {parseTime} from '@/utils/ruoyi'
import Decimal from 'decimal.js'
import Template from "@/views/cms/template/index.vue";
export default {
name: "WarehouseRecord",
filters:{parseTime},
components: {WarehouseAreaSelect},
components: {Template, WarehouseAreaSelect},
props:{
warehouseRecord:Object,
appendToBody: Boolean,
......@@ -235,6 +238,23 @@ export default {
})
return total.toNumber()
}
},
// 剩余数据
leftData(){
return field => {
// 入仓记录跟拆单记录的箱数字段不同,要做特殊处理
let left = new Decimal(this.warehouseRecord[field == 'num' ? 'cartonsNum' : field] || 0)
console.log('leftData', left.toNumber())
// 累减已拆记录
this.warehouseRecord.specsRecordVOList.forEach(item => {
left = left.minus(new Decimal(item[field] || 0))
})
// 累减本页添加的入仓记录
this.form.list.forEach(item => {
left = left.minus(new Decimal(item[field] || 0))
})
return left.toNumber()
}
}
},
mounted() {
......@@ -248,6 +268,7 @@ export default {
let num = this.warehouseRecord.cartonsNum
// 根据入仓记录添加一行
this.form.list.push({
warehouseInId: this.warehouseRecord.id,
specificationType, boxGauge1, boxGauge2, boxGauge3, volume, weight,num,
orderLocationList: this.warehouseRecord.orderLocationBackVOList
})
......
......@@ -309,7 +309,8 @@
</el-table-column>
<el-table-column :label="$t('操作')">
<template v-slot="{ row, column, $index}">
<el-button size="mini" type="primary" @click="putInRecord(row)">放入</el-button>
<el-tag v-if="getWarehouseInLeftData(row.id,'num') >= row.cartonsNum" disabled size="mini" type="primary" >{{$t('已拆完')}}</el-tag>
<el-button v-else size="mini" type="primary" @click="putInRecord(row)">放入</el-button>
</template>
</el-table-column>
</el-table>
......@@ -607,11 +608,18 @@ export default {
num: new Decimal(this.orderItem.warehouseInInfoVO?.cartonsNum || 0),
volume: new Decimal(this.orderItem.warehouseInInfoVO?.volume || 0),
weight: new Decimal(this.orderItem.warehouseInInfoVO?.weight || 0),
quantity: new Decimal(this.orderItem.warehouseInInfoVO?.quantity || 0)
quantity: new Decimal(this.orderItem.warehouseInInfoVO?.quantity || 0),
chargeVolume: new Decimal(this.orderItem.chargeVolume || 0),
chargeWeight: new Decimal(this.orderItem.chargeWeight || 0)
}
// 全部拆单的放入数据累减
this.splitData.forEach(split => {
split.orderSplitItemBackVOList.forEach(splitItem => {
// 每个品名都要累减收费数据
data.chargeVolume = data.chargeVolume.minus(new Decimal(splitItem.chargeVolume || 0))
data.chargeWeight = data.chargeWeight.minus(new Decimal(splitItem.chargeWeight || 0))
// 每个品名的入仓记录挨个累减其他数据
if(splitItem.orderItemId == this.shopForm.orderItemId){
data.num = data.num.minus(new Decimal(splitItem.num || 0))
data.volume = data.volume.minus(new Decimal(splitItem.volume || 0))
......@@ -684,6 +692,37 @@ export default {
return item
})
}
},
// 根据入仓记录ID筛选出他的全部拆出记录
getWarehouseInspecsRecordVOList(){
return warehouseInId => {
let specsRecordVOList = []
// 这里是全部已放入的
this.splitData.forEach(split => {
split.orderSplitItemBackVOList.forEach(splitItem => {
splitItem.specsRecordVOList.forEach(specs => {
if(specs.warehouseInId === warehouseInId){
specsRecordVOList.push(specs)
}
})
})
})
// 这里是全部正在操作放入,但是还没确定提交的
this.shopForm.specsRecordVOList.forEach(item => {
if(item.warehouseInId == warehouseInId)specsRecordVOList.push(item)
})
return specsRecordVOList
}
},
// 根据入仓ID获取剩余数据
getWarehouseInLeftData(){
return (warehouseInId, field) => {
let total = new Decimal(0)
this.getWarehouseInspecsRecordVOList(warehouseInId).forEach(item => {
total = total.plus(new Decimal(item[field] || 0))
})
return total.toNumber()
}
}
},
methods: {
......@@ -1051,8 +1090,18 @@ export default {
// 根据入仓记录打开放入弹层
putInRecord(row){
this.currentPutIn = row
// 计算此条入仓记录已拆出的数据,这样在放入的时候可以确保不超过此入仓记录的数量
// 此条入仓记录已拆出的入仓记录,这样在放入的时候可以确保不超过此入仓记录的数量
let specsRecordVOList = []
this.splitData.forEach(split => {
split.orderSplitItemBackVOList.forEach(splitItem => {
splitItem.specsRecordVOList.forEach(specs => {
if(specs.warehouseInId === row.id){
specsRecordVOList.push(specs)
}
})
})
})
this.currentPutIn.specsRecordVOList = specsRecordVOList
},
// 放入回调
handlePutin(list){
......
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