'use client'; import { X } from 'lucide-react'; import type { Requirement, DictItem, SourceTarget } from '@/lib/requirement'; import { REQ_STATUS_LABEL, REQ_STATUS_COLOR, EFFORT_SHORT, EFFORT_COLOR, SOURCE_TYPE_LABEL } from '@/lib/requirement'; interface RequirementDetailProps { requirement: Requirement; projects: { id: string; name: string }[]; types: DictItem[]; platforms: DictItem[]; sourceTargets: SourceTarget[]; resolveVersionName: (id?: string) => string; onClose: () => void; onEdit: () => void; onAdopt?: () => void; onReject?: () => void; onCloseReq?: () => void; onDelete?: () => void; } const PRIORITY_COLORS: Record = { P0: 'bg-red-500/10 text-red-600', P1: 'bg-orange-500/10 text-orange-600', P2: 'bg-blue-500/10 text-blue-600', P3: 'bg-zinc-100 text-zinc-600', P4: 'bg-zinc-100 text-zinc-500', }; export function RequirementDetail({ requirement: req, projects, types, platforms, sourceTargets, resolveVersionName, onClose, onEdit, onAdopt, onReject, onCloseReq, onDelete, }: RequirementDetailProps) { const canEdit = ['pending_review', 'adopted', 'planned'].includes(req.status); const projectName = projects.find((p) => p.id === req.projectId)?.name ?? '-'; const typeName = types.find((t) => t.id === req.typeId)?.name ?? '-'; const platformNames = req.platforms.map((pid) => platforms.find((p) => p.id === pid)?.name ?? pid).join('、') || '-'; return (
e.stopPropagation()}> {/* Header */}
{req.code} {REQ_STATUS_LABEL[req.status]}
{/* Actions */}
{canEdit && ( )} {onAdopt && req.status === 'pending_review' && ( )} {onReject && req.status === 'pending_review' && ( )} {onCloseReq && (req.status === 'adopted' || req.status === 'planned') && ( )} {onDelete && ['pending_review', 'adopted', 'rejected', 'closed'].includes(req.status) && ( )}
{/* Content */}
{/* 需求概述 */}

{req.title}

{/* 需求描述 */} {req.description && (

{req.description}

)} {/* 基本信息 */}
{req.priority} {req.effort && ( {EFFORT_SHORT[req.effort]} )}
{/* 人员 & 日期 */}
{/* 关联父需求 */} {req.parentId && (
)}
); } function Label({ children }: { children: React.ReactNode }) { return
{children}
; } function FieldRow({ label, value, children }: { label: string; value?: string; children?: React.ReactNode }) { return (
{label} {children ?? {value}}
); }