@ -173,7 +173,7 @@
< / template >
< / e l - i n p u t >
< el -input -number v -else v -model = " row.inputCount " controls -position = " right " :min ="0" :precision ="0"
class = "quantity-input !w-100%" @ blur= "handleInputCountBlur(row)" >
class = "quantity-input !w-100%" @ change= "handleInputCountBlur(row)" @ blur= "handleInputCountBlur(row)" >
< template v -if = " isPurchaseUnitStockOut " # suffix >
< span > { { getInventoryQuantityUnitName ( row ) } } < / span >
< / template >
@ -314,7 +314,8 @@
< el -table v -else ref = "palletTableRef" v -loading = " palletDialogLoading " :data ="palletDialogList" row -key = " id "
: stripe = "true" : show - overflow - tooltip = "true" @ row - click = "handlePalletDialogRowClick"
@ selection - change = "handlePalletDialogSelectionChange" >
< el -table -column type = "selection" width = "55" align = "center" :reserve-selection ="true" / >
< el -table -column type = "selection" width = "55" align = "center" :reserve-selection ="true"
: selectable = "isPalletSelectable" / >
< el -table -column :label ="t('ErpStock.Pallet.code')" prop = "code" min -width = " 150 " / >
< el -table -column :label ="t('ErpStock.Pallet.palletType')" prop = "palletType" min -width = " 100 " >
< template # default = "{ row }" >
@ -338,6 +339,7 @@
< / e l - t a b l e - c o l u m n >
< el -table -column :label ="t('ErpStock.Pallet.productName')" prop = "productName" min -width = " 100 " / >
< el -table -column :label ="t('ErpStock.Item.packageCount')" prop = "productCount" min -width = " 100 " / >
< el -table -column :label ="t('ErpStock.Item.outLockedPackageCount')" prop = "lockedPackageCount" min -width = " 130 " / >
< el -table -column v -if = " currentSelectRow ? .outMode = = = 2 " :label ="t('ErpStock.Item.outPackageCount')"
min - width = "130" >
< template # default = "{ row }" >
@ -1068,6 +1070,7 @@ const handlePalletDialogQuery = () => {
}
const handlePalletDialogRowClick = ( row : PalletVO ) => {
if ( ! isPalletSelectable ( row ) ) return
palletTableRef . value ? . toggleRowSelection ( row )
}
@ -1130,7 +1133,7 @@ const syncPalletDialogSelection = () => {
const selectedIds = new Set ( ( row . pallets || [ ] ) . map ( ( item : any ) => item . palletId ) )
palletTableRef . value . clearSelection ( )
palletDialogList . value . forEach ( ( pallet : any ) => {
if ( selectedIds . has ( pallet . id ) ) {
if ( selectedIds . has ( pallet . id ) && isPalletSelectable ( pallet ) ) {
palletTableRef . value . toggleRowSelection ( pallet , true )
}
} )
@ -1138,7 +1141,18 @@ const syncPalletDialogSelection = () => {
const getPalletAvailablePackageCount = ( pallet : PalletVO ) => {
const packageCount = Number ( pallet ? . productCount )
return Number . isFinite ( packageCount ) ? packageCount : 0
const lockedPackageCount = getPalletLockedPackageCount ( pallet )
return Number . isFinite ( packageCount ) ? Math . max ( packageCount - lockedPackageCount , 0 ) : 0
}
const getPalletLockedPackageCount = ( pallet : PalletVO ) => {
const lockedPackageCount = Number ( pallet ? . lockedPackageCount )
return Number . isFinite ( lockedPackageCount ) ? Math . max ( lockedPackageCount , 0 ) : 0
}
const isPalletSelectable = ( pallet : PalletVO ) => {
if ( Number ( currentSelectRow . value ? . outMode ) !== 1 ) return true
return getPalletLockedPackageCount ( pallet ) === 0
}
const handlePalletPackageCountChange = ( value : number | undefined , pallet : any ) => {
@ -1146,7 +1160,7 @@ const handlePalletPackageCountChange = (value: number | undefined, pallet: any)
const packageCount = Number ( value )
if ( ! Number . isFinite ( packageCount ) || packageCount <= availablePackageCount ) return
pallet . packageCount = availablePackageCount
message . warning( ` 出库包数不能大于包数,已自动调整为 ${ availablePackageCount } ` )
message . alertWarning( t ( 'ErpStock.Item.outPackageCountExceededWarning' , { count : availablePackageCount } ) )
}
const getPalletOutCount = ( pallet : any ) => {
@ -1366,18 +1380,25 @@ const syncCountByInputCount = (row: any) => {
row . count = inputCount
}
const getAvailableStockCount = ( row : any ) => {
const stockCount = Number ( row . stockCount )
if ( ! Number . isFinite ( stockCount ) ) return undefined
const lockedStockCount = Number ( row . lockedStockCount )
return Math . max ( stockCount - ( Number . isFinite ( lockedStockCount ) ? lockedStockCount : 0 ) , 0 )
}
const handleInputCountBlur = ( row : any ) => {
if ( ! isProductMaterialStockOut . value ) return
const inputCount = toIntegerCount ( row . inputCount )
const stockCount = Number ( row . stockCount )
if ( inputCount === undefined || ! Number . isFinite ( stockCount ) ) return
const availableStockCount = getAvailableStockCount ( row )
if ( inputCount === undefined || availableStockCount === undefined ) return
row . inputCount = inputCount
if ( inputCount <= stockCount ) {
if ( inputCount <= availableS tockCount) {
syncCountByInputCount ( row )
syncPalletPackageCounts ( row )
return
}
row . inputCount = Math . trunc ( s tockCount)
row . inputCount = Math . trunc ( availableS tockCount)
syncCountByInputCount ( row )
syncPalletPackageCounts ( row )
message . warning ( t ( 'ErpStock.Item.stockCountExceededWarning' ) )
@ -1454,6 +1475,7 @@ const setStockCount = async (row) => {
/** 表单校验 */
const validate = ( ) => {
formData . value . forEach ( ( row ) => {
handleInputCountBlur ( row )
syncPalletPackageCounts ( row )
syncInputCountByPallets ( row )
syncCountByInputCount ( row )