'use client'; /** * 공정 상세 - 작업일지 양식 미리보기 모달 * * 기획서 기준 양식: * - 신청업체/신청내용 테이블 * - 순번/작업항목/규격/수량/단위/작업자/비고 테이블 */ import { Printer, X } from 'lucide-react'; import { Dialog, DialogContent, DialogTitle, } from '@/components/ui/dialog'; import { VisuallyHidden } from '@radix-ui/react-visually-hidden'; import { Button } from '@/components/ui/button'; import type { Process } from '@/types/process'; interface ProcessWorkLogPreviewModalProps { open: boolean; onOpenChange: (open: boolean) => void; process: Process; } // 공정명을 문서 코드로 매핑 const getDocumentCode = (processName: string): string => { if (processName.includes('스크린')) return 'WL-SCR'; if (processName.includes('슬랫')) return 'WL-SLT'; if (processName.includes('절곡') || processName.includes('포밍')) return 'WL-BEN'; return 'WL-STK'; }; // 공정명을 부서명으로 매핑 const getDepartmentName = (processName: string): string => { if (processName.includes('스크린')) return '스크린 생산부서'; if (processName.includes('슬랫')) return '슬랫 생산부서'; if (processName.includes('절곡')) return '절곡 생산부서'; if (processName.includes('포밍')) return '포밍 생산부서'; return process?.department || '생산부서'; }; export function ProcessWorkLogPreviewModal({ open, onOpenChange, process }: ProcessWorkLogPreviewModalProps) { const handlePrint = () => { window.print(); }; const documentCode = getDocumentCode(process.processName); const departmentName = getDepartmentName(process.processName); const today = new Date().toLocaleDateString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', }).replace(/\. /g, '-').replace('.', ''); // 샘플 작업항목 데이터 (기획서 기준) const workItems = [ { no: 1, name: '원단 재단', spec: 'W2900 × H3900', qty: 9, unit: 'EA', worker: '이작업', note: '' }, { no: 2, name: '미싱 작업', spec: 'W2800 × H3800', qty: 8, unit: 'EA', worker: '김작업', note: '' }, { no: 3, name: '앤드락 조립', spec: 'W2700 × H3700', qty: 7, unit: 'EA', worker: '이작업', note: '' }, { no: 4, name: '검수', spec: 'W2600 × H3600', qty: 6, unit: 'EA', worker: '김작업', note: '' }, { no: 5, name: '포장', spec: 'W2500 × H3500', qty: 5, unit: 'EA', worker: '이작업', note: '' }, ]; return ( {/* 접근성을 위한 숨겨진 타이틀 */} {process.workLogTemplate} 미리보기 {/* 모달 헤더 */}
{process.workLogTemplate} 미리보기 ({documentCode})
{/* 문서 본문 */}
{/* 문서 헤더: 로고 + 제목 + 결재라인 */}
{/* 좌측: 로고 영역 */}
KD
정동기업
{/* 중앙: 문서 제목 */}

작 업 일 지

{documentCode}

{departmentName}

{/* 우측: 결재라인 */}
작성 검토 승인
홍길동
12/17
판매/전진 생산 품질
{/* 신청업체 / 신청내용 테이블 */}
신 청 업 체 신 청 내 용
발 주 일 {today} 현 장 명 송도 오피스텔 A동
업 체 명 (주)인천건설 작업일자 {today}
담 당 자 김담당 제품 LOT NO. KD-TS-251217-01-01
제품명 SH3040   방화셔터 W3000×H4000 마감유형 스크린   그레이
{/* 작업항목 테이블 */} {workItems.map((item, index) => ( ))}
순번 작업항목 규격 수량 단위 작업자 비고
{item.no} {item.name} {item.spec} {item.qty} {item.unit} {item.worker} {item.note}
); }