From 5821596e267cbd267f98ff66e827df6c806cb715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sun, 22 Mar 2026 18:12:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[=EC=9E=91=EC=97=85=EC=9E=90=ED=99=94?= =?UTF-8?q?=EB=A9=B4]=20=EA=B2=80=EC=82=AC=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=EC=8B=9C=20=EC=83=9D=EC=82=B0=EC=9D=BC=EC=9E=90=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - updateWorkOrderScheduledDate API 함수 추가 (PUT /work-orders/{id}) - handleInspectionComplete에서 검사 완료 시 오늘 날짜로 생산일자 자동 저장 - UI의 생산일자 필드도 즉시 반영 --- src/components/production/WorkerScreen/actions.ts | 14 ++++++++++++++ src/components/production/WorkerScreen/index.tsx | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/production/WorkerScreen/actions.ts b/src/components/production/WorkerScreen/actions.ts index e2eed0b2..9d3cda47 100644 --- a/src/components/production/WorkerScreen/actions.ts +++ b/src/components/production/WorkerScreen/actions.ts @@ -250,6 +250,20 @@ export async function completeWorkOrder( return { success: true, lotNo }; } +// ===== 작업지시 생산일자 업데이트 ===== +export async function updateWorkOrderScheduledDate( + id: string, + scheduledDate: string +): Promise<{ success: boolean; error?: string }> { + const result = await executeServerAction({ + url: `${API_URL}/api/v1/work-orders/${id}`, + method: 'PUT', + body: { scheduled_date: scheduledDate }, + errorMessage: '생산일자 저장에 실패했습니다.', + }); + return { success: result.success, error: result.error }; +} + // ===== 자재 목록 조회 (로트 기준) ===== export interface MaterialForInput { stockLotId: number | null; // StockLot ID (null이면 재고 없음) diff --git a/src/components/production/WorkerScreen/index.tsx b/src/components/production/WorkerScreen/index.tsx index b1d145f6..5a4a2eaa 100644 --- a/src/components/production/WorkerScreen/index.tsx +++ b/src/components/production/WorkerScreen/index.tsx @@ -49,7 +49,7 @@ import { Button } from '@/components/ui/button'; import { PageLayout } from '@/components/organisms/PageLayout'; import { cn } from '@/lib/utils'; import { toast } from 'sonner'; -import { getMyWorkOrders, completeWorkOrder, saveItemInspection, getWorkOrderInspectionData, saveInspectionDocument, getInspectionTemplate, getStepProgress, toggleStepProgress, deleteMaterialInput, updateMaterialInput, getDepartments, getDepartmentUsers } from './actions'; +import { getMyWorkOrders, completeWorkOrder, saveItemInspection, getWorkOrderInspectionData, saveInspectionDocument, getInspectionTemplate, getStepProgress, toggleStepProgress, deleteMaterialInput, updateMaterialInput, getDepartments, getDepartmentUsers, updateWorkOrderScheduledDate } from './actions'; import type { StepProgressItem, DepartmentOption, DepartmentUser } from './actions'; import type { InspectionTemplateData } from './types'; import { getProcessList } from '@/components/process-management/actions'; @@ -1366,7 +1366,14 @@ export default function WorkerScreen() { // stepProgressId 없으면 로컬만 완료 처리 setStepCompletionMap((prev) => ({ ...prev, [buildStepKey(stepName)]: true })); } - // 4. 작업 목록 리프레시 (상태 변경 반영 → 사이드바 대기/완료 탭 갱신) + // 4. 생산일자 자동 저장 (검사 완료 시점 = 생산일자) + if (selectedOrder) { + const today = new Date().toISOString().slice(0, 10); + await updateWorkOrderScheduledDate(selectedOrder.id, today); + setProductionDate(today); + } + + // 5. 작업 목록 리프레시 (상태 변경 반영 → 사이드바 대기/완료 탭 갱신) const refreshResult = await getMyWorkOrders(); if (refreshResult.success) setWorkOrders(refreshResult.data); } catch {