feat: [process] 공정 단계에 검사범위(InspectionScope) 설정 추가
- 전수검사/샘플링/그룹 유형 선택 UI - 샘플링 시 샘플 크기(n) 입력 - options JSON으로 API 저장/복원
This commit is contained in:
@@ -30,12 +30,16 @@ import type {
|
||||
StepConnectionType,
|
||||
StepCompletionType,
|
||||
InspectionSetting,
|
||||
InspectionScope,
|
||||
InspectionScopeType,
|
||||
} from '@/types/process';
|
||||
import {
|
||||
STEP_CONNECTION_TYPE_OPTIONS,
|
||||
STEP_COMPLETION_TYPE_OPTIONS,
|
||||
STEP_CONNECTION_TARGET_OPTIONS,
|
||||
DEFAULT_INSPECTION_SETTING,
|
||||
DEFAULT_INSPECTION_SCOPE,
|
||||
INSPECTION_SCOPE_TYPE_OPTIONS,
|
||||
} from '@/types/process';
|
||||
import { createProcessStep, updateProcessStep } from './actions';
|
||||
import type { DetailConfig } from '@/components/templates/IntegratedDetailTemplate/types';
|
||||
@@ -108,6 +112,9 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
const [inspectionSetting, setInspectionSetting] = useState<InspectionSetting>(
|
||||
initialData?.inspectionSetting || DEFAULT_INSPECTION_SETTING
|
||||
);
|
||||
const [inspectionScope, setInspectionScope] = useState<InspectionScope>(
|
||||
initialData?.inspectionScope || DEFAULT_INSPECTION_SCOPE
|
||||
);
|
||||
|
||||
// 모달 상태
|
||||
const [isInspectionSettingOpen, setIsInspectionSettingOpen] = useState(false);
|
||||
@@ -137,6 +144,7 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
connectionTarget: connectionType === '팝업' ? connectionTarget : undefined,
|
||||
completionType,
|
||||
inspectionSetting: isInspectionEnabled ? inspectionSetting : undefined,
|
||||
inspectionScope: isInspectionEnabled ? inspectionScope : undefined,
|
||||
};
|
||||
|
||||
setIsLoading(true);
|
||||
@@ -237,6 +245,52 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
{isInspectionEnabled && (
|
||||
<>
|
||||
<div className="space-y-2">
|
||||
<Label>검사범위</Label>
|
||||
<Select
|
||||
value={inspectionScope.type}
|
||||
onValueChange={(v) =>
|
||||
setInspectionScope((prev) => ({
|
||||
...prev,
|
||||
type: v as InspectionScopeType,
|
||||
...(v === 'all' ? { sampleSize: undefined, sampleBase: undefined } : {}),
|
||||
...(v === 'sampling' ? { sampleSize: prev.sampleSize || 1, sampleBase: prev.sampleBase || 'order' } : {}),
|
||||
}))
|
||||
}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{INSPECTION_SCOPE_TYPE_OPTIONS.map((opt) => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
{inspectionScope.type === 'sampling' && (
|
||||
<div className="space-y-2">
|
||||
<Label>샘플 크기 (n)</Label>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={inspectionScope.sampleSize ?? 1}
|
||||
onChange={(e) =>
|
||||
setInspectionScope((prev) => ({
|
||||
...prev,
|
||||
sampleSize: Math.max(1, parseInt(e.target.value) || 1),
|
||||
}))
|
||||
}
|
||||
placeholder="검사할 개소 수"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
<Label>상태</Label>
|
||||
<Select value={isActive} onValueChange={setIsActive}>
|
||||
@@ -338,6 +392,7 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
completionType,
|
||||
initialData?.stepCode,
|
||||
isInspectionEnabled,
|
||||
inspectionScope,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user