feat(WEB): 중간검사 성적서 편집 모드 및 저장 기능 추가
- 3개 검사 콘텐츠 컴포넌트에 forwardRef + useImperativeHandle 추가 (getInspectionData 노출)
- InspectionReportModal에 readOnly prop, 저장 버튼, ref 연결 추가
- saveInspectionData 서버 액션 추가 (POST /api/v1/work-orders/{id}/inspection)
- 작업자 화면에서 readOnly={false} 전달 (편집+저장 가능)
- 작업지시 관리에서는 readOnly 기본값(true)으로 읽기 전용 유지
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,9 +13,13 @@
|
||||
* - 부적합 내용 / 종합판정(자동)
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useMemo } from 'react';
|
||||
import { useState, useCallback, useMemo, forwardRef, useImperativeHandle } from 'react';
|
||||
import type { WorkOrder } from '../types';
|
||||
|
||||
export interface InspectionContentRef {
|
||||
getInspectionData: () => unknown;
|
||||
}
|
||||
|
||||
interface ScreenInspectionContentProps {
|
||||
data: WorkOrder;
|
||||
readOnly?: boolean;
|
||||
@@ -39,7 +43,7 @@ interface InspectionRow {
|
||||
|
||||
const DEFAULT_ROW_COUNT = 6;
|
||||
|
||||
export function ScreenInspectionContent({ data: order, readOnly = false }: ScreenInspectionContentProps) {
|
||||
export const ScreenInspectionContent = forwardRef<InspectionContentRef, ScreenInspectionContentProps>(function ScreenInspectionContent({ data: order, readOnly = false }, ref) {
|
||||
const fullDate = new Date().toLocaleDateString('ko-KR', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
@@ -115,6 +119,22 @@ export function ScreenInspectionContent({ data: order, readOnly = false }: Scree
|
||||
return null;
|
||||
}, [rows, getRowJudgment]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getInspectionData: () => ({
|
||||
rows: rows.map(row => ({
|
||||
id: row.id,
|
||||
processStatus: row.processStatus,
|
||||
sewingStatus: row.sewingStatus,
|
||||
assemblyStatus: row.assemblyStatus,
|
||||
lengthMeasured: row.lengthMeasured,
|
||||
widthMeasured: row.widthMeasured,
|
||||
gapResult: row.gapResult,
|
||||
})),
|
||||
inadequateContent,
|
||||
overallResult,
|
||||
}),
|
||||
}), [rows, inadequateContent, overallResult]);
|
||||
|
||||
// 체크박스 렌더 (양호/불량)
|
||||
const renderCheckStatus = (rowId: number, field: 'processStatus' | 'sewingStatus' | 'assemblyStatus', value: CheckStatus) => (
|
||||
<td className="border border-gray-400 p-1">
|
||||
@@ -380,4 +400,4 @@ export function ScreenInspectionContent({ data: order, readOnly = false }: Scree
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user