From ce9529afda23b429d55ed8aa6917601bf6ff1e5d Mon Sep 17 00:00:00 2001 From: hwj Date: Tue, 23 Jun 2026 16:25:35 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=85=A5=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E6=8D=AE-=E7=89=A9=E6=96=99=E3=80=81=E5=A4=87=E4=BB=B6?= =?UTF-8?q?=E5=85=A5=E5=BA=93-=E6=B7=BB=E5=8A=A0=E2=80=9C=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E5=8C=85=E6=95=B0=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en.ts | 2 + src/locales/zh-CN.ts | 2 + .../stock/in/components/StockInItemForm.vue | 75 +++++++++++++++---- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/locales/en.ts b/src/locales/en.ts index 870dc2fa..5193bb94 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -576,6 +576,8 @@ export default { selectedPallets: 'Selected Pallets', packageCount: 'Package Count', outPackageCount: 'Outbound Package Count', + inPackageCount: 'Inbound Package Count', + inItemCount: 'Inbound Count', outCount: 'Outbound Count', packageCountWithItems: 'Package Count ({count} per package)', itemCount: 'Item Count', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 65dd7db1..7e4e94ce 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -576,6 +576,8 @@ export default { selectedPallets: '已选托盘', packageCount: '包数', outPackageCount: '出库包数', + inPackageCount: '入库包数', + inItemCount: '入库个数', outCount: '出库个数', packageCountWithItems: '包数(每包{count}个)', itemCount: '个数', diff --git a/src/views/erp/stock/in/components/StockInItemForm.vue b/src/views/erp/stock/in/components/StockInItemForm.vue index 122547bd..c5b3723a 100644 --- a/src/views/erp/stock/in/components/StockInItemForm.vue +++ b/src/views/erp/stock/in/components/StockInItemForm.vue @@ -142,10 +142,18 @@ - + + + + @@ -512,6 +520,7 @@ const formRules = reactive({ productId: [{ required: true, message: t('ErpStock.Item.validatorProductRequired'), trigger: 'blur' }], taskId: [{ required: true, message: t('ErpStock.Item.validatorTaskRequired'), trigger: 'change' }], pallets: [{ validator: validatePallets, trigger: 'change' }], + packageCount: [{ required: true, message: t('ErpStock.Item.validatorPackageCountRequired'), trigger: 'blur' }], count: [{ required: true, message: t('ErpStock.Item.validatorCountRequired'), trigger: 'blur' }] }) const formRef = ref([]) // 表单 Ref @@ -658,11 +667,11 @@ watch( await loadWarehouseList() if (isProductMaterialStockIn.value) { formData.value.forEach((row) => { - row.inputCount = row.inputCount ?? row.count ?? 1 + normalizePackageCount(row) if (isProductStockIn.value) { row.inputUnitType = row.inputUnitType || '个' } - syncCountByInputCount(row) + syncCountByPackageCount(row) }) await loadRowsWarehouseAreas(formData.value) } @@ -713,13 +722,14 @@ const handleAdd = () => { pallets: [], palletCode: undefined, inputUnitType: isProductStockIn.value ? '个' : undefined, - inputCount: isProductMaterialStockIn.value ? 1 : undefined, + inputCount: undefined, + packageCount: isPurchaseUnitStockIn.value ? 1 : undefined, stockCount: undefined, count: isProductMaterialStockIn.value ? undefined : 1, totalPrice: undefined, remark: undefined } - syncCountByInputCount(row) + syncCountByPackageCount(row) formData.value.push(row) if (row.warehouseId && isProductMaterialStockIn.value) { loadWarehouseAreas(row.warehouseId) @@ -754,7 +764,9 @@ const handleRelatedTaskChange = (row: any) => { clearTask(row) clearPallet(row) row.count = isProductMaterialStockIn.value ? undefined : 1 - row.inputCount = isProductMaterialStockIn.value ? 1 : undefined + row.inputCount = undefined + row.packageCount = isPurchaseUnitStockIn.value ? 1 : undefined + syncCountByPackageCount(row) } /** 处理产品变更 */ @@ -795,7 +807,8 @@ const fillRowByProduct = (row: any, product: any) => { row.supplierName = getDefaultSupplierName(product) row.purchaseUnitConvertQuantity = product.purchaseUnitConvertQuantity fillPackagingSchemeByProduct(row, product) - syncCountByInputCount(row) + normalizePackageCount(row) + syncCountByPackageCount(row) } const fillPackagingSchemeByProduct = (row: any, product: any) => { @@ -838,6 +851,7 @@ const clearProduct = (row: any) => { row.palletPackageQuantity = undefined row.palletTotalQuantity = undefined row.inputCount = isProductMaterialStockIn.value ? undefined : row.inputCount + row.packageCount = isPurchaseUnitStockIn.value ? undefined : row.packageCount row.count = isProductMaterialStockIn.value ? undefined : row.count } @@ -1218,28 +1232,56 @@ const syncCountByPallets = (row: any) => { } watch( - () => formData.value.map((row) => [row.inputCount, row.purchaseUnitConvertQuantity]), + () => formData.value.map((row) => [row.packageCount, row.purchaseUnitConvertQuantity]), () => { - if (!isProductMaterialStockIn.value) return - formData.value.forEach(syncCountByInputCount) + if (!isPurchaseUnitStockIn.value) return + formData.value.forEach(syncCountByPackageCount) }, { deep: true } ) +const normalizePackageCount = (row: any) => { + if (!isPurchaseUnitStockIn.value || isRowRelatedTask(row)) return + if (row.packageCount !== undefined && row.packageCount !== null && row.packageCount !== '') return + if (row.inputCount !== undefined && row.inputCount !== null && row.inputCount !== '') { + row.packageCount = row.inputCount + return + } + const count = Number(row.count) + const convertQuantity = Number(row.purchaseUnitConvertQuantity) + if (Number.isFinite(count) && Number.isFinite(convertQuantity) && convertQuantity > 0) { + row.packageCount = count / convertQuantity + } +} + const syncCountByInputCount = (row: any) => { - if (!isProductMaterialStockIn.value) return + if (!isProductMaterialStockIn.value || isPurchaseUnitStockIn.value) return if (isRowRelatedTask(row)) return const inputCount = Number(row.inputCount) - const convertQuantity = Number(row.purchaseUnitConvertQuantity) if (!Number.isFinite(inputCount)) { row.count = undefined return } + row.count = inputCount +} + +const syncCountByPackageCount = (row: any) => { + if (!isPurchaseUnitStockIn.value) { + syncCountByInputCount(row) + return + } + if (isRowRelatedTask(row)) return + const packageCount = Number(row.packageCount) + const convertQuantity = Number(row.purchaseUnitConvertQuantity) + if (!Number.isFinite(packageCount)) { + row.count = undefined + return + } if (!row.purchaseUnitId && !row.purchaseUnitName) { - row.count = inputCount + row.count = packageCount return } - row.count = Number.isFinite(convertQuantity) ? inputCount * convertQuantity : inputCount + row.count = Number.isFinite(convertQuantity) ? packageCount * convertQuantity : packageCount } const loadWarehouseAreas = async (warehouseId: number) => { @@ -1292,7 +1334,8 @@ const fillProductNames = (rows: any[]) => { row.purchaseUnitName = row.purchaseUnitName ?? (product as any).purchaseUnitName row.supplierName = row.supplierName ?? getDefaultSupplierName(product) row.purchaseUnitConvertQuantity = row.purchaseUnitConvertQuantity ?? (product as any).purchaseUnitConvertQuantity - syncCountByInputCount(row) + normalizePackageCount(row) + syncCountByPackageCount(row) }) }