"use client"; import React from "react"; import { Plus, Trash2, GripVertical } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { ProcessWorkStandardConfig, WorkPhaseDefinition, DetailTypeDefinition } from "./types"; import { defaultConfig } from "./config"; interface ConfigPanelProps { config: Partial; onChange: (config: Partial) => void; } export function ProcessWorkStandardConfigPanel({ config: configProp, onChange, }: ConfigPanelProps) { const config: ProcessWorkStandardConfig = { ...defaultConfig, ...configProp, dataSource: { ...defaultConfig.dataSource, ...configProp?.dataSource }, phases: configProp?.phases?.length ? configProp.phases : defaultConfig.phases, detailTypes: configProp?.detailTypes?.length ? configProp.detailTypes : defaultConfig.detailTypes, }; const update = (partial: Partial) => { onChange({ ...configProp, ...partial }); }; const updateDataSource = (field: string, value: string) => { update({ dataSource: { ...config.dataSource, [field]: value }, }); }; // 작업 단계 관리 const addPhase = () => { const nextOrder = config.phases.length + 1; update({ phases: [ ...config.phases, { key: `PHASE_${nextOrder}`, label: `단계 ${nextOrder}`, sortOrder: nextOrder }, ], }); }; const removePhase = (idx: number) => { update({ phases: config.phases.filter((_, i) => i !== idx) }); }; const updatePhase = (idx: number, field: keyof WorkPhaseDefinition, value: string | number) => { const next = [...config.phases]; next[idx] = { ...next[idx], [field]: value }; update({ phases: next }); }; // 상세 유형 관리 const addDetailType = () => { update({ detailTypes: [ ...config.detailTypes, { value: `TYPE_${config.detailTypes.length + 1}`, label: "신규 유형" }, ], }); }; const removeDetailType = (idx: number) => { update({ detailTypes: config.detailTypes.filter((_, i) => i !== idx) }); }; const updateDetailType = (idx: number, field: keyof DetailTypeDefinition, value: string) => { const next = [...config.detailTypes]; next[idx] = { ...next[idx], [field]: value }; update({ detailTypes: next }); }; return (

공정 작업기준 설정

{/* 데이터 소스 설정 */}

데이터 소스 설정

updateDataSource("itemTable", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("itemNameColumn", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("itemCodeColumn", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("routingVersionTable", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("routingFkColumn", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("processTable", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("processNameColumn", e.target.value)} className="mt-1 h-8 text-xs" />
updateDataSource("processCodeColumn", e.target.value)} className="mt-1 h-8 text-xs" />
{/* 작업 단계 설정 */}

작업 단계 설정

{config.phases.map((phase, idx) => (
updatePhase(idx, "key", e.target.value)} className="h-7 w-20 text-[10px]" placeholder="키" /> updatePhase(idx, "label", e.target.value)} className="h-7 flex-1 text-[10px]" placeholder="표시명" />
))}
{/* 상세 유형 옵션 */}

상세 유형 옵션

{config.detailTypes.map((dt, idx) => (
updateDetailType(idx, "value", e.target.value)} className="h-7 w-24 text-[10px]" placeholder="값" /> updateDetailType(idx, "label", e.target.value)} className="h-7 flex-1 text-[10px]" placeholder="표시명" />
))}
{/* UI 설정 */}

UI 설정

update({ splitRatio: Number(e.target.value) })} min={15} max={50} className="mt-1 h-8 w-20 text-xs" />
update({ leftPanelTitle: e.target.value })} className="mt-1 h-8 text-xs" />
update({ readonly: v })} />
); }