diff --git a/src/modules/energy/ElectricDaily.tsx b/src/modules/energy/ElectricDaily.tsx index 58f96e2..8cafa95 100644 --- a/src/modules/energy/ElectricDaily.tsx +++ b/src/modules/energy/ElectricDaily.tsx @@ -6,12 +6,15 @@ import { fetchElectricMonthly } from './api'; import type { CustomerType, DateQuickPick, ElectricMonthGroup } from './types'; import RotatingFooterHint from '../../components/RotatingFooterHint'; -interface Props { - pick: DateQuickPick; -} +const QUICK_PICK_OPTIONS: Array<{ id: DateQuickPick; label: string }> = [ + { id: 'thisWeek', label: '本周' }, + { id: 'thisMonth', label: '本月' }, + { id: 'last15', label: '近 15 天' }, +]; -export default function ElectricDaily({ pick }: Props) { +export default function ElectricDaily() { const [customer, setCustomer] = useState('lingniu'); + const [pick, setPick] = useState('last15'); const [months, setMonths] = useState(null); const [openMonths, setOpenMonths] = useState>(new Set()); const [error, setError] = useState(null); @@ -41,6 +44,23 @@ export default function ElectricDaily({ pick }: Props) { return (
+ {/* 日期速选 */} +
+ {QUICK_PICK_OPTIONS.map(opt => ( + + ))} +
+ {/* 客户类型 */}
{(['lingniu', 'external'] as const).map(c => ( diff --git a/src/modules/energy/ElectricView.tsx b/src/modules/energy/ElectricView.tsx index 500d680..0d4fd6a 100644 --- a/src/modules/energy/ElectricView.tsx +++ b/src/modules/energy/ElectricView.tsx @@ -1,14 +1,12 @@ import ElectricOverview from './ElectricOverview'; import ElectricDaily from './ElectricDaily'; -import type { DateQuickPick } from './types'; export type ElectricSubTab = 'daily' | 'overview'; interface Props { sub: ElectricSubTab; - pick: DateQuickPick; } -export default function ElectricView({ sub, pick }: Props) { - return sub === 'overview' ? : ; +export default function ElectricView({ sub }: Props) { + return sub === 'overview' ? : ; } diff --git a/src/modules/energy/EnergyModule.tsx b/src/modules/energy/EnergyModule.tsx index 0057b50..0f3d23a 100644 --- a/src/modules/energy/EnergyModule.tsx +++ b/src/modules/energy/EnergyModule.tsx @@ -4,13 +4,6 @@ import { motion } from 'motion/react'; import HydrogenView, { type HydrogenSubTab } from './HydrogenView'; import ElectricView, { type ElectricSubTab } from './ElectricView'; import ETCView from './ETCView'; -import type { DateQuickPick } from './types'; - -const QUICK_PICK_OPTIONS: Array<{ id: DateQuickPick; label: string }> = [ - { id: 'thisWeek', label: '本周' }, - { id: 'thisMonth', label: '本月' }, - { id: 'last15', label: '近 15 天' }, -]; type TopTab = 'hydrogen' | 'electric' | 'etc'; type SubTabId = HydrogenSubTab | ElectricSubTab; // 'daily' | 'overview' @@ -30,16 +23,9 @@ export default function EnergyModule() { const [activeTab, setActiveTab] = useState('hydrogen'); const [hydroSub, setHydroSub] = useState('daily'); const [electricSub, setElectricSub] = useState('daily'); - const [hydroPick, setHydroPick] = useState('last15'); - const [electricPick, setElectricPick] = useState('last15'); const showSubTabs = activeTab === 'hydrogen' || activeTab === 'electric'; const currentSub: SubTabId = activeTab === 'electric' ? electricSub : hydroSub; const setSub = (id: SubTabId) => activeTab === 'electric' ? setElectricSub(id) : setHydroSub(id); - // 是否在 daily 模式(需要在 sticky 头部展示日期速选) - const showQuickPick = (activeTab === 'hydrogen' && hydroSub === 'daily') - || (activeTab === 'electric' && electricSub === 'daily'); - const currentPick: DateQuickPick = activeTab === 'electric' ? electricPick : hydroPick; - const setPick = (id: DateQuickPick) => activeTab === 'electric' ? setElectricPick(id) : setHydroPick(id); return (
@@ -88,32 +74,11 @@ export default function EnergyModule() { })}
)} - {/* 日期速选:daily 模式时跟着 sticky,避免滚动后被遮挡 */} - {showQuickPick && ( -
- {QUICK_PICK_OPTIONS.map(opt => { - const active = currentPick === opt.id; - return ( - - ); - })} -
- )}
- {activeTab === 'hydrogen' && } - {activeTab === 'electric' && } + {activeTab === 'hydrogen' && } + {activeTab === 'electric' && } {activeTab === 'etc' && }
diff --git a/src/modules/energy/HydrogenDaily.tsx b/src/modules/energy/HydrogenDaily.tsx index 9b52a1c..5b381ca 100644 --- a/src/modules/energy/HydrogenDaily.tsx +++ b/src/modules/energy/HydrogenDaily.tsx @@ -7,11 +7,14 @@ import { fetchHydrogenDaily } from './api'; import type { CustomerType, DateQuickPick, HydrogenDailyRow } from './types'; import RotatingFooterHint from '../../components/RotatingFooterHint'; -interface Props { - pick: DateQuickPick; -} +const QUICK_PICK_OPTIONS: Array<{ id: DateQuickPick; label: string }> = [ + { id: 'thisWeek', label: '本周' }, + { id: 'thisMonth', label: '本月' }, + { id: 'last15', label: '近 15 天' }, +]; -export default function HydrogenDaily({ pick }: Props) { +export default function HydrogenDaily() { + const [pick, setPick] = useState('last15'); const [customer, setCustomer] = useState('lingniu'); const [expanded, setExpanded] = useState>(new Set()); const [rows, setRows] = useState(null); @@ -38,6 +41,23 @@ export default function HydrogenDaily({ pick }: Props) { return (
+ {/* 日期速选 */} +
+ {QUICK_PICK_OPTIONS.map(opt => ( + + ))} +
+ {/* 客户类型 segmented */}
{(['lingniu', 'external'] as const).map(c => ( diff --git a/src/modules/energy/HydrogenView.tsx b/src/modules/energy/HydrogenView.tsx index fa61afc..c5a24af 100644 --- a/src/modules/energy/HydrogenView.tsx +++ b/src/modules/energy/HydrogenView.tsx @@ -1,14 +1,12 @@ import HydrogenOverview from './HydrogenOverview'; import HydrogenDaily from './HydrogenDaily'; -import type { DateQuickPick } from './types'; export type HydrogenSubTab = 'daily' | 'overview'; interface Props { sub: HydrogenSubTab; - pick: DateQuickPick; } -export default function HydrogenView({ sub, pick }: Props) { - return sub === 'overview' ? : ; +export default function HydrogenView({ sub }: Props) { + return sub === 'overview' ? : ; }