feat: [WEB] 중간검사 프론트엔드 저장 연동 (Phase 2)
- WorkerScreen/actions.ts에 saveItemInspection, getWorkOrderInspectionData 서버 액션 추가
- handleInspectionComplete에서 POST /items/{itemId}/inspection API 호출 연동
- 작업지시 선택 시 GET /inspection-data로 기존 검사 데이터 자동 로드
- InspectionInputModal에 initialData prop 추가 (재클릭 시 저장된 값 표시)
- WorkItemData에 apiItemId, workOrderId 필드 추가 (실제 DB ID 보존)
- 기존 saveInspectionData deprecated 처리
This commit is contained in:
@@ -61,6 +61,7 @@ interface InspectionInputModalProps {
|
||||
processType: InspectionProcessType;
|
||||
productName?: string;
|
||||
specification?: string;
|
||||
initialData?: InspectionData;
|
||||
onComplete: (data: InspectionData) => void;
|
||||
}
|
||||
|
||||
@@ -192,6 +193,7 @@ export function InspectionInputModal({
|
||||
processType,
|
||||
productName = '',
|
||||
specification = '',
|
||||
initialData,
|
||||
onComplete,
|
||||
}: InspectionInputModalProps) {
|
||||
const [formData, setFormData] = useState<InspectionData>({
|
||||
@@ -208,6 +210,21 @@ export function InspectionInputModal({
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
// initialData가 있으면 기존 저장 데이터로 복원
|
||||
if (initialData) {
|
||||
setFormData({
|
||||
...initialData,
|
||||
productName: initialData.productName || productName,
|
||||
specification: initialData.specification || specification,
|
||||
});
|
||||
if (initialData.gapPoints) {
|
||||
setGapPoints(initialData.gapPoints);
|
||||
} else {
|
||||
setGapPoints(Array(5).fill(null).map(() => ({ left: null, right: null })));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 공정별 기본값 설정 - 모두 양호/OK/적합 상태로 초기화
|
||||
const baseData: InspectionData = {
|
||||
productName,
|
||||
@@ -259,7 +276,7 @@ export function InspectionInputModal({
|
||||
|
||||
setGapPoints(Array(5).fill(null).map(() => ({ left: null, right: null })));
|
||||
}
|
||||
}, [open, productName, specification, processType]);
|
||||
}, [open, productName, specification, processType, initialData]);
|
||||
|
||||
const handleComplete = () => {
|
||||
const data: InspectionData = {
|
||||
|
||||
Reference in New Issue
Block a user