feat(WEB): 작업일지/검사성적서 버튼 공정 레벨 설정 연동
- Process 타입에 documentTemplateId, needsWorkLog 필드 추가 (ProcessStep에서 이동) - ProcessForm에 중간검사 양식/작업일지 설정 UI 추가 - StepForm에서 해당 UI 제거 - WorkerScreen 하단 버튼 조건부 렌더링: needsWorkLog/documentTemplateId 기반
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* - 완료 정보: 유형(선택 완료 시 완료/클릭 시 완료)
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -37,8 +37,7 @@ import {
|
||||
STEP_CONNECTION_TARGET_OPTIONS,
|
||||
DEFAULT_INSPECTION_SETTING,
|
||||
} from '@/types/process';
|
||||
import { createProcessStep, updateProcessStep, getDocumentTemplates } from './actions';
|
||||
import type { DocumentTemplateOption } from './actions';
|
||||
import { createProcessStep, updateProcessStep } from './actions';
|
||||
import type { DetailConfig } from '@/components/templates/IntegratedDetailTemplate/types';
|
||||
import { InspectionSettingModal } from './InspectionSettingModal';
|
||||
import { InspectionPreviewModal } from './InspectionPreviewModal';
|
||||
@@ -105,12 +104,6 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
initialData?.completionType || '클릭 시 완료'
|
||||
);
|
||||
|
||||
// 문서양식 선택
|
||||
const [documentTemplateId, setDocumentTemplateId] = useState<number | undefined>(
|
||||
initialData?.documentTemplateId
|
||||
);
|
||||
const [documentTemplates, setDocumentTemplates] = useState<DocumentTemplateOption[]>([]);
|
||||
|
||||
// 검사 설정
|
||||
const [inspectionSetting, setInspectionSetting] = useState<InspectionSetting>(
|
||||
initialData?.inspectionSetting || DEFAULT_INSPECTION_SETTING
|
||||
@@ -125,17 +118,6 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
// 검사여부가 "사용"인지 확인
|
||||
const isInspectionEnabled = needsInspection === '사용';
|
||||
|
||||
// 검사여부가 "사용"이면 문서양식 목록 조회
|
||||
useEffect(() => {
|
||||
if (isInspectionEnabled && documentTemplates.length === 0) {
|
||||
getDocumentTemplates().then((result) => {
|
||||
if (result.success && result.data) {
|
||||
setDocumentTemplates(result.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [isInspectionEnabled, documentTemplates.length]);
|
||||
|
||||
// 제출
|
||||
const handleSubmit = async (): Promise<{ success: boolean; error?: string }> => {
|
||||
if (!stepName.trim()) {
|
||||
@@ -149,7 +131,6 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
isRequired: isRequired === '필수',
|
||||
needsApproval: needsApproval === '필요',
|
||||
needsInspection: needsInspection === '사용',
|
||||
documentTemplateId: isInspectionEnabled ? documentTemplateId : undefined,
|
||||
isActive: isActive === '사용',
|
||||
order: initialData?.order || 0,
|
||||
connectionType,
|
||||
@@ -269,33 +250,6 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
{/* 문서양식 선택 (검사여부가 "사용"일 때만 표시) */}
|
||||
{isInspectionEnabled && (
|
||||
<div className="mt-4 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
|
||||
<div className="space-y-2">
|
||||
<Label>문서양식 (검사 템플릿)</Label>
|
||||
<Select
|
||||
key={`doc-template-${documentTemplateId ?? 'none'}`}
|
||||
value={documentTemplateId ? String(documentTemplateId) : ''}
|
||||
onValueChange={(v) => setDocumentTemplateId(v ? Number(v) : undefined)}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="문서양식을 선택하세요" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{documentTemplates.map((tmpl) => (
|
||||
<SelectItem key={tmpl.id} value={String(tmpl.id)}>
|
||||
{tmpl.name} ({tmpl.category})
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
중간검사 시 사용할 문서양식을 선택합니다. MNG에서 등록한 양식이 표시됩니다.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -384,8 +338,6 @@ export function StepForm({ mode, processId, initialData }: StepFormProps) {
|
||||
completionType,
|
||||
initialData?.stepCode,
|
||||
isInspectionEnabled,
|
||||
documentTemplateId,
|
||||
documentTemplates,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user