From bba04f24c276b699aa660aeab07fc4a9e7fb7320 Mon Sep 17 00:00:00 2001 From: Akira Date: Mon, 16 Mar 2026 16:53:32 +0900 Subject: [PATCH] =?UTF-8?q?=E9=81=8B=E6=90=AC=E8=A8=88=E7=94=BB:=20?= =?UTF-8?q?=E3=82=B0=E3=83=AB=E3=83=BC=E3=83=97=E4=B8=80=E6=8B=AC=E5=89=B2?= =?UTF-8?q?=E3=82=8A=E5=BD=93=E3=81=A6=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 各回の追加ドロップダウンに「+ グループを追加...」を追加。 グループ内の全圃場の未割り当て分を一括で回に追加できるようにした。 Co-Authored-By: Claude Opus 4.6 --- .../_components/DeliveryEditPage.tsx | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/distribution/_components/DeliveryEditPage.tsx b/frontend/src/app/distribution/_components/DeliveryEditPage.tsx index a4637bb..5740a59 100644 --- a/frontend/src/app/distribution/_components/DeliveryEditPage.tsx +++ b/frontend/src/app/distribution/_components/DeliveryEditPage.tsx @@ -433,6 +433,32 @@ export default function DeliveryEditPage({ planId }: Props) { ]); }; + // グループの全圃場をtripに一括割り当て + const assignGroupToTrip = (groupTempId: string, tripTempId: string) => { + const group = groups.find(g => g.tempId === groupTempId); + if (!group) return; + setTrips(prev => prev.map(t => { + if (t.tempId !== tripTempId) return t; + const newItems = [...t.items]; + for (const fieldId of group.fieldIds) { + for (const fert of selectedFertilizers) { + const remaining = getUnassignedBags(fieldId, fert.id); + if (remaining > 0) { + const existing = newItems.find( + item => item.fieldId === fieldId && item.fertilizerId === fert.id + ); + if (existing) { + existing.bags += remaining; + } else { + newItems.push({ fieldId, fertilizerId: fert.id, bags: remaining }); + } + } + } + } + return { ...t, items: newItems }; + })); + }; + // tripの中の圃場IDを取得(表示用・重複なし) const getTripFieldIds = useCallback((trip: LocalTrip): number[] => { const seen = new Set(); @@ -989,9 +1015,31 @@ export default function DeliveryEditPage({ planId }: Props) { )} - {/* このtripに圃場を追加 */} + {/* このtripに追加 */} {hasUnassignedBags && ( -
+
+ {/* グループ一括追加 */} + + {/* 圃場単体追加 */}