From 2f3f7a486c759361036d5dca0d566eb43f89fc08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Mon, 9 Feb 2026 21:31:07 +0900 Subject: [PATCH] =?UTF-8?q?feat(WEB):=20=EC=9E=91=EC=97=85=EC=9E=90?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=A4=91=EA=B0=84=EA=B2=80=EC=82=AC=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=8C=90=EC=A0=95=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - InspectionInputModal: 공정별(screen/slat/bending) 자동 판정 계산 로직 - JudgmentToggle → JudgmentDisplay로 변경 (수동 → 자동 판정) - computeJudgment: 검사 항목 상태 기반 적합/부적합 자동 산출 - index.tsx: 관련 타입/로직 보강 --- .../WorkerScreen/InspectionInputModal.tsx | 97 ++++++++++++++----- .../production/WorkerScreen/index.tsx | 12 +++ 2 files changed, 83 insertions(+), 26 deletions(-) diff --git a/src/components/production/WorkerScreen/InspectionInputModal.tsx b/src/components/production/WorkerScreen/InspectionInputModal.tsx index 6cb8f873..73d3d02b 100644 --- a/src/components/production/WorkerScreen/InspectionInputModal.tsx +++ b/src/components/production/WorkerScreen/InspectionInputModal.tsx @@ -11,7 +11,7 @@ * - bending_wip: 재고생산(재공품) 중간검사 */ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useMemo } from 'react'; import { Dialog, DialogContent, @@ -149,44 +149,81 @@ function OkNgToggle({ ); } -// 적합/부적합 버튼 컴포넌트 -function JudgmentToggle({ - value, - onChange, -}: { - value: 'pass' | 'fail' | null; - onChange: (v: 'pass' | 'fail') => void; -}) { +// 자동 판정 표시 컴포넌트 +function JudgmentDisplay({ value }: { value: 'pass' | 'fail' | null }) { return (
- -
+
부적합 - +
); } +// 공정별 자동 판정 계산 +function hasMeasurement(v: number | null | undefined): boolean { + return v != null; +} + +function computeJudgment(processType: InspectionProcessType, data: InspectionData): 'pass' | 'fail' | null { + switch (processType) { + case 'screen': { + const { processingStatus, sewingStatus, assemblyStatus, gapStatus, length, width } = data; + // 불량이 하나라도 있으면 즉시 부적합 + if (processingStatus === 'bad' || sewingStatus === 'bad' || assemblyStatus === 'bad' || gapStatus === 'ng') return 'fail'; + // 모든 상태 양호 + 측정값 입력 완료 시 적합 + if (processingStatus === 'good' && sewingStatus === 'good' && assemblyStatus === 'good' && gapStatus === 'ok' + && hasMeasurement(length) && hasMeasurement(width)) return 'pass'; + return null; + } + case 'slat': { + const { processingStatus, assemblyStatus, height1, height2, length } = data; + if (processingStatus === 'bad' || assemblyStatus === 'bad') return 'fail'; + if (processingStatus === 'good' && assemblyStatus === 'good' + && hasMeasurement(height1) && hasMeasurement(height2) && hasMeasurement(length)) return 'pass'; + return null; + } + case 'slat_jointbar': { + const { processingStatus, assemblyStatus, height1, height2, length3, gap4 } = data; + if (processingStatus === 'bad' || assemblyStatus === 'bad') return 'fail'; + if (processingStatus === 'good' && assemblyStatus === 'good' + && hasMeasurement(height1) && hasMeasurement(height2) && hasMeasurement(length3) && hasMeasurement(gap4)) return 'pass'; + return null; + } + case 'bending': { + const { bendingStatus, length } = data; + if (bendingStatus === 'bad') return 'fail'; + if (bendingStatus === 'good' && hasMeasurement(length)) return 'pass'; + return null; + } + case 'bending_wip': { + const { bendingStatus, length, width } = data; + if (bendingStatus === 'bad') return 'fail'; + if (bendingStatus === 'good' && hasMeasurement(length) && hasMeasurement(width)) return 'pass'; + return null; + } + default: + return null; + } +} + export function InspectionInputModal({ open, onOpenChange, @@ -278,6 +315,17 @@ export function InspectionInputModal({ } }, [open, productName, specification, processType, initialData]); + // 자동 판정 계산 + const autoJudgment = useMemo(() => computeJudgment(processType, formData), [processType, formData]); + + // 판정값 자동 동기화 + useEffect(() => { + setFormData((prev) => { + if (prev.judgment === autoJudgment) return prev; + return { ...prev, judgment: autoJudgment }; + }); + }, [autoJudgment]); + const handleComplete = () => { const data: InspectionData = { ...formData, @@ -642,11 +690,8 @@ export function InspectionInputModal({ {/* 하단 고정: 판정 + 버튼 */}
- 판정 - setFormData((prev) => ({ ...prev, judgment: v }))} - /> + 판정 (자동) +