File size: 9,230 Bytes
926b211 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | /**
* ProjectCard - Enterprise SaaS Style (Linear/Notion inspired)
*
* Visual Design:
* - Modern typography with Microsoft YaHei optimization
* - Soft shadows and generous spacing
* - Clean section headers with decorative accents
* - Traffic light system for FAI values
*/
import { ProjectData } from '@/types/project';
import {
getRiskBadgeClass,
formatDate,
getDisplayValue,
parseFAIValue,
getFAIColorClass,
getCardVisualState,
formatExcelDate
} from '@/lib/projectUtils';
import { Target, FlaskConical, CheckCircle2 } from 'lucide-react';
interface ProjectCardProps {
project: ProjectData;
}
export default function ProjectCard({ project }: ProjectCardProps) {
const { no, identity, milestones, details } = project;
// Get visual state based on currentNode
const visualState = getCardVisualState(milestones.currentNode);
return (
<div
className={`
${visualState.bgClass} rounded-xl overflow-hidden
transition-all duration-300 ease-out
hover:shadow-xl hover:-translate-y-0.5
${visualState.borderClass}
`}
>
{/* Card Header */}
<div className="px-8 py-5 border-b border-slate-100 bg-gradient-to-r from-slate-50/50 to-white">
<div className="flex items-start justify-between gap-4">
<div className="flex-1 min-w-0">
<h3 className="text-2xl font-bold text-slate-900 tracking-tight leading-tight">
{getDisplayValue(identity.projectName, 'N/A')}
</h3>
<p className="text-sm text-slate-500 mt-1.5 font-medium">
{getDisplayValue(identity.productName, 'N/A')} <span className="text-slate-300 mx-2">•</span> NO. {getDisplayValue(no, 'N/A')}
</p>
</div>
{/* Status Badge - Only show if valid currentNode */}
{visualState.showBadge && (
<span className={`px-4 py-1.5 rounded-lg text-sm font-semibold border-2 whitespace-nowrap ${visualState.badgeClass}`}>
{visualState.badgeLabel}
</span>
)}
</div>
</div>
{/* Section 1: 项目基本信息 */}
<div className="px-8 py-6 bg-slate-50/50">
<div className="flex items-center gap-2 mb-4">
<div className="w-1 h-5 bg-blue-500 rounded-full" />
<h4 className="text-lg font-bold text-slate-800">
项目基本信息
</h4>
</div>
<div className="grid grid-cols-4 gap-x-6 gap-y-4">
<InfoField label="客户名称" value={identity.customerName} />
<InfoField label="客户基地" value={identity.customerBase} />
<InfoField label="落地工厂" value={identity.factory} />
<InfoField label="模具套数" value={identity.moldSets} />
<InfoField label="料号" value={identity.partNumber} />
<InfoField label="穴号" value={identity.cavityNumber} />
<InfoField label="模具编号" value={identity.moldNumber} />
<InfoField label="项目经理" value={identity.projectManager} />
<InfoField label="项目工程师" value={identity.projectEngineer} />
<InfoField label="模具项目" value={identity.moldProject} />
<InfoField label="项目QE" value={identity.qe} />
<InfoField label="风险等级" value={identity.riskLevel} highlight />
</div>
</div>
{/* Section 2: 内部节点 */}
<div className="px-8 py-6 bg-white">
<div className="flex items-center gap-2 mb-5">
<div className="w-1 h-5 bg-indigo-500 rounded-full" />
<h4 className="text-lg font-bold text-slate-800">
内部节点
</h4>
</div>
{/* Timeline Visual - CSS Grid for Perfect Alignment */}
<div className="mb-6">
<div className="relative w-full">
{/* The Grey Line - Perfectly centered start-to-end */}
<div className="absolute top-4 sm:top-5 left-[10%] right-[10%] h-0.5 bg-slate-200 -z-10" />
{/* The Nodes - Grid System (5 equal columns) */}
<div className="grid grid-cols-5 w-full">
<TimelineNode label="KICK OFF" date={formatDate(milestones.projectStart)} />
<TimelineNode label="T1" date={formatDate(milestones.t1)} />
<TimelineNode label="G/L" date={formatDate(milestones.glTime)} />
<TimelineNode label="VMP" date={formatDate(milestones.vmp)} />
<TimelineNode label="MP" date={formatDate(milestones.mp)} />
</div>
</div>
</div>
{/* Status Indicators Grid */}
<div className="grid grid-cols-3 gap-4">
<StatusField
icon={<Target className="w-4 h-4" />}
label="当前阶段"
value={milestones.currentStage}
/>
<StatusField
icon={<FlaskConical className="w-4 h-4" />}
label="试模次数"
value={milestones.trialCount}
/>
<StatusField
icon={<CheckCircle2 className="w-4 h-4" />}
label="T1尺寸达标"
value={milestones.t1SizeQualified}
/>
{/* FAI Fields with Traffic Light Logic */}
<FAIField
label="Tooling FAI"
value={milestones.toolingFAI}
/>
<FAIField
label="Part FAI"
value={milestones.partFAI}
/>
{/* Status is now shown in header badge */}
</div>
</div>
{/* Section 3: 项目推进细节 - Executive View */}
<div className="px-8 py-6 bg-slate-50 border-t-2 border-slate-100">
<div className="flex justify-between items-center mb-4">
<div className="flex items-center gap-2">
<div className="w-1 h-5 bg-slate-700 rounded-full" />
<h4 className="text-lg font-bold text-slate-700">
项目推进细节
</h4>
</div>
{/* Date Display with formatExcelDate */}
<span className="text-sm font-medium text-slate-500">
更新时间: {formatExcelDate(details.detailDate)}
</span>
</div>
{/* The Content Block - Executive View Typography (Premium Bold) */}
<p
className="whitespace-pre-wrap text-lg font-bold leading-loose text-slate-800"
style={{
fontFamily: "'Microsoft YaHei', 'PingFang SC', sans-serif",
letterSpacing: "0.02em" // Adds design feel to Chinese text
}}
>
{getDisplayValue(details.detailProgress, '无详细内容')}
</p>
</div>
</div>
);
}
// Helper component for info fields in Section 1
function InfoField({
label,
value,
highlight = false
}: {
label: string;
value: string;
highlight?: boolean;
}) {
return (
<div className="space-y-1">
<div className="text-xs font-medium text-slate-500 uppercase tracking-wider">{label}</div>
<div className={`text-sm font-semibold leading-snug ${highlight ? 'text-blue-600' : 'text-slate-900'}`}>
{getDisplayValue(value, '-')}
</div>
</div>
);
}
// Helper component for timeline nodes in Section 2
function TimelineNode({ label, date }: { label: string; date: string }) {
return (
<div className="relative flex flex-col items-center">
<div className="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white border-2 border-indigo-500 shadow-sm flex items-center justify-center mb-1.5 sm:mb-2">
<div className="w-3 h-3 sm:w-4 sm:h-4 rounded-full bg-indigo-500" />
</div>
<div className="text-[10px] sm:text-xs font-bold text-slate-600 uppercase tracking-wider mb-0.5 whitespace-nowrap text-center">{label}</div>
<div className="text-[9px] sm:text-[10px] text-slate-500 font-medium whitespace-nowrap text-center scale-90">{date}</div>
</div>
);
}
// Helper component for status fields in Section 2
function StatusField({
icon,
label,
value
}: {
icon?: React.ReactNode;
label: string;
value: string;
}) {
return (
<div className="flex items-start gap-3 p-3 rounded-lg bg-slate-50/50">
{icon && <span className="text-slate-400 mt-0.5">{icon}</span>}
<div className="flex-1 min-w-0">
<div className="text-xs font-medium text-slate-500 uppercase tracking-wider mb-1">{label}</div>
<div className="text-sm font-semibold text-slate-900 truncate">
{getDisplayValue(value, '-')}
</div>
</div>
</div>
);
}
// Helper component for FAI fields with traffic light logic
function FAIField({
label,
value
}: {
label: string;
value: string;
}) {
const displayValue = parseFAIValue(value);
const colorClass = getFAIColorClass(value);
return (
<div className="flex items-start gap-3 p-3 rounded-lg bg-slate-50/50">
<div className="flex-1 min-w-0">
<div className="text-xs font-medium text-slate-500 uppercase tracking-wider mb-1">{label}</div>
<div className={`text-sm font-semibold truncate ${colorClass}`}>
{displayValue}
</div>
</div>
</div>
);
}
|