|
|
|
|
@ -142,10 +142,18 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column v-if="!isProductStockIn" :label="t('ErpStock.Item.count')" prop="count" min-width="140">
|
|
|
|
|
<el-table-column v-if="isPurchaseUnitStockIn" :label="t('ErpStock.Item.inPackageCount')" prop="packageCount" min-width="140">
|
|
|
|
|
<template #default="{ row, $index }">
|
|
|
|
|
<el-form-item :prop="`${$index}.packageCount`" :rules="formRules.packageCount" class="mb-0px!">
|
|
|
|
|
<el-input v-if="disabled" :model-value="row.packageCount ?? '-'" readonly />
|
|
|
|
|
<el-input-number v-else v-model="row.packageCount" controls-position="right" :min="0.001" :precision="3" class="!w-100%" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column v-if="!isProductStockIn" :label="isPurchaseUnitStockIn ? t('ErpStock.Item.inItemCount') : t('ErpStock.Item.count')" prop="count" min-width="140">
|
|
|
|
|
<template #default="{ row, $index }">
|
|
|
|
|
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
|
|
|
|
|
<el-input v-if="disabled || isProductStockIn" :model-value="row.count ?? '-'" readonly />
|
|
|
|
|
<el-input v-if="disabled || isPurchaseUnitStockIn" :model-value="row.count ?? '-'" readonly />
|
|
|
|
|
<el-input-number v-else v-model="row.count" controls-position="right" :min="0.001" :precision="3" class="!w-100%" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
@ -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)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|