|
|
|
@ -74,11 +74,8 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label=" "> |
|
|
|
<!-- <el-button type="text" @click.stop="handlingUnitStep" :disabled="recvItem.needHandlingUnit !== 'Y'" |
|
|
|
:class="{ 'disabled-button': recvItem.needHandlingUnit !== 'Y' }" |
|
|
|
style="font-size: 16px" size="small">包装记录</el-button>--> |
|
|
|
<el-button type="text" @click.stop="handlingUnitStep" |
|
|
|
style="font-size: 16px" size="small">包装记录</el-button> |
|
|
|
style="font-size: 16px;margin-top: -5px" size="small">包装记录</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> <el-form-item label="高度(mm)"> |
|
|
|
@ -91,7 +88,7 @@ |
|
|
|
<el-input v-model="recvItem.wdr" placeholder="请输入WDR" /> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item label="到达日期"> |
|
|
|
<el-date-picker v-model="recvItem.arrivalDate" type="date" format="yyyy-MM-dd HH:mm:ss" |
|
|
|
<el-date-picker v-model="recvItem.arrivalDate" type="datetime" format="yyyy-MM-dd HH:mm:ss" |
|
|
|
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择到达日期" style="width: 100%" |
|
|
|
inputmode="none" |
|
|
|
autocomplete="off" |
|
|
|
@ -112,22 +109,60 @@ |
|
|
|
<el-form label-position="top" class="form-section" style="margin: 5px;"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="12"><el-form-item label="商品编码"><el-input v-model="recvItem.partNo" disabled /></el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item label="计量单位"><el-input v-model="recvItem.purchaseUOM" disabled /></el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item label="待收数量"><el-input v-model="recvItem.qtyToReceive" disabled /></el-form-item></el-col> |
|
|
|
<el-col :span="24"><el-form-item label="商品名称"><el-input v-model="recvItem.description" disabled /></el-form-item></el-col> |
|
|
|
<el-col :span="8"><el-form-item label="单包装数量"><el-input v-model="hanlingItem.perQty" /></el-form-item></el-col> |
|
|
|
<el-col :span="8"><el-form-item label="包装数"><el-input v-model="hanlingItem.packageQty" /></el-form-item></el-col> |
|
|
|
<el-col :span="8" style="margin-top: 24px"><el-form-item> |
|
|
|
|
|
|
|
<!-- 自动计算开关 --> |
|
|
|
<el-col :span="24" style="margin-bottom: 10px;"> |
|
|
|
<el-form-item> |
|
|
|
<el-switch |
|
|
|
v-model="autoCalculate" |
|
|
|
active-text="自动计算模式" |
|
|
|
inactive-text="手动输入模式" |
|
|
|
active-color="#17B3A3" |
|
|
|
style="display: block;" |
|
|
|
> |
|
|
|
</el-switch> |
|
|
|
<span v-if="autoCalculate" style="font-size: 13px; color: #17B3A3; margin-top: 5px; display: block; font-weight: bold;"> |
|
|
|
💡 输入单包装数量后,按回车键或点击确定按钮 |
|
|
|
</span> |
|
|
|
<span v-else style="font-size: 12px; color: #999; margin-top: 5px; display: block;"> |
|
|
|
手动输入单包装数量和包装数,然后点击"创建"按钮 |
|
|
|
</span> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="8"><el-form-item label="单包装数量"> |
|
|
|
<el-input |
|
|
|
v-model="hanlingItem.perQty" |
|
|
|
type="number" |
|
|
|
:placeholder="autoCalculate ? '输入完按回车或失去焦点' : '请输入单包装数量'" |
|
|
|
@blur="autoCalculate && autoCreateHandlingUnits()" |
|
|
|
@keyup.enter.native="autoCalculate && autoCreateHandlingUnits()" |
|
|
|
/> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="8" v-if="!autoCalculate"><el-form-item label="包装数"> |
|
|
|
<el-input v-model="hanlingItem.packageQty" type="number" placeholder="请输入包装数" /> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="8" v-if="!autoCalculate" style="margin-top: 16px"><el-form-item> |
|
|
|
<el-button type="text" @click="createHandlingUnit" style="font-size: 16px">创建</el-button></el-form-item></el-col> |
|
|
|
<el-col :span="8" v-else style="margin-top: 16px"><el-form-item> |
|
|
|
<el-button type="text" style="font-size: 16px">确定</el-button></el-form-item></el-col> |
|
|
|
<el-table :data="handlingUnit" :row-style="{ height: '30px' }" style="width: 94%; margin-left: 10px;" highlight-current-row> |
|
|
|
<el-table-column prop="code" label="序号" /> |
|
|
|
<el-table-column prop="packageQty" label="包装数" width="80" /> |
|
|
|
<el-table-column prop="perQty" label="单包装数量" width="100" /> |
|
|
|
<el-table-column label="操作"> |
|
|
|
<el-table-column label="操作" v-if="!autoCalculate"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<a @click="removeItem(scope.$index)">删除</a> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-col :span="24" v-if="autoCalculate && handlingUnit.length > 0" style="margin-top: 10px;"> |
|
|
|
<span style="font-size: 12px; color: #999;"> |
|
|
|
💡 如需修改,请重新输入单包装数量 |
|
|
|
</span> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"><el-form-item><span>合计</span><span style="margin-left: 38%">{{ totalQty }}</span></el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item><el-button type="text" @click="processFlag = 2" style="font-size: 18px;margin-left: 60px">回退</el-button></el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item><el-button type="text" @click="processFlag = 2" style="font-size: 18px;">确定</el-button></el-form-item></el-col> |
|
|
|
@ -154,7 +189,8 @@ export default { |
|
|
|
site:localStorage.getItem('site'), |
|
|
|
warehouseId:localStorage.getItem('selectedWarehouse'), |
|
|
|
fullscreenLoading: false, // 控制全屏loading |
|
|
|
loadingText: '加载中...' // 动态loading文本 |
|
|
|
loadingText: '加载中...', // 动态loading文本 |
|
|
|
autoCalculate: true // 自动计算包装数开关 |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
@ -170,6 +206,22 @@ export default { |
|
|
|
return `${this.recvItem.lineNo || ''}/${this.recvItem.releaseNo}`; |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
// 监听自动计算开关变化 |
|
|
|
autoCalculate(newVal, oldVal) { |
|
|
|
// 切换模式时清空输入框和HU列表 |
|
|
|
this.hanlingItem.perQty = ''; |
|
|
|
this.hanlingItem.packageQty = ''; |
|
|
|
this.handlingUnit = []; |
|
|
|
localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit)); |
|
|
|
|
|
|
|
if (newVal) { |
|
|
|
this.$message.success('已切换到自动创建HU模式'); |
|
|
|
} else { |
|
|
|
this.$message.success('已切换到手动输入模式'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 计算“显示宽度” |
|
|
|
getTextWidth(text) { |
|
|
|
@ -277,9 +329,77 @@ export default { |
|
|
|
}, |
|
|
|
handlingUnitStep() { |
|
|
|
this.processFlag = 3; |
|
|
|
this.autoCalculate = true; // 重置自动计算开关 |
|
|
|
const saved = localStorage.getItem(this.huKey); |
|
|
|
this.handlingUnit = saved ? JSON.parse(saved) : []; |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 自动创建HU列表(自动模式) |
|
|
|
*/ |
|
|
|
autoCreateHandlingUnits() { |
|
|
|
const perQty = this.hanlingItem.perQty; |
|
|
|
|
|
|
|
// 验证输入 |
|
|
|
if (!perQty || isNaN(perQty) || parseFloat(perQty) <= 0) { |
|
|
|
this.$message.warning('请输入有效的单包装数量'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取待收数量 |
|
|
|
const qtyToReceive = parseFloat(this.recvItem.qtyToReceive) || 0; |
|
|
|
if (qtyToReceive <= 0) { |
|
|
|
this.$message.warning('待收数量为0,无法创建HU'); |
|
|
|
this.hanlingItem.perQty = ''; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const perQtyValue = parseFloat(perQty); |
|
|
|
|
|
|
|
// 计算需要多少个完整包装 |
|
|
|
const packageQty = Math.floor(qtyToReceive / perQtyValue); |
|
|
|
// 计算余数(最后一个包装的数量) |
|
|
|
const remainder = qtyToReceive - (packageQty * perQtyValue); |
|
|
|
|
|
|
|
// 清空现有的HU列表 |
|
|
|
this.handlingUnit = []; |
|
|
|
|
|
|
|
// 创建完整包装的HU |
|
|
|
if (packageQty > 0) { |
|
|
|
for (let i = 1; i <= packageQty; i++) { |
|
|
|
const qty = perQtyValue; |
|
|
|
const code = String(i); |
|
|
|
this.handlingUnit.push({ |
|
|
|
code: code, |
|
|
|
perQty: perQtyValue, |
|
|
|
packageQty: 1, |
|
|
|
qty: qty |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果有余数,创建最后一个HU |
|
|
|
if (remainder > 0) { |
|
|
|
const code = String(this.handlingUnit.length + 1); |
|
|
|
this.handlingUnit.push({ |
|
|
|
code: code, |
|
|
|
perQty: remainder, |
|
|
|
packageQty: 1, |
|
|
|
qty: remainder |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 保存到localStorage |
|
|
|
localStorage.setItem(this.huKey, JSON.stringify(this.handlingUnit)); |
|
|
|
|
|
|
|
// 清空输入框 |
|
|
|
this.hanlingItem.perQty = ''; |
|
|
|
this.hanlingItem.packageQty = ''; |
|
|
|
|
|
|
|
this.$message.success(`自动创建了${this.handlingUnit.length}个HU,合计数量:${qtyToReceive}`); |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 手动创建HU(手动模式) |
|
|
|
*/ |
|
|
|
createHandlingUnit() { |
|
|
|
const { perQty, packageQty } = this.hanlingItem; |
|
|
|
if (!perQty || !packageQty || isNaN(perQty) || isNaN(packageQty)) { |
|
|
|
@ -500,7 +620,7 @@ export default { |
|
|
|
cursor: not-allowed !important; |
|
|
|
} |
|
|
|
.form-section >>> .el-col { |
|
|
|
margin-bottom: 12px; |
|
|
|
margin-bottom: 2px; |
|
|
|
} |
|
|
|
.status-bar { |
|
|
|
display: flex; |
|
|
|
|