import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { CheckCircle2, XCircle, Clock } from 'lucide-react'; import { renderFormData, renderStepProgress, getApprovalTypeLabel, getApprovalTypeColor, getInstanceType, } from './helpers'; import type { JsonData } from '@/types/common'; interface ApprovalDetailDialogProps { open: boolean; onOpenChange: (open: boolean) => void; instance?: JsonData; templates: JsonData[]; onApprove: (instance: JsonData) => void; onReject: (instance: JsonData) => void; } // 审批详情弹窗 — 展示流程详情/表单/进度/操作记录 // Logan.Li export function ApprovalDetailDialog({ open, onOpenChange, instance, templates, onApprove, onReject, }: ApprovalDetailDialogProps) { if (!instance) return null; return ( 审批详情 查看审批流程详细信息

{instance.title}

{getApprovalTypeLabel(getInstanceType(instance))} 申请人:{instance.applicant_name || instance.applicant || '--'} 提交于 {instance.created_at ? new Date(instance.created_at).toLocaleString() : '--'}
{/* 审批内容 */} {instance.content && (

{instance.content}

)} {/* 申请表单 */} {(() => { const tpl = templates.find((t) => t.id === instance.template_id); const rendered = renderFormData(instance.form_data, tpl); if (!rendered) return null; return (

申请表单

{rendered}
); })()} {/* 审批进度 */}

审批进度

{renderStepProgress(instance)}
{/* 操作记录 */} {instance.actions && (

操作记录

{instance.actions.map((action: JsonData, index: number) => (
{action.action === 'approve' ? ( ) : action.action === 'reject' ? ( ) : ( )}
{action.operator_name || action.operator} · {action.action === 'approve' ? '通过' : action.action === 'reject' ? '拒绝' : '提交'} {action.comment && (

{action.comment}

)}
{action.created_at ? new Date(action.created_at).toLocaleString() : ''}
))}
)}
{instance.status === 'pending' && ( <> )}
); }