'use client' import type { WorkReviewImageAnnotation, WorkReviewRole } from '@/types/work-review' export type WorkReviewDisplayAnnotation = { annotation: WorkReviewImageAnnotation markerNumber: number reviewerName?: string reviewerRole?: WorkReviewRole draft?: boolean positionEditable?: boolean } function markerTone(item: WorkReviewDisplayAnnotation) { if (item.draft) return 'bg-[#8a5200] text-white ring-[#fff3d6]' if (item.reviewerRole === 'final_reviewer') return 'bg-[#087a3c] text-white ring-[#d9f6e5]' return 'bg-[#0050cb] text-white ring-[#dcecff]' } function markerColor(item: WorkReviewDisplayAnnotation) { if (item.annotation.color) return item.annotation.color if (item.draft) return '#8a5200' if (item.reviewerRole === 'final_reviewer') return '#087a3c' return '#0050cb' } function commentPosition(x: number) { return x > 0.62 ? 'right-9' : 'left-9' } export function WorkReviewAnnotationMarker({ item, onClick, showComment = true, }: { item: WorkReviewDisplayAnnotation onClick?: () => void showComment?: boolean }) { const { annotation } = item const shape = annotation.shape || 'point' const color = markerColor(item) const alignRight = annotation.x > 0.62 const roleLabel = item.draft ? '当前批注' : item.reviewerRole === 'final_reviewer' ? '元泽' : '评审人' const summary = annotation.comment.trim() || '待填写修改意见' const positionState = item.positionEditable ? shape === 'point' ? ',位置可调整' : ',范围可调整' : '' const label = `${roleLabel}标注 ${item.markerNumber}${positionState}${item.reviewerName ? `,${item.reviewerName}` : ''}:${summary}` const visualTitle = showComment ? label : `${roleLabel}标注 ${item.markerNumber}` if (shape !== 'point' && annotation.x2 != null && annotation.y2 != null) { const minX = Math.min(annotation.x, annotation.x2) const minY = Math.min(annotation.y, annotation.y2) const width = Math.max(0.008, Math.abs(annotation.x2 - annotation.x)) const height = Math.max(0.008, Math.abs(annotation.y2 - annotation.y)) const arrowPointsRight = annotation.x2 >= annotation.x const arrowPointsDown = annotation.y2 >= annotation.y const arrowX1 = arrowPointsRight ? 4 : 96 const arrowY1 = arrowPointsDown ? 4 : 96 const arrowX2 = arrowPointsRight ? 96 : 4 const arrowY2 = arrowPointsDown ? 96 : 4 const markerId = `work-review-arrow-${annotation.id.replace(/[^a-zA-Z0-9_-]/g, '')}` const lightColor = color === '#ffffff' return ( ) } return ( ) }