diff --git a/CLAUDE.md b/CLAUDE.md index 9d07e29..dd7598f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -146,6 +146,13 @@ Variety (品種マスタ) - `display_order` (リスト表示時の順序) - マイグレーション0004で追加 +5. **年度管理の設計方針**(⚠️ Phase 2 で必ず参照): + - **作付け計画**: 年度セレクタで独立して来年度も選べる。選んだ年度はlocalStorageに保存して維持 + - **過去年度**: 「参照モード」として視覚的に区別(背景色・バナー) + - **Phase 2 の栽培管理・販売管理**: グローバル作業年度を導入し、基本は今年度に従う + - **栽培記録・作業日誌**: 日付中心設計、年度は日付から自動算出 + - 参考: ソリマチ農業簿記の年度管理方式(明示的に年度を選択、変更するまで固定) + --- ## 🔑 重要な制約・ルール diff --git a/frontend/src/app/allocation/page.tsx b/frontend/src/app/allocation/page.tsx index d8d0767..1ff2fca 100644 --- a/frontend/src/app/allocation/page.tsx +++ b/frontend/src/app/allocation/page.tsx @@ -23,7 +23,13 @@ export default function AllocationPage() { const [fields, setFields] = useState([]); const [crops, setCrops] = useState([]); const [plans, setPlans] = useState([]); - const [year, setYear] = useState(2025); + const [year, setYear] = useState(() => { + if (typeof window !== 'undefined') { + const saved = localStorage.getItem('allocationYear'); + if (saved) return parseInt(saved); + } + return new Date().getFullYear(); + }); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(null); const [showSidebar, setShowSidebar] = useState(true); @@ -44,9 +50,13 @@ export default function AllocationPage() { const [filterUnassigned, setFilterUnassigned] = useState(false); useEffect(() => { + localStorage.setItem('allocationYear', String(year)); fetchData(); }, [year]); + const currentYear = new Date().getFullYear(); + const isPastYear = year < currentYear; + const fetchData = async (background = false) => { if (!background) setLoading(true); try { @@ -540,7 +550,9 @@ export default function AllocationPage() {
-

作付け計画

+

+ 作付け計画 {year}年度 +

{/* スマホ用集計ボタン */} +
+ )} +

💡 グループ名を入力して「グループ順」で並び替え、「↑」「↓」ボタンで順序を変更できます @@ -699,7 +725,7 @@ export default function AllocationPage() {

)} -
+
diff --git a/frontend/src/app/reports/page.tsx b/frontend/src/app/reports/page.tsx index 925739d..442f230 100644 --- a/frontend/src/app/reports/page.tsx +++ b/frontend/src/app/reports/page.tsx @@ -26,7 +26,7 @@ const previewPdf = async (url: string) => { }; export default function ReportsPage() { - const [year, setYear] = useState(2025); + const [year, setYear] = useState(new Date().getFullYear()); const [busy, setBusy] = useState(null); const handleAction = async (action: 'download' | 'preview', type: 'kyosai' | 'chusankan') => { @@ -67,9 +67,9 @@ export default function ReportsPage() { onChange={(e) => setYear(parseInt(e.target.value))} className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500 w-full max-w-xs" > - - - + {Array.from({ length: 5 }, (_, i) => new Date().getFullYear() - 2 + i).map((y) => ( + + ))}