import React, { useEffect, useRef, useState } from 'react'; import { ChevronDown, Filter, Loader2, Search } from 'lucide-react'; import { motion } from 'motion/react'; import type { SubjectOption } from '../api'; export type AssetsTab = 'overview' | 'department' | 'region' | 'customer'; export type AssetsTheme = 'soft' | 'minimal' | 'vibrant'; interface AssetsHeaderProps { activeTab: AssetsTab; setActiveTab: React.Dispatch>; theme: AssetsTheme; setTheme: React.Dispatch>; lastUpdate: string; loading: boolean; selectedSubject: string | null; setSelectedSubject: React.Dispatch>; subjects: SubjectOption[]; subjectDropdownOpen: boolean; setSubjectDropdownOpen: React.Dispatch>; subjectSearch: string; setSubjectSearch: React.Dispatch>; subjectDropdownRef: React.RefObject; } // --- Constants --- const TABS = [ { id: 'overview', label: '总览' }, { id: 'department', label: '按部门' }, { id: 'region', label: '按区域' }, { id: 'customer', label: '按客户' }, ]; function MarqueeBanner() { const trackRef = useRef(null); const innerRef = useRef(null); const [overflow, setOverflow] = useState(false); useEffect(() => { const check = () => { if (!trackRef.current || !innerRef.current) return; setOverflow(innerRef.current.scrollWidth > trackRef.current.clientWidth); }; check(); const ro = new ResizeObserver(check); ro.observe(trackRef.current!); return () => ro.disconnect(); }, []); const text = '车辆资产已于 2026 年 6 月 18 日完成“运营状态”与“业务关联”校验'; return (
{text} {overflow && ( {text} )}
); } export function AssetsHeader({ activeTab, setActiveTab, theme, setTheme, lastUpdate, loading, selectedSubject, setSelectedSubject, subjects, subjectDropdownOpen, setSubjectDropdownOpen, subjectSearch, setSubjectSearch, subjectDropdownRef, }: AssetsHeaderProps) { return ( <> {/* Compact Header Bar */}
{/* Title row */}

羚牛氢能-资产BI

{/* Right: status + theme */}
{lastUpdate}
{loading && (
)}
{(['soft','minimal','vibrant'] as const).map((t) => ( ))}
{/* 归属公司作用域筛选 (Scope Chip) */}
{subjectDropdownOpen && (
setSubjectSearch(e.target.value)} placeholder="搜索公司名" className="w-full h-7 pl-6 pr-2 text-[11px] bg-gray-50 border border-gray-100 rounded focus:outline-none focus:border-blue-300 focus:bg-white" />
{subjects .filter((s) => !subjectSearch || s.name.toLowerCase().includes(subjectSearch.toLowerCase())) .map((s) => { const active = selectedSubject === s.name; return ( ); })} {subjects.filter((s) => !subjectSearch || s.name.toLowerCase().includes(subjectSearch.toLowerCase())).length === 0 && (
未找到匹配公司
)}
)}
{/* Tab row */}
{TABS.map(tab => ( ))}
{/* Status row */}
最后更新: {lastUpdate}
{/* OneOS 迁移提示滚动条 */} ); }