From ff67a6bf26deded595e5e3a9c4924541ec255a6c Mon Sep 17 00:00:00 2001 From: Akira Date: Mon, 2 Mar 2026 11:23:38 +0900 Subject: [PATCH] =?UTF-8?q?=E6=96=BD=E8=82=A5=E8=A8=88=E7=94=BB:=20?= =?UTF-8?q?=E8=A8=88=E7=AE=97=E8=A8=AD=E5=AE=9A=E3=81=AE=E5=BE=A9=E5=85=83?= =?UTF-8?q?=E3=81=A8=E3=83=A9=E3=83=99=E3=83=AB=E8=A1=A8=E7=A4=BA=E3=83=90?= =?UTF-8?q?=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - calcNewOnly フィルターを hasAdjusted/hasCalc チェックから inputValue === '' ベースに変更 (既存プランを開いた際に全フィールドが「計算済み」と判定されて計算が動かないバグを修正) - runCalc で adjusted をクリアしないよう変更 (計算ボタン押下後にラベル=計算結果、テキストボックス=DB/確定値が同時表示されるよう修正) Co-Authored-By: Claude Sonnet 4.6 --- .../_components/FertilizerEditPage.tsx | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/fertilizer/_components/FertilizerEditPage.tsx b/frontend/src/app/fertilizer/_components/FertilizerEditPage.tsx index 0b2d029..0b25f0a 100644 --- a/frontend/src/app/fertilizer/_components/FertilizerEditPage.tsx +++ b/frontend/src/app/fertilizer/_components/FertilizerEditPage.tsx @@ -187,9 +187,10 @@ export default function FertilizerEditPage({ planId }: { planId?: number }) { const targetFields = calcNewOnly ? selectedFields.filter((f) => { - const hasAdjusted = adjusted[f.id]?.[setting.fertilizer_id] !== undefined; - const hasCalc = calcMatrix[f.id]?.[setting.fertilizer_id] !== undefined; - return !hasAdjusted && !hasCalc; + const adjVal = adjusted[f.id]?.[setting.fertilizer_id]; + const calcVal = calcMatrix[f.id]?.[setting.fertilizer_id]; + const inputValue = adjVal !== undefined ? adjVal : (calcVal ?? ''); + return inputValue === ''; }) : selectedFields; @@ -214,19 +215,7 @@ export default function FertilizerEditPage({ planId }: { planId?: number }) { return next; }); - // adjusted と丸め状態をリセット(新しい計算結果を再丸めさせる) - setAdjusted((prev) => { - const next = { ...prev }; - results.forEach(({ field_id }) => { - if (next[field_id]) { - const row = { ...next[field_id] }; - delete row[setting.fertilizer_id]; - next[field_id] = row; - } - }); - return next; - }); - setRoundedColumns((prev) => { const next = new Set(prev); next.delete(setting.fertilizer_id); return next; }); + // adjusted は保持する(テキストボックスにDB/確定値を維持し、ラベルに計算結果を表示) } catch (e: unknown) { const err = e as { response?: { data?: { error?: string } } }; alert(err.response?.data?.error ?? '計算に失敗しました');