diff --git a/frontend/src/components/RecipeDetailOverlay.vue b/frontend/src/components/RecipeDetailOverlay.vue index b20c769..2532a54 100644 --- a/frontend/src/components/RecipeDetailOverlay.vue +++ b/frontend/src/components/RecipeDetailOverlay.vue @@ -1010,6 +1010,7 @@ async function saveRecipe() { note: editNote.value.trim(), tags: editTags.value, ingredients: allIngs, + volume: selectedVolume.value || '', } await recipesStore.saveRecipe(payload) // Reload recipes so the data is fresh when re-opened diff --git a/frontend/src/views/KitExport.vue b/frontend/src/views/KitExport.vue index 9aebec9..f29a7ad 100644 --- a/frontend/src/views/KitExport.vue +++ b/frontend/src/views/KitExport.vue @@ -48,7 +48,7 @@ - {{ r.name }} {{ r.volume || '单次' }} + {{ r.name }} {{ volumeLabel(r) }} {{ calcMaxTimes(r) }} {{ fmtPrice(r.kitCost) }} {{ fmtPrice(r.originalCost) }} @@ -85,7 +85,7 @@ - {{ row.name }} {{ row.volume || '单次' }} + {{ row.name }} {{ volumeLabel(row) }} @@ -120,6 +120,33 @@ const sellingPrices = ref({}) const activeKitData = computed(() => kitAnalysis.value.find(k => k.id === activeKit.value)) +function volumeLabel(recipe) { + const vol = recipe.volume + if (vol) { + if (vol === 'single') return '单次' + if (vol === 'custom') return '' + if (/^\d+$/.test(vol)) return `${vol}ml` + return vol + } + const ings = recipe.ingredients || [] + const coco = ings.find(i => i.oil === '椰子油') + if (coco && coco.drops) { + const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0) + const ml = totalDrops / 18.6 + if (ml <= 2) return '单次' + return `${Math.round(ml)}ml` + } + let totalMl = 0 + let hasProduct = false + for (const ing of ings) { + if (!oils.isPortionUnit(ing.oil)) continue + hasProduct = true + totalMl += ing.drops || 0 + } + if (hasProduct && totalMl > 0) return `${Math.round(totalMl)}ml` + return '' +} + onMounted(async () => { if (!auth.isBusiness && !auth.isAdmin) { router.replace('/projects')