diff --git a/inventory-web/src/App.vue b/inventory-web/src/App.vue index 4d81969..8ccbe55 100644 --- a/inventory-web/src/App.vue +++ b/inventory-web/src/App.vue @@ -239,7 +239,7 @@ const handleLogout = () => { diff --git a/inventory-web/src/views/outbound/Selection.vue b/inventory-web/src/views/outbound/Selection.vue index ac1ba97..43959fe 100644 --- a/inventory-web/src/views/outbound/Selection.vue +++ b/inventory-web/src/views/outbound/Selection.vue @@ -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 ensureAllStockLoaded() + if (stockList.value.length === 0) { + await loadStockList() } 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) )