import { X } from 'lucide-react'; import { projectMap, prefixLabels } from '../data/materials'; import type { Material } from '../data/materials'; const lightCategoryColors: Record = { '温控系统': '#0A7AFF', '气路系统': '#7B6CF7', '阀件系统': '#F07830', '结构件': '#28A866', }; const lightAgingColors: Record = { '60-90': '#28A866', '90-120': '#E08C00', '120-150':'#D94040', }; const darkCategoryColors: Record = { '温控系统': '#38b8ff', '气路系统': '#a78bfa', '阀件系统': '#fb923c', '结构件': '#34d399', }; const darkAgingColors: Record = { '60-90': '#34d399', '90-120': '#fbbf24', '120-150':'#f87171', }; interface NodeDetailPanelProps { node: { id: string; label: string; type: string; color: string; material?: Material; count?: number; agingRange?: string; } | null; onClose: () => void; darkMode?: boolean; } function Row({ label, children, darkMode }: { label: string; children: React.ReactNode; darkMode: boolean }) { return (
{label} {children}
); } export default function NodeDetailPanel({ node, onClose, darkMode = false }: NodeDetailPanelProps) { if (!node) return null; const catColors = darkMode ? darkCategoryColors : lightCategoryColors; const agColors = darkMode ? darkAgingColors : lightAgingColors; const mat = node.material; const catColor = mat ? (catColors[mat.category] || '#94a3b8') : node.color; const agColor = mat ? (agColors[mat.aging] || '#94a3b8') : node.color; const typeLabel: Record = { material: '物料节点', project: '项目节点', category: '分类节点', aging: '账龄节点', }; // ── 深色主题变量 ────────────────────────────── const panelBg = darkMode ? 'rgba(0,15,45,0.92)' : '#ffffff'; const panelBorder = darkMode ? '1px solid rgba(0,212,255,0.2)' : '1px solid #e5e5ea'; const panelShadow = darkMode ? '0 0 30px rgba(0,212,255,0.12)' : '0 4px 28px rgba(0,0,0,0.09)'; const headerBorder = darkMode ? 'rgba(0,212,255,0.1)' : '#f2f2f7'; const titleColor = darkMode ? '#e8f4ff' : '#1c1c1e'; const subtitleColor= darkMode ? '#4a7fa8' : '#8e8e93'; const closeBtnBg = darkMode ? 'rgba(0,212,255,0.1)' : '#f2f2f7'; const closeBtnColor= darkMode ? '#00d4ff' : '#6d6d72'; const specBg = darkMode ? 'rgba(0,30,70,0.6)' : '#f9f9fb'; const specBorder = darkMode ? 'rgba(0,212,255,0.12)' : '#e8e8ed'; const specText = darkMode ? '#7aadcc' : '#3a3a3c'; const sectionLabel = darkMode ? '#3a6080' : '#aeaeb2'; const projBg = darkMode ? 'rgba(100,80,200,0.12)' : '#f5f0ff'; const projBorder = darkMode ? 'rgba(167,139,250,0.25)' : 'rgba(123,108,247,0.18)'; const projTitle = darkMode ? '#a78bfa' : '#7B6CF7'; const projDesc = darkMode ? '#4a7fa8' : '#6d6d72'; const projId = darkMode ? '#3a6080' : '#aeaeb2'; const groupBg = darkMode ? 'rgba(0,30,70,0.5)' : '#f9f9fb'; return (
{/* Header */}
{/* 深色模式顶部扫光线 */} {darkMode && (
)}

{typeLabel[node.type] || node.type}

{node.label}

{/* Body */}
{mat ? (
{/* 技术规格 */}

技术规格

{mat.spec}

{/* 字段列表 */}
{mat.id} {mat.qty} 件 {mat.category} {prefixLabels[mat.prefix] || mat.prefix} {/* 账龄行 */}
账龄 {mat.aging} 天
{/* 关联项目卡片 */}

关联项目

{projectMap[mat.projectId]?.name || mat.projectId}

{projectMap[mat.projectId]?.desc || ''}

{mat.projectId}

) : (
{/* 分组节点:物料数量 */} {node.count !== undefined && (

关联物料数

{node.count}

)} {node.type === 'category' && (

该分类下包含所有归属于{' '} {node.label} {' '} 的采购物料,点击物料节点查看详细规格。

)} {node.type === 'aging' && node.agingRange && (

账龄区间

{node.agingRange} 天

该账龄段物料需关注资金占用,建议优先推进采购收货。

)}
)}
); }