'use client'; /** * 작업일지 문서 콘텐츠 * * DocumentViewer와 함께 사용하는 문서 본문 컴포넌트 * 인쇄 영역만 포함 (모달 헤더/툴바는 DocumentViewer가 처리) * * 공통 컴포넌트 사용: * - DocumentHeader: 로고 + 제목 + 결재라인 * - InfoTable: 라벨-값 정보 테이블 * - SectionHeader: 섹션 제목 (작업내역, 특이사항) */ import type { WorkOrder, WorkOrderItem } from '../WorkOrders/types'; import { ITEM_STATUS_LABELS } from '../WorkOrders/types'; import { DocumentHeader, InfoTable, SectionHeader, } from '@/components/document-system'; interface WorkLogContentProps { data: WorkOrder; } // 작업 통계 타입 interface WorkStats { orderQty: number; completedQty: number; inProgressQty: number; waitingQty: number; progress: number; } // 품목 데이터에서 작업 통계 계산 function calculateWorkStats(items: WorkOrderItem[]): WorkStats { const orderQty = items.length; const completedQty = items.filter(i => i.status === 'completed').length; const inProgressQty = items.filter(i => i.status === 'in_progress').length; const waitingQty = items.filter(i => i.status === 'waiting').length; const progress = orderQty > 0 ? Math.round((completedQty / orderQty) * 100) : 0; return { orderQty, completedQty, inProgressQty, waitingQty, progress, }; } export function WorkLogContent({ data: order }: WorkLogContentProps) { const today = new Date().toLocaleDateString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', }).replace(/\. /g, '-').replace('.', ''); const documentNo = `WL-${order.processCode.toUpperCase().slice(0, 3)}`; // 품목 데이터 const items = order.items || []; // 작업 통계 계산 const workStats = calculateWorkStats(items); // 주 담당자 const primaryAssignee = order.assignees?.find(a => a.isPrimary)?.name || order.assignee || '-'; // 포맷된 납기일 const formattedDueDate = order.dueDate !== '-' ? new Date(order.dueDate).toLocaleDateString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', }).replace(/\. /g, '-').replace('.', '') : '-'; // 작성자 날짜 포맷 const writerDate = new Date().toLocaleDateString('ko-KR', { month: '2-digit', day: '2-digit', }).replace('. ', '/').replace('.', ''); return (
{/* 문서 헤더: 로고 + 제목 + 결재라인 (공통 컴포넌트) */} {/* 기본 정보 테이블 (공통 컴포넌트) */} {/* 품목 테이블 */}
{/* 테이블 헤더 */}
No
품목명
층/부호
규격
수량
상태
{/* 테이블 데이터 */} {items.length > 0 ? ( items.map((item, index) => (
{item.no}
{item.productName}
{item.floorCode}
{item.specification}
{item.quantity}
{ITEM_STATUS_LABELS[item.status]}
)) ) : (
등록된 품목이 없습니다.
)}
{/* 작업내역 */}
{/* 섹션 헤더 (공통 컴포넌트) */} {order.processName} 작업내역 {/* 수량 및 진행률 */}
지시수량
{workStats.orderQty} EA
완료수량
{workStats.completedQty} EA
진행률
{workStats.progress}%
{/* 상세 상태 */}
대기
{workStats.waitingQty} EA
작업중
{workStats.inProgressQty} EA
완료
{workStats.completedQty} EA
{/* 특이사항 (공통 컴포넌트) */}
특이사항
{order.note || '-'}
); }