@ -527,12 +527,14 @@ const totalExportCount = computed(() => {
// --- BOM 齐套性分析计算属性(使用后端已计算的 current_stock, O(N),无嵌套循环)---
const maxBuildableSets = computed ( ( ) => {
if ( ! currentBomDetail . value ? . length ) return 0
return currentBomDetail . value . reduce ( ( minSets , bomItem : any ) => {
const result = currentBomDetail . value . reduce ( ( minSets , bomItem : any ) => {
const dosage = parseFloat ( bomItem . dosage ) || 0
if ( dosage <= 0 ) return minSets
const stock = parseFloat ( bomItem . current _stock ) || 0
return Math . min ( minSets , Math . floor ( stock / dosage ) )
} , Infinity )
return result === Infinity ? 0 : result
} )
const shortageList = computed ( ( ) => {
@ -723,8 +725,8 @@ watch(selectedBomNo, async (newBomNo) => {
const confirmBomAdd = async ( ) => {
if ( ! selectedBomNo . value ) return ElMessage . warning ( '请选择 BOM' )
if ( allStockData . value . length === 0 ) {
await ensureAll StockLoaded ( )
if ( stockList . value . length === 0 ) {
await load StockList ( )
}
if ( currentBomDetail . value . length === 0 ) {
@ -745,7 +747,7 @@ const confirmBomAdd = async () => {
const dosage = parseFloat ( bomItem . dosage ) || 0
const needQty = dosage * bomSets . value
const stockCandidate = allStockData . value . find ( s =>
const stockCandidate = stockList . value . find ( s =>
( s . base _id && s . base _id == bomItem . child _id )
)