"use client"; /** * 수주서 문서 컴포넌트 * - 스크린샷 기반 디자인 * - 제목 좌측, 결재란 우측 * - 신청업체/신청내용/납품정보 3열 구조 * - 스크린, 모터, 절곡물 테이블 */ import { getTodayString } from "@/utils/date"; import { OrderItem } from "../actions"; import { ProductInfo } from "./OrderDocumentModal"; import { ConstructionApprovalTable } from "@/components/document-system"; interface SalesOrderDocumentProps { documentNumber?: string; orderNumber: string; // 로트번호 certificationNumber?: string; // 인정번호 orderDate?: string; client: string; siteName?: string; manager?: string; managerContact?: string; deliveryRequestDate?: string; expectedShipDate?: string; deliveryMethod?: string; address?: string; recipientName?: string; recipientContact?: string; shutterCount?: number; fee?: number; items?: OrderItem[]; products?: ProductInfo[]; remarks?: string; } /** * 수량 포맷 함수 */ function formatQuantity(quantity: number, unit?: string): string { const countableUnits = ["EA", "SET", "PCS", "개", "세트", "BOX", "ROLL"]; const upperUnit = (unit || "").toUpperCase(); if (countableUnits.includes(upperUnit)) { return Math.round(quantity).toLocaleString(); } const rounded = Math.round(quantity * 10000) / 10000; return rounded.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 4 }); } export function SalesOrderDocument({ documentNumber = "ABC123", orderNumber, certificationNumber = "-", orderDate = getTodayString(), client, siteName = "-", manager = "-", managerContact = "-", deliveryRequestDate = "-", expectedShipDate = "-", deliveryMethod = "상차", address = "-", recipientName = "-", recipientContact = "-", shutterCount = 0, items = [], products = [], remarks, }: SalesOrderDocumentProps) { // 스크린 제품만 필터링 const screenProducts = products.filter(p => p.productCategory?.includes("스크린") || p.productName?.includes("스크린") || p.productName?.includes("방화") || p.productName?.includes("셔터") ); // 모터 아이템 필터링 const motorItems = items.filter(item => item.itemName?.toLowerCase().includes("모터") || item.type?.includes("모터") || item.itemCode?.startsWith("MT") ); // 브라켓 아이템 필터링 const bracketItems = items.filter(item => item.itemName?.includes("브라켓") || item.type?.includes("브라켓") ); // 가이드레일 아이템 필터링 const guideRailItems = items.filter(item => item.itemName?.includes("가이드") || item.itemName?.includes("레일") || item.type?.includes("가이드") ); // 케이스 아이템 필터링 const caseItems = items.filter(item => item.itemName?.includes("케이스") || item.itemName?.includes("셔터박스") || item.type?.includes("케이스") ); // 하단마감재 아이템 필터링 const bottomFinishItems = items.filter(item => item.itemName?.includes("하단") || item.itemName?.includes("마감") || item.type?.includes("하단마감") ); return (
{/* 헤더: 수주서 제목 (좌측) + 결재란 (우측) */}
{/* 수주서 제목 (좌측) */}

수 주 서

문서번호: {documentNumber} 작성일자: {orderDate}
{/* 결재란 (우측) */}
{/* 상품명 / 제품명 / 로트번호 / 인정번호 */}
상품명 {products[0]?.productCategory || "-"} 제품명 {products[0]?.productName || "-"} 로트번호 {orderNumber} 인정번호 {certificationNumber}
{/* 3열 섹션: 신청업체 | 신청내용 | 납품정보 */}
{/* 신청업체 */}
신청업체
수주일 {orderDate}
업체명 {client}
수주 담당자 {manager}
담당자 연락처 {managerContact}
배송지 주소 {address}
{/* 신청내용 */}
신청내용
현장명 {siteName}
납기요청일 {deliveryRequestDate}
출고일 {expectedShipDate}
셔터출수량 {shutterCount}개소
   
{/* 납품정보 */}
납품정보
현장명 {siteName}
인수담당자 {recipientName}
인수자연락처 {recipientContact}
배송방법 {deliveryMethod}
   

아래와 같이 주문하오니 품질 및 납기일을 준수하여 주시기 바랍니다.

{/* 1. 스크린 테이블 */}

1. 스크린

{screenProducts.length > 0 ? ( screenProducts.map((product, index) => ( )) ) : ( )}
No 품류 부호 오픈사이즈 제작사이즈 가이드레일
유형
샤프트
(인치)
케이스
(인치)
모터 마감
가로 세로 가로 세로 브라켓트 용량Kg
{index + 1} {product.productCategory || "-"} {product.code || "-"} {product.openWidth || "-"} {product.openHeight || "-"} {product.openWidth || "-"} {product.openHeight || "-"} 백면형
(120X70)
5 5 380X180 300 SUS마감
등록된 스크린 제품이 없습니다
{/* 2. 모터 테이블 */}

2. 모터

{(motorItems.length > 0 || bracketItems.length > 0) ? ( <> {/* 모터 행 */} {/* 브라켓트 행 */} {/* 브라켓트 추가 행 (밑침통 영금) */} ) : ( )}
항목 구분 규격 수량 항목 구분 규격 수량
모터(380V 단상) 모터 용량 {motorItems[0]?.spec || "KD-150K"} {motorItems[0] ? formatQuantity(motorItems[0].quantity, motorItems[0].unit) : "6"} 모터(380V 단상) 모터 용량 {motorItems[1]?.spec || "KD-150K"} {motorItems[1] ? formatQuantity(motorItems[1].quantity, motorItems[1].unit) : "6"}
브라켓트 브라켓트 {bracketItems[0]?.spec || "380X180 [2-4\"]"} {bracketItems[0] ? formatQuantity(bracketItems[0].quantity, bracketItems[0].unit) : "6"} 브라켓트 브라켓트 {bracketItems[1]?.spec || "380X180 [2-4\"]"} {bracketItems[1] ? formatQuantity(bracketItems[1].quantity, bracketItems[1].unit) : "6"}
브라켓트 밑침통 영금 {bracketItems[2]?.spec || "∠40-40 L380"} {bracketItems[2] ? formatQuantity(bracketItems[2].quantity, bracketItems[2].unit) : "44"}
등록된 모터/브라켓 품목이 없습니다
{/* 3. 절곡물 */}

3. 절곡물

{/* 3-1. 가이드레일 */}

3-1. 가이드레일 - EGI 1.5ST + 마감재 EGI 1.1ST + 별도마감재 SUS 1.1ST

{guideRailItems.length > 0 ? ( <> {/* 1행: L: 3,000 / 22 */} {/* 2행: 하부BASE */} {/* 3행: 빈 행 */} {/* 4행: 제품명 */} ) : ( )}
백면형 (120X70) 길이 수량 측면형 (120X120) 길이 수량
IMG
L: 3,000 22
IMG
L: 3,000 22
하부BASE
[130X80]
22
제품명 KSS01 제품명 KSS01
등록된 가이드레일이 없습니다
{/* 연기차단재 정보 */}
연기차단재(W50)
• 가이드레일 마감재
양측에 설치
EGI 0.8T +
화이버글라스코팅직물
IMG
규격 3,000 4,000
수량 44 1
• 별도 추가사항
{/* 3-2. 케이스(셔터박스) */}

3-2. 케이스(셔터박스) - EGI 1.5ST

{caseItems.length > 0 ? ( ) : ( )}
  규격 길이 수량 측면부 수량
IMG
500X330
(150X300,
400K원)
L: 4,000
L: 5,000
상부덮개
(1219X389)
3
4
55
500X355 22
등록된 케이스가 없습니다
{/* 연기차단재 정보 */}
연기차단재(W50)
• 판넬부, 전면부
감싸에 설치
EGI 0.8T +
화이버글라스코팅직물
IMG
규격 3,000
수량 44
{/* 3-3. 하단마감재 */}

3-3. 하단마감재 - 하단마감재(EGI 1.5ST) + 하단보강앨비(EGI 1.5ST) + 하단 보강철(EGI 1.1ST) + 하단 무게형 철(50X12T)

{bottomFinishItems.length > 0 ? ( ) : ( )}
구성품 길이 수량 구성품 길이 수량 구성품 길이 수량
하단마감재
(60X40)
L: 4,000 11 하단보강
(60X17)
L: 4,000 11 하단무게
[50X12T]
L: 4,000 11
등록된 하단마감재가 없습니다
{/* 특이사항 */} {remarks && (

【 특이사항 】

{remarks}
)}
); }