From f03bf699e599988cba18da2e89154f762c731d84 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Tue, 14 Apr 2026 10:42:26 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E6=96=B9=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=97=B6=E6=8C=81=E4=B9=85=E5=8C=96volume=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E5=A5=97=E8=A3=85=E5=AF=B9=E6=AF=94=E9=A1=B5=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E5=AE=B9=E9=87=8F=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit saveRecipe payload 漏传 selectedVolume 导致编辑器选择的容量从未写入数据库; 套装方案对比页改用与 RecipeCard 一致的 volumeLabel 计算逻辑。 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/components/RecipeDetailOverlay.vue | 1 + frontend/src/views/KitExport.vue | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) 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')