施肥計画: 計算設定の復元とラベル表示バグを修正
- calcNewOnly フィルターを hasAdjusted/hasCalc チェックから inputValue === '' ベースに変更 (既存プランを開いた際に全フィールドが「計算済み」と判定されて計算が動かないバグを修正) - runCalc で adjusted をクリアしないよう変更 (計算ボタン押下後にラベル=計算結果、テキストボックス=DB/確定値が同時表示されるよう修正) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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 ?? '計算に失敗しました');
|
||||
|
||||
Reference in New Issue
Block a user