-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
- {{dict.label}}
-
-
+
+
+
+
+
+
+
+
+
@@ -545,7 +545,7 @@
-
+
@@ -564,7 +564,8 @@
{{qty}}个
- 总计:{{averageTotal}} / {{remainingQty}}
+ 总计:{{averageTotal}} / {{instockQty}}
+ - 必须分配完所有入库数量
@@ -577,7 +578,7 @@
- 总计:{{totalPackageQty}} / {{remainingQty}}
+ 总计:{{totalPackageQty}} / {{instockQty}}
+ - 必须分配完所有入库数量
@@ -783,23 +785,30 @@ listUser({ pageNum: 1, pageSize: 99999 }).then(e => {
})
/** 提交按钮 */
const submitForm = async() => {
- if (!childrenTableInfoForm.value.instockQty || !childrenTableInfoForm.value.printedNum) {
+ if (!childrenTableInfoForm.value.instockQty || childrenTableInfoForm.value.printedNum === undefined) {
ElMessage.error('物料数据未加载完成,请重试')
return
}
+
+ // 检查是否已经打印过
+ if (Number(childrenTableInfoForm.value.printedNum) > 0) {
+ ElMessage.error('该入库单已经打印过,不允许重复打印')
+ return
+ }
+
const split = Number(childrenTableInfoForm.value.splitPackageCount) || 1
const copies = Number(childrenTableInfoForm.value.printCopies) || 1
- const remaining = remainingQty.value
+ const totalInstockQty = instockQty.value // 使用完整的入库数量
if (split > 1) {
- // 分包逻辑:根据模式选择数据源
+ // 分包逻辑:统一使用packageQtyList
let finalPackageList = []
if (packageMode.value === 'average') {
// 平均分包模式:使用平均分包的结果
finalPackageList = averagePackageList.value
const total = averageTotal.value
- if (total > remaining) {
- ElMessage.error('平均分包总计不能超过剩余物料量')
+ if (total !== totalInstockQty) {
+ ElMessage.error(`分包数量大于1时,必须一次性分配完所有入库数量 ${totalInstockQty},当前总计:${total}`)
return
}
if (total <= 0) {
@@ -810,8 +819,8 @@ const submitForm = async() => {
// 自定义模式:使用用户输入的数量
finalPackageList = packageQtyList.value
const total = totalPackageQty.value
- if (total > remaining) {
- ElMessage.error('每包数量总计不能超过剩余物料量')
+ if (total !== totalInstockQty) {
+ ElMessage.error(`分包数量大于1时,每包数量总计必须等于入库数量 ${totalInstockQty},当前总计:${total}`)
return
}
if (total <= 0) {
@@ -825,13 +834,12 @@ const submitForm = async() => {
}
}
- // 将最终的分包数量传递给后端
+ // 无论什么模式,都传递分包数量列表给后端
childrenTableInfoForm.value.packageQtyList = finalPackageList
- childrenTableInfoForm.value.packageMode = packageMode.value // 传递模式信息
} else {
- // 不分包逻辑
- if (split > remaining) {
- ElMessage.error('分包数量不能超过剩余物料量')
+ // 不分包逻辑(单包打印)
+ if (split > totalInstockQty) {
+ ElMessage.error('分包数量不能超过入库数量')
return
}
if (copies < 1) {
@@ -1137,9 +1145,11 @@ const parentTableInfoSubmit = () =>{
// 子表格修改
const childrenTableUpdate = async (e) => {
const detail = (await getInstockDetail(e.instockDetailId)).data
- const remaining = Number(detail.instockQty) - Number(detail.printedNum || 0)
- if(remaining < 1){
- ElMessage.error('无剩余数量可打印')
+ const printed = Number(detail.printedNum || 0)
+
+ // 检查是否已经打印过
+ if(printed > 0){
+ ElMessage.error('该入库单已经打印过,不允许重复打印')
return
}
@@ -1282,7 +1292,7 @@ const handleAssociatePurchaseOrder = async () => {
});
dialogtable.value = res.data.map(item => ({
poDId: item.poDId, // 添加采购订单物料主键
- materialId: item.materialCode, // 修正字段名
+ // materialId: item.materialId,
materialCode: item.materialCode,
materialName: item.materialName,
materialSpe: item.materialSpe,
@@ -1337,18 +1347,25 @@ const validateQty = (row, val) => {
}
// 对于其他类型,验证不超过交付数量(如果有)
- if (row.deliveryQty !== undefined && intVal > row.deliveryQty) {
- row.instockQty = row.deliveryQty;
- ElMessage.warning(`入库数量不能大于交付数量 ${row.deliveryQty}`);
- } else {
- row.instockQty = Math.max(0, intVal);
- }
+ // if (row.deliveryQty !== undefined && intVal > row.deliveryQty) {
+ // row.instockQty = row.deliveryQty;
+ // ElMessage.warning(`入库数量不能大于交付数量 ${row.deliveryQty}`);
+ // } else {
+ // row.instockQty = Math.max(0, intVal);
+ // }
};
const remainingQty = computed(() => {
+ // 注意:这里的remainingQty实际上是用于显示剩余可打印数量
+ // 但分包时应该基于完整的instockQty
const instock = Number(childrenTableInfoForm.value.instockQty) || 0
const printed = Number(childrenTableInfoForm.value.printedNum) || 0
- return Math.max(0, instock - printed) // 添加 Math.max 防护负值
+ return Math.max(0, instock - printed) // 显示剩余可打印数量
+})
+
+// 入库数量(用于分包计算)
+const instockQty = computed(() => {
+ return Number(childrenTableInfoForm.value.instockQty) || 0
})
// 分包相关的响应式数据
@@ -1388,12 +1405,14 @@ const onSplitPackageCountChange = (count) => {
// 计算平均分包数量
const calculateAveragePackage = (count) => {
- const remaining = remainingQty.value
- if (remaining > 0 && count > 0) {
- const avgQty = Math.floor(remaining / count)
- const remainder = remaining % count
+ const totalQty = instockQty.value // 使用完整的入库数量
+ if (totalQty > 0 && count > 0) {
+ const avgQty = Math.floor(totalQty / count)
+ const remainder = totalQty % count
+ averagePackageList.value = []
for (let i = 0; i < count; i++) {
+ // 前面的包分配 avgQty + 1(如果有余数),后面的包分配 avgQty
averagePackageList.value[i] = avgQty + (i < remainder ? 1 : 0)
}
}
@@ -1411,10 +1430,15 @@ const onPackageModeChange = (mode) => {
// 验证总数量是否超出限制
const validateTotalQty = () => {
const total = totalPackageQty.value
- const remaining = remainingQty.value
+ const totalQty = instockQty.value // 使用完整的入库数量
- if (total > remaining) {
- ElMessage.warning(`每包数量总计不能超过剩余数量 ${remaining}`)
+ if (total > totalQty) {
+ ElMessage.warning(`每包数量总计不能超过入库数量 ${totalQty}`)
+ }
+
+ // 分包数量大于1时,必须分配完所有入库数量
+ if (childrenTableInfoForm.value.splitPackageCount > 1 && total !== totalQty) {
+ ElMessage.warning(`分包数量大于1时,每包数量总计必须等于入库数量 ${totalQty}`)
}
}
@@ -1428,6 +1452,17 @@ const isAddDisabled = computed(() => {
return dialogForm.value.instockType === '1';
});
+// 判断行是否可以打印
+const isRowPrintable = (row) => {
+ const printed = Number(row.printedNum || 0)
+ // 如果已经有打印记录,不允许再次打印
+ if (printed > 0) {
+ return false
+ }
+
+ return true
+}
+