Commit ec3671e2 authored by dragondean@qq.com's avatar dragondean@qq.com

完善装柜拆单的默认值计算和最大值优化

parent fa355cf3
...@@ -199,48 +199,50 @@ ...@@ -199,48 +199,50 @@
<el-dialog :title="$t('放入品名')" :visible.sync="shopOpen" width="400px" append-to-body> <el-dialog :title="$t('放入品名')" :visible.sync="shopOpen" width="400px" append-to-body>
<el-form ref="shopForm" :model="shopForm" :rules="shopRules" label-width="100px"> <el-form ref="shopForm" :model="shopForm" :rules="shopRules" label-width="100px">
<el-row> <el-row>
<el-form-item :label="$t('中文品名')+':'" prop="zhId"> <el-form-item :label="$t('中文品名')+':'" prop="orderItemId">
<el-select v-model="shopForm.zhId" :placeholder="$t('请选择中文品名')" @change="changeProdTitleZh"> <el-select v-model="shopForm.orderItemId" :placeholder="$t('请选择中文品名')" @change="onProdChange">
<el-option v-for="item in orderItems" :label="item.prodTitleZh" :value="item.id" :key="item.id" :disabled="itemDisabled(item)"></el-option> <el-option v-for="item in orderItems" :label="item.prodTitleZh" :value="item.orderItemId" :key="item.id" :disabled="itemDisabled(item)"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-row> </el-row>
<el-row> <el-row>
<el-form-item :label="$t('英文品名')+':'" prop="enId"> <el-form-item :label="$t('英文品名')+':'" prop="orderItemId">
<el-select v-model="shopForm.enId" :placeholder="$t('请选择英文品名')" @change="changeProdTitleEn"> <el-select v-model="shopForm.orderItemId" :placeholder="$t('请选择英文品名')" @change="onProdChange">
<el-option v-for="item in orderItems" :label="item.prodTitleEn" :value="item.id" :key="item.id" :disabled="itemDisabled(item)"></el-option> <el-option v-for="item in orderItems" :label="item.prodTitleEn" :value="item.orderItemId" :key="item.id" :disabled="itemDisabled(item)"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item :label="$t('剩余箱数')+':'"> <el-form-item :label="$t('剩余箱数')+':'">
{{shopForm.num||0}} {{shopForm.leftNum||0}}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-show="isQuantity"> <!--剩余数量计算不出来,显示没意义-->
<!--<el-col :span="12" v-show="isQuantity">
<el-form-item :label="$t('剩余数量(个)')+':'"> <el-form-item :label="$t('剩余数量(个)')+':'">
{{shopForm.quantity||0}} {{shopForm.leftQuantity||0}}
</el-form-item> </el-form-item>
</el-col> </el-col>-->
</el-row> </el-row>
<el-form-item :label="$t('放入箱数')+':'"> <el-form-item :label="$t('放入箱数')+':'">
{{shopForm.putNum||0}} {{shopForm.num||0}}
</el-form-item>
<el-form-item :label="$t('放入数量(个)')+':'" prop="quantity" v-show="isQuantity">
<el-input-number v-model="shopForm.quantity" controls-position="right" :min="0" :max="mainOrderItem.quantity || undefined"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item :label="$t('入仓体积')"> <el-form-item :label="$t('入仓体积')">
<el-input-number v-model="shopForm.volume" controls-position="right" :min="0" :max="orderItem.warehouseInInfoVO.volume"></el-input-number> <el-input-number v-model="shopForm.volume" controls-position="right" :min="0" :max="mainOrderItem.volume"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item :label="$t('收费体积')"> <el-form-item :label="$t('收费体积')">
<el-input-number v-model="shopForm.chargeVolume" controls-position="right" :min="0" :max="orderItem.chargeVolume"></el-input-number> <el-input-number v-model="shopForm.chargeVolume" controls-position="right" :min="0" :max="mainOrderItem.chargeVolume"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item :label="$t('入仓重量')"> <el-form-item :label="$t('入仓重量')">
<el-input-number v-model="shopForm.weight" controls-position="right" :min="0" :max="orderItem.warehouseInInfoVO.weight"></el-input-number> <el-input-number v-model="shopForm.weight" controls-position="right" :min="0" :max="mainOrderItem.weight"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item :label="$t('收费重量')"> <el-form-item :label="$t('收费重量')">
<el-input-number v-model="shopForm.chargeWeight" controls-position="right" :min="0" :max="orderItem.chargeWeight"></el-input-number> <el-input-number v-model="shopForm.chargeWeight" controls-position="right" :min="0" :max="mainOrderItem.chargeWeight"></el-input-number>
</el-form-item> </el-form-item>
<!-- <el-form-item :label="$t('放入数量(个)')+':'" prop="putQuantity" v-show="isQuantity">
<el-input-number v-model="shopForm.putQuantity" controls-position="right" :min="0"></el-input-number>
</el-form-item> -->
<el-form-item :label="$t('备注信息')+':'"> <el-form-item :label="$t('备注信息')+':'">
<el-input v-model="shopForm.remarks"></el-input> <el-input v-model="shopForm.remarks"></el-input>
</el-form-item> </el-form-item>
...@@ -312,6 +314,9 @@ export default { ...@@ -312,6 +314,9 @@ export default {
lang: 0, lang: 0,
}, },
isQuantity: false, isQuantity: false,
// 主单数据
mainOrder: {orderSplitItemBackVOList: {}}
}; };
}, },
created() { created() {
...@@ -359,9 +364,10 @@ export default { ...@@ -359,9 +364,10 @@ export default {
return false; return false;
}, },
// 订单项数据,默认要返回一个如下的空json结构体,避免报错 // 订单项数据,默认要返回一个如下的空json结构体,避免报错
orderItem(){ // 装柜拆单只能拆一个出来,所以直接用原单数据作为放入品名的最大值限制即可,跟订单操作中的拆单有所区别
if(!this.orderData) return {warehouseInInfoVO:{}} mainOrderItem(){
return this.orderData.orderItemVOList.find(item => item.orderItemId == this.shopForm.orderItemId) || {warehouseInInfoVO:{}} if(!this.shopForm.orderItemId || !this.mainOrder.orderSplitItemBackVOList.length) return {}
return this.mainOrder.orderSplitItemBackVOList.find(item => item.orderItemId == this.shopForm.orderItemId) || {}
} }
}, },
methods: { methods: {
...@@ -378,23 +384,23 @@ export default { ...@@ -378,23 +384,23 @@ export default {
this.getList() this.getList()
}) })
}, },
/* 拆箱总数 */ /* 拆箱总数,默认计算箱数,传递quantity可计算个数 */
totalSplitNum() { totalSplit(field = 'num') {
let _total = 0; let _total = 0;
const { orderSplitItemBackVOList = [] } = this.splitData; const { orderSplitItemBackVOList = [] } = this.splitData;
orderSplitItemBackVOList.forEach((v) => { orderSplitItemBackVOList.forEach((v) => {
_total = Decimal.add(_total, Number(v.num)).toNumber(); _total = Decimal.add(_total, Number(v[field])).toNumber();
}); });
return _total; return _total;
}, },
totalSplitQty() { /*totalSplitQty() {
let _total = 0; let _total = 0;
const { orderSplitItemBackVOList = [] } = this.splitData; const { orderSplitItemBackVOList = [] } = this.splitData;
orderSplitItemBackVOList.forEach((v) => { orderSplitItemBackVOList.forEach((v) => {
_total = Decimal.add(_total, Number(v.quantity)).toNumber(); _total = Decimal.add(_total, Number(v.quantity)).toNumber();
}); });
return _total; return _total;
}, },*/
/* 打开拆单 */ /* 打开拆单 */
getSplit() { getSplit() {
this.orderItems = this.currRow.goodsList ?? []; this.orderItems = this.currRow.goodsList ?? [];
...@@ -406,6 +412,8 @@ export default { ...@@ -406,6 +412,8 @@ export default {
const data = res.data; const data = res.data;
// 取拆单项 // 取拆单项
this.splitData = data.filter((item) => !item.isMaster)?.[0] ?? {}; this.splitData = data.filter((item) => !item.isMaster)?.[0] ?? {};
// 取主单,用语判断放入品名的数据上限
this.mainOrder = data.find(item => item.isMaster)
}); });
}, },
itemDisabled(data) { itemDisabled(data) {
...@@ -510,7 +518,36 @@ export default { ...@@ -510,7 +518,36 @@ export default {
this.shopOpen = true; this.shopOpen = true;
this.isQuantity = false; this.isQuantity = false;
}, },
async changeProdTitleZh() { // 更改放入品名后触发,计算重量体积等默认值
onProdChange(){
// 根据键值(中文名或者英文名)来获取对应商品的信息,注:这里应该可以采用orderItemId来获取更优,而不是商品名称,同名可能导致异常
let orderItem = this.orderData.orderItemVOList.find(item => item.orderItemId == this.shopForm.orderItemId)
console.log({orderItem})
// 剩余可装箱数,订单入仓箱数 - 订单已装箱数 - 已拆箱数
let leftNum = Decimal(this.currRow.num).minus(this.currRow.installNum).minus(this.totalSplit('num'))
// 剩余箱数
this.$set(this.shopForm, 'leftNum', leftNum)
// 如果主单商品项的入仓箱数小于可装箱数,则取商品项数据
leftNum = Math.min(leftNum, this.mainOrderItem.num)
// 放入箱数
this.$set(this.shopForm, 'num', leftNum)
// 装箱比例
const rate = leftNum / this.mainOrderItem.num
// 放入个数,剩余个数是算不出来的,因为不知道已装数量,所以放入数量只能按照总数的比例计算
this.$set(this.shopForm, 'quantity', Math.ceil(this.mainOrderItem.quantity|| 0 * rate))
// 数量,体积,重量等按照比例给默认值
this.$set(this.shopForm, 'volume', (this.mainOrderItem.volume * rate).toFixed(2))
this.$set(this.shopForm, 'chargeVolume', (this.mainOrderItem.chargeVolume * rate).toFixed(2))
this.$set(this.shopForm, 'weight', (this.mainOrderItem.weight * rate).toFixed(2))
this.$set(this.shopForm, 'chargeWeight', (this.mainOrderItem.chargeWeight * rate).toFixed(2))
},
/*async changeProdTitleZh() {
const item = this.setShopForm("zhId"); const item = this.setShopForm("zhId");
this.shopForm.enId = item.id; this.shopForm.enId = item.id;
this.shopForm = { ...this.shopForm }; this.shopForm = { ...this.shopForm };
...@@ -563,7 +600,7 @@ export default { ...@@ -563,7 +600,7 @@ export default {
this.shopForm.num this.shopForm.num
).toFixed(0); ).toFixed(0);
return data; return data;
}, },*/
async getSelectData(item) { async getSelectData(item) {
await quantitycheck({ await quantitycheck({
seaFreightVolume: item.seaFreightVolume, seaFreightVolume: item.seaFreightVolume,
...@@ -587,6 +624,8 @@ export default { ...@@ -587,6 +624,8 @@ export default {
shopAdd() { shopAdd() {
this.$refs["shopForm"].validate((valid) => { this.$refs["shopForm"].validate((valid) => {
if (valid) { if (valid) {
// 放入箱数自动计算出来的,所以不需要在做判断了
/*
// 输入箱数大于实装箱数 // 输入箱数大于实装箱数
const total = this.totalSplitNum(); const total = this.totalSplitNum();
const canSplitNum = Decimal.sub( const canSplitNum = Decimal.sub(
...@@ -597,19 +636,19 @@ export default { ...@@ -597,19 +636,19 @@ export default {
if (this.shopForm.num > remain) { if (this.shopForm.num > remain) {
this.$message.error(this.$t("放入箱数不能大于总箱数")); this.$message.error(this.$t("放入箱数不能大于总箱数"));
return; return;
} }*/
if (this.shopForm.num === 0) { if (this.shopForm.num === 0) {
this.$message.error(this.$t("放入箱数不能为0")); this.$message.error(this.$t("放入箱数不能为0"));
return; return;
} }
if (this.shopForm.putQuantity === 0 && this.isQuantity) { if (this.shopForm.quantity === 0 && this.isQuantity) {
this.$message.error(this.$t("放入数量(个)不能为0")); this.$message.error(this.$t("放入数量(个)不能为0"));
return; return;
} }
let params = { let params = {
num: this.shopForm.putNum, num: this.shopForm.num,
quantity: this.shopForm.putQuantity, quantity: this.shopForm.quantity,
orderItemId: this.shopForm.orderItemId, orderItemId: this.shopForm.orderItemId,
orderSplitId: this.splitData.id, orderSplitId: this.splitData.id,
remarks: this.shopForm.remarks, remarks: this.shopForm.remarks,
......
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