feat: [process] 공정 단계에 검사범위(InspectionScope) 설정 추가
- 전수검사/샘플링/그룹 유형 선택 UI - 샘플링 시 샘플 크기(n) 입력 - options JSON으로 API 저장/복원
This commit is contained in:
@@ -576,6 +576,15 @@ export async function getDocumentTemplates(): Promise<{
|
||||
// 공정 단계 (Process Step) API
|
||||
// ============================================================================
|
||||
|
||||
interface ApiProcessStepOptions {
|
||||
inspection_setting?: Record<string, unknown>;
|
||||
inspection_scope?: {
|
||||
type: string;
|
||||
sample_size?: number;
|
||||
sample_base?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface ApiProcessStep {
|
||||
id: number;
|
||||
process_id: number;
|
||||
@@ -589,11 +598,13 @@ interface ApiProcessStep {
|
||||
connection_type: string | null;
|
||||
connection_target: string | null;
|
||||
completion_type: string | null;
|
||||
options: ApiProcessStepOptions | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
function transformStepApiToFrontend(apiStep: ApiProcessStep): ProcessStep {
|
||||
const opts = apiStep.options;
|
||||
return {
|
||||
id: String(apiStep.id),
|
||||
stepCode: apiStep.step_code,
|
||||
@@ -606,6 +617,12 @@ function transformStepApiToFrontend(apiStep: ApiProcessStep): ProcessStep {
|
||||
connectionType: (apiStep.connection_type as ProcessStep['connectionType']) || '없음',
|
||||
connectionTarget: apiStep.connection_target ?? undefined,
|
||||
completionType: (apiStep.completion_type as ProcessStep['completionType']) || 'click_complete',
|
||||
inspectionSetting: opts?.inspection_setting as ProcessStep['inspectionSetting'],
|
||||
inspectionScope: opts?.inspection_scope ? {
|
||||
type: opts.inspection_scope.type as 'all' | 'sampling' | 'group',
|
||||
sampleSize: opts.inspection_scope.sample_size,
|
||||
sampleBase: opts.inspection_scope.sample_base as 'order' | 'lot' | undefined,
|
||||
} : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -660,6 +677,14 @@ export async function createProcessStep(
|
||||
connection_type: data.connectionType || null,
|
||||
connection_target: data.connectionTarget || null,
|
||||
completion_type: data.completionType || null,
|
||||
options: (data.inspectionSetting || data.inspectionScope) ? {
|
||||
inspection_setting: data.inspectionSetting || null,
|
||||
inspection_scope: data.inspectionScope ? {
|
||||
type: data.inspectionScope.type,
|
||||
sample_size: data.inspectionScope.sampleSize,
|
||||
sample_base: data.inspectionScope.sampleBase,
|
||||
} : null,
|
||||
} : null,
|
||||
},
|
||||
transform: (d: ApiProcessStep) => transformStepApiToFrontend(d),
|
||||
errorMessage: '공정 단계 등록에 실패했습니다.',
|
||||
@@ -684,6 +709,16 @@ export async function updateProcessStep(
|
||||
if (data.connectionType !== undefined) apiData.connection_type = data.connectionType || null;
|
||||
if (data.connectionTarget !== undefined) apiData.connection_target = data.connectionTarget || null;
|
||||
if (data.completionType !== undefined) apiData.completion_type = data.completionType || null;
|
||||
if (data.inspectionSetting !== undefined || data.inspectionScope !== undefined) {
|
||||
apiData.options = {
|
||||
inspection_setting: data.inspectionSetting || null,
|
||||
inspection_scope: data.inspectionScope ? {
|
||||
type: data.inspectionScope.type,
|
||||
sample_size: data.inspectionScope.sampleSize,
|
||||
sample_base: data.inspectionScope.sampleBase,
|
||||
} : null,
|
||||
};
|
||||
}
|
||||
|
||||
const result = await executeServerAction({
|
||||
url: buildApiUrl(`/api/v1/processes/${processId}/steps/${stepId}`),
|
||||
|
||||
Reference in New Issue
Block a user