"use client"; // 개발관리 > PART 상세 다이얼로그 — wace partMng/partMngDetailPopUp.jsp 1:1 // // 운영판은 form 과 동일 화면을 disabled 로 표시 후 "수정" 클릭 시 활성화. // RPS 에서는 PartFormDialog 와 분리 유지 (호환). 본 다이얼로그는 Form 레이아웃 readonly + // 부속 정보 행 추가 (EO_NO / EO_DATE / EO구분(CHANGE_TYPE) / EO사유(CHANGE_OPTION)) + // CAD Data 영역 (3D / 2D(Drawing) / 2D(PDF)) — AttachFileDropZone readonly (목록·다운로드). // // "수정" 버튼: 부모가 본 다이얼로그를 닫고 PartFormDialog(mode='edit') 오픈하도록 onEdit 콜백 호출. import React, { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Loader2, Pencil } from "lucide-react"; import { toast } from "sonner"; import { devPartApi, PartRow } from "@/lib/api/devPart"; import { cn } from "@/lib/utils"; import { AttachFileDropZone } from "@/components/common/AttachFileDropZone"; const LABEL_ODRFG: Record = { "0": "구매", "1": "생산", "8": "Phantom" }; const LABEL_LOT_FG: Record = { "0": "미사용", "1": "사용" }; const LABEL_USE_YN: Record = { "0": "미사용", "1": "사용" }; const LABEL_QC_FG: Record = { "0": "무검사", "1": "검사" }; const LABEL_YESNO: Record = { "0": "부", "1": "여" }; interface Props { open: boolean; onOpenChange: (open: boolean) => void; objid: string | null; /** "수정" 버튼 클릭 시 호출 — 부모는 본 다이얼로그 닫고 PartFormDialog(mode='edit') 오픈 */ onEdit?: (objid: string) => void; } export function PartDetailDialog({ open, onOpenChange, objid, onEdit }: Props) { const [row, setRow] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { if (!open || !objid) return; let alive = true; setLoading(true); devPartApi.detail(objid) .then((data) => { if (alive) setRow(data); }) .catch((e: any) => { toast.error(e?.response?.data?.message ?? e?.message ?? "조회 실패"); onOpenChange(false); }) .finally(() => { if (alive) setLoading(false); }); return () => { alive = false; }; }, [open, objid, onOpenChange]); if (!open) return null; return ( 품목 상세 {loading || !row ? (
) : (
{/* 운영판 colgroup 1:1 (12% / 12% / 25% / 12% / *) */} {/* 부속 — wace detail 만 표시 */} {/* CAD Data — readonly (목록·다운로드만) */}
품번{row.part_no} 품명{row.part_name}
재료{row.material} 열처리경도{row.heat_treatment_hardness}
열처리방법{row.heat_treatment_method} 표면처리{row.surface_treatment}
메이커{row.maker} 범주 이름{row.part_type_title}
규격{row.spec}
계정구분{row.acctfg_nm} 조달구분{LABEL_ODRFG[row.odrfg ?? ""] ?? row.odrfg_nm ?? ""}
재고단위{row.unit_dc_nm} 관리단위{row.unitmang_dc_nm}
환산수량 {row.unitchng_nb != null && row.unitchng_nb !== "" ? String(row.unitchng_nb) : ""} LOT구분{LABEL_LOT_FG[row.lot_fg ?? ""] ?? row.lot_fg_nm ?? ""}
사용여부{LABEL_USE_YN[row.use_yn ?? ""] ?? row.use_yn_nm ?? ""} 검사여부{LABEL_QC_FG[row.qc_fg ?? ""] ?? row.qc_fg_nm ?? ""}
SET품여부{LABEL_YESNO[row.setitem_fg ?? ""] ?? row.setitem_fg_nm ?? ""} 의뢰여부{LABEL_YESNO[row.req_fg ?? ""] ?? row.req_fg_nm ?? ""}
개당길이{row.unit_length} 개당소요량{row.unit_qty}
비고{row.remark}
EO No{row.eo_no} EO Date{row.eo_date}
EO구분{row.change_type} EO사유{row.change_option_name ?? row.change_option}
CAD Data 3D
2D(Drawing)
2D(PDF)
)} {row && onEdit && ( )}
); } // ─── 보조 컴포넌트 ────────────────────────────────────────── function Tr({ children }: { children: React.ReactNode }) { return {children}; } function Th({ children }: { children: React.ReactNode }) { return ( {children} ); } function Td({ children, colSpan }: { children: React.ReactNode; colSpan?: number }) { return {children}; } // 운영판 disabled input 의 readonly 박스 function Ro({ children, align }: { children: React.ReactNode; align?: "left" | "center" | "right" }) { const cls = align === "right" ? "text-right" : align === "center" ? "text-center" : "text-left"; const empty = children == null || children === ""; return (
{empty ? : children}
); }