|
|
|
|
@ -61,7 +61,7 @@
|
|
|
|
|
<el-table-column v-if="!isProductStockOut" :label="t('ErpStock.Item.stock')" min-width="100">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-form-item class="mb-0px!">
|
|
|
|
|
<el-input disabled v-model="row.stockCount" :formatter="erpCountInputFormatter" />
|
|
|
|
|
<el-input disabled v-model="row.stockCount" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
@ -177,7 +177,7 @@
|
|
|
|
|
<el-form-item :prop="`${$index}.inputCount`" :rules="formRules.inputCount" class="mb-0px!">
|
|
|
|
|
<el-input v-if="disabled || isProductStockOut" :model-value="row.pieceCount ?? row.inputCount ?? '-'"
|
|
|
|
|
readonly />
|
|
|
|
|
<el-input-number v-else v-model="row.inputCount" controls-position="right" :min="0.001" :precision="3"
|
|
|
|
|
<el-input-number v-else v-model="row.inputCount" controls-position="right" :min="0" :precision="0"
|
|
|
|
|
class="!w-100%" @blur="handleInputCountBlur(row)" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
@ -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'))
|
|
|
|
|
|