diff --git a/src/views/erp/stock/out/components/StockOutItemForm.vue b/src/views/erp/stock/out/components/StockOutItemForm.vue index 539175f6..aa6ea8b2 100644 --- a/src/views/erp/stock/out/components/StockOutItemForm.vue +++ b/src/views/erp/stock/out/components/StockOutItemForm.vue @@ -61,7 +61,7 @@ @@ -177,7 +177,7 @@ - @@ -1303,7 +1303,7 @@ const getRepairResultTagType = (value: any) => { } watch( - () => formData.value.map((row) => [row.inputCount, row.purchaseUnitConvertQuantity]), + () => formData.value.map((row) => row.inputCount), () => { if (!isProductMaterialStockOut.value) return formData.value.forEach((row) => { @@ -1316,28 +1316,34 @@ watch( { deep: true } ) +const toIntegerCount = (value: any) => { + const count = Number(value) + return Number.isFinite(count) ? Math.trunc(count) : undefined +} + const syncCountByInputCount = (row: any) => { if (!isProductMaterialStockOut.value) return - const inputCount = Number(row.inputCount) - const convertQuantity = Number(row.purchaseUnitConvertQuantity) - if (!Number.isFinite(inputCount)) { + const inputCount = toIntegerCount(row.inputCount) + if (inputCount === undefined) { row.count = undefined return } - if (isProductStockOut.value || (!row.purchaseUnitId && !row.purchaseUnitName)) { - row.count = inputCount - return - } - row.count = Number.isFinite(convertQuantity) ? inputCount * convertQuantity : inputCount + row.inputCount = inputCount + row.count = inputCount } const handleInputCountBlur = (row: any) => { if (!isProductMaterialStockOut.value) return - const inputCount = Number(row.inputCount) + const inputCount = toIntegerCount(row.inputCount) const stockCount = Number(row.stockCount) - if (!Number.isFinite(inputCount) || !Number.isFinite(stockCount)) return - if (inputCount <= stockCount) return - row.inputCount = stockCount + if (inputCount === undefined || !Number.isFinite(stockCount)) return + row.inputCount = inputCount + if (inputCount <= stockCount) { + syncCountByInputCount(row) + syncPalletPackageCounts(row) + return + } + row.inputCount = Math.trunc(stockCount) syncCountByInputCount(row) syncPalletPackageCounts(row) message.warning(t('ErpStock.Item.stockCountExceededWarning'))