diff --git a/src/views/modules/recv/recv.vue b/src/views/modules/recv/recv.vue
index eb89a17..0b97447 100644
--- a/src/views/modules/recv/recv.vue
+++ b/src/views/modules/recv/recv.vue
@@ -74,11 +74,8 @@
-
包装记录
+ style="font-size: 16px;margin-top: -5px" size="small">包装记录
@@ -91,7 +88,7 @@
-
-
+
-
-
-
+
+
+
+
+
+
+
+ 💡 输入单包装数量后,按回车键或点击确定按钮
+
+
+ 手动输入单包装数量和包装数,然后点击"创建"按钮
+
+
+
+
+
+
+
+
+
+
+
创建
+
+ 确定
-
+
删除
+
+
+ 💡 如需修改,请重新输入单包装数量
+
+
合计{{ totalQty }}
回退
确定
@@ -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;