From 1dcc20552e10b5f9cd22e222debf9addae64d660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 20 Mar 2026 16:59:24 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[quality]=20=EA=B2=80=EC=82=AC=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=EA=B1=B4=20=EC=88=98=EC=A0=95=20=EC=B0=A8=EB=8B=A8?= =?UTF-8?q?=20+=20=EC=99=84=EB=A3=8C=20=EB=B2=84=ED=8A=BC=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EA=B0=95=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 완료 상태 검사 건은 편집 모드 강제 해제 - 미검사/진행중 건이 있으면 검사완료 버튼 비활성화 - 완료 건에 수정 버튼 disabled 표시 --- .../InspectionManagement/InspectionDetail.tsx | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/components/quality/InspectionManagement/InspectionDetail.tsx b/src/components/quality/InspectionManagement/InspectionDetail.tsx index 39ffc3a1..17aed631 100644 --- a/src/components/quality/InspectionManagement/InspectionDetail.tsx +++ b/src/components/quality/InspectionManagement/InspectionDetail.tsx @@ -21,6 +21,7 @@ import { Plus, Trash2, ClipboardCheck, + Pencil, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; @@ -121,12 +122,15 @@ const EMPTY_FORM: InspectionFormData = { export function InspectionDetail({ id }: InspectionDetailProps) { const router = useRouter(); const searchParams = useSearchParams(); - const isEditMode = searchParams.get('mode') === 'edit'; + const isEditModeParam = searchParams.get('mode') === 'edit'; // 상세 데이터 const [inspection, setInspection] = useState(null); const [isLoading, setIsLoading] = useState(true); + // 완료 상태면 편집 모드 강제 해제 + const isEditMode = isEditModeParam && inspection?.status !== '완료'; + // 수정 폼 데이터 const [formData, setFormData] = useState(EMPTY_FORM); @@ -809,7 +813,8 @@ export function InspectionDetail({ id }: InspectionDetailProps) { ); } - // View 모드: 검사제품요청서 보기, 제품검사하기, 검사 완료 버튼 표시 + // View 모드: 검사제품요청서 보기, 제품검사하기, 수정(완료시 disabled), 검사 완료 + const isCompleted = inspection.status === '완료'; return ( <> - {inspection.status !== '완료' && ( - )} + {!isCompleted && (() => { + const hasIncomplete = !inspectionStats || inspectionStats.none > 0 || inspectionStats.inProgress > 0; + return ( + + ); + })()} ); - }, [isEditMode, inspection]); + }, [isEditMode, inspection, inspectionStats]); // ===== View 모드 렌더링 ===== const renderViewContent = useCallback(() => { @@ -1295,11 +1311,12 @@ export function InspectionDetail({ id }: InspectionDetailProps) { const mode = isEditMode ? 'edit' : 'view'; const dynamicConfig = useMemo(() => { - if (isEditMode) { - return { ...inspectionConfig, title: '제품검사' }; + const base = isEditMode ? { ...inspectionConfig, title: '제품검사' } : inspectionConfig; + if (inspection?.status === '완료') { + return { ...base, permissions: { ...base.permissions, canEdit: false } }; } - return inspectionConfig; - }, [isEditMode]); + return base; + }, [isEditMode, inspection?.status]); // 데이터 없음 if (!isLoading && !inspection) { @@ -1322,7 +1339,7 @@ export function InspectionDetail({ id }: InspectionDetailProps) { itemId={id} isLoading={isLoading} onSubmit={handleSubmit} - onEdit={handleEdit} + onEdit={inspection?.status !== '완료' ? handleEdit : undefined} headerActions={headerActions} renderView={() => renderViewContent()} renderForm={() => renderFormContent()}