diff --git a/src/components/quality/InspectionManagement/actions.ts b/src/components/quality/InspectionManagement/actions.ts index 8170a3bb..6cd2174b 100644 --- a/src/components/quality/InspectionManagement/actions.ts +++ b/src/components/quality/InspectionManagement/actions.ts @@ -220,6 +220,7 @@ function transformApiToFrontend(api: ProductInspectionApi): ProductInspection { }, orderItems: (api.order_items || []).map((item) => ({ id: item.id, + orderId: item.order_id, orderNumber: item.order_number, siteName: item.site_name || '', deliveryDate: item.delivery_date || '', @@ -230,6 +231,7 @@ function transformApiToFrontend(api: ProductInspectionApi): ProductInspection { constructionWidth: item.construction_width, constructionHeight: item.construction_height, changeReason: item.change_reason, + inspectionData: item.inspection_data || undefined, })), }; } @@ -281,6 +283,8 @@ function transformFormToApi(data: InspectionFormData): Record { phone: data.supervisor?.phone || '', }, }, + // 수주 연결 + order_ids: data.orderItems?.map((item) => item.orderId ?? Number(item.id)) ?? [], }; } @@ -555,6 +559,23 @@ export async function updateInspection( apiData.options = options; } + // 수주 연결 동기화 (orderItems에서 orderId 추출) + if (data.orderItems !== undefined) { + apiData.order_ids = data.orderItems.map((item) => { + // orderId가 있으면 사용, 없으면 id를 숫자로 변환 + return item.orderId ?? Number(item.id); + }); + + // 개소별 데이터 (시공규격, 변경사유, 검사데이터) + apiData.locations = data.orderItems.map((item) => ({ + id: Number(item.id), + post_width: item.constructionWidth || null, + post_height: item.constructionHeight || null, + change_reason: item.changeReason || null, + inspection_data: item.inspectionData || null, + })); + } + const result = await executeServerAction({ url: buildApiUrl(`/api/v1/quality/documents/${id}`), method: 'PUT',