feat(WEB): 작업일지/검사성적서 버튼 공정 레벨 설정 연동
- Process 타입에 documentTemplateId, needsWorkLog 필드 추가 (ProcessStep에서 이동) - ProcessForm에 중간검사 양식/작업일지 설정 UI 추가 - StepForm에서 해당 UI 제거 - WorkerScreen 하단 버튼 조건부 렌더링: needsWorkLog/documentTemplateId 기반
This commit is contained in:
@@ -37,7 +37,9 @@ import {
|
||||
updateProcess,
|
||||
getDepartmentOptions,
|
||||
getProcessSteps,
|
||||
getDocumentTemplates,
|
||||
type DepartmentOption,
|
||||
type DocumentTemplateOption,
|
||||
} from './actions';
|
||||
|
||||
interface ProcessFormProps {
|
||||
@@ -67,6 +69,18 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
// 중간검사/작업일지 설정 (Process 레벨)
|
||||
const [documentTemplateId, setDocumentTemplateId] = useState<number | undefined>(
|
||||
initialData?.documentTemplateId
|
||||
);
|
||||
const [needsWorkLog, setNeedsWorkLog] = useState(
|
||||
initialData?.needsWorkLog ?? false
|
||||
);
|
||||
const [workLogTemplateId, setWorkLogTemplateId] = useState<number | undefined>(
|
||||
initialData?.workLogTemplateId
|
||||
);
|
||||
const [documentTemplates, setDocumentTemplates] = useState<DocumentTemplateOption[]>([]);
|
||||
|
||||
// 품목 분류 규칙 (기존 로직 유지)
|
||||
const [classificationRules, setClassificationRules] = useState<ClassificationRule[]>(
|
||||
initialData?.classificationRules || []
|
||||
@@ -124,15 +138,21 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
);
|
||||
}, []);
|
||||
|
||||
// 부서 목록 + 단계 목록 로드
|
||||
// 부서 목록 + 문서양식 목록 로드
|
||||
useEffect(() => {
|
||||
const loadDepartments = async () => {
|
||||
const loadInitialData = async () => {
|
||||
setIsDepartmentsLoading(true);
|
||||
const departments = await getDepartmentOptions();
|
||||
const [departments, templates] = await Promise.all([
|
||||
getDepartmentOptions(),
|
||||
getDocumentTemplates(),
|
||||
]);
|
||||
setDepartmentOptions(departments);
|
||||
if (templates.success && templates.data) {
|
||||
setDocumentTemplates(templates.data);
|
||||
}
|
||||
setIsDepartmentsLoading(false);
|
||||
};
|
||||
loadDepartments();
|
||||
loadInitialData();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -300,6 +320,9 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
processType,
|
||||
processCategory: processCategory || undefined,
|
||||
department,
|
||||
documentTemplateId: documentTemplateId || undefined,
|
||||
needsWorkLog,
|
||||
workLogTemplateId: needsWorkLog ? workLogTemplateId : undefined,
|
||||
classificationRules: classificationRules.map((rule) => ({
|
||||
registrationType: rule.registrationType,
|
||||
ruleType: rule.ruleType,
|
||||
@@ -463,6 +486,64 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
{/* Row 3: 중간검사양식 | 작업일지여부 | 작업일지양식 */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mt-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>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>작업일지 여부</Label>
|
||||
<Select
|
||||
value={needsWorkLog ? '사용' : '미사용'}
|
||||
onValueChange={(v) => setNeedsWorkLog(v === '사용')}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="사용">사용</SelectItem>
|
||||
<SelectItem value="미사용">미사용</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
{needsWorkLog && (
|
||||
<div className="space-y-2">
|
||||
<Label>작업일지 양식</Label>
|
||||
<Select
|
||||
key={`worklog-template-${workLogTemplateId ?? 'none'}`}
|
||||
value={workLogTemplateId ? String(workLogTemplateId) : ''}
|
||||
onValueChange={(v) => setWorkLogTemplateId(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>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -679,6 +760,10 @@ export function ProcessForm({ mode, initialData }: ProcessFormProps) {
|
||||
manager,
|
||||
useProductionDate,
|
||||
isActive,
|
||||
documentTemplateId,
|
||||
needsWorkLog,
|
||||
workLogTemplateId,
|
||||
documentTemplates,
|
||||
classificationRules,
|
||||
steps,
|
||||
isStepsLoading,
|
||||
|
||||
Reference in New Issue
Block a user