2025-12-23 09:31:18 +09:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-28 17:36:19 +09:00
|
|
|
* V2Input 설정 패널
|
2026-03-11 21:51:37 +09:00
|
|
|
* 토스식 단계별 UX: 기본 설정 -> 타입별 설정 -> 고급 설정(접힘)
|
2025-12-23 09:31:18 +09:00
|
|
|
*/
|
|
|
|
|
|
2026-01-19 18:21:30 +09:00
|
|
|
import React, { useState, useEffect } from "react";
|
2025-12-23 09:31:18 +09:00
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
2026-03-11 21:51:37 +09:00
|
|
|
import { Switch } from "@/components/ui/switch";
|
|
|
|
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
2026-03-12 10:04:26 +09:00
|
|
|
import { Settings, ChevronDown, Loader2, Type, Hash, Lock, AlignLeft, SlidersHorizontal, Palette, ListOrdered } from "lucide-react";
|
2026-03-11 21:51:37 +09:00
|
|
|
import { cn } from "@/lib/utils";
|
2026-01-19 18:21:30 +09:00
|
|
|
import { AutoGenerationType, AutoGenerationConfig } from "@/types/screen";
|
|
|
|
|
import { AutoGenerationUtils } from "@/lib/utils/autoGeneration";
|
|
|
|
|
import { getAvailableNumberingRules } from "@/lib/api/numberingRule";
|
|
|
|
|
import { NumberingRuleConfig } from "@/types/numbering-rule";
|
2025-12-23 09:31:18 +09:00
|
|
|
|
2026-01-28 17:36:19 +09:00
|
|
|
interface V2InputConfigPanelProps {
|
2025-12-23 09:31:18 +09:00
|
|
|
config: Record<string, any>;
|
|
|
|
|
onChange: (config: Record<string, any>) => void;
|
2026-03-11 16:27:18 +09:00
|
|
|
menuObjid?: number;
|
2025-12-23 09:31:18 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-28 17:36:19 +09:00
|
|
|
export const V2InputConfigPanel: React.FC<V2InputConfigPanelProps> = ({ config, onChange, menuObjid }) => {
|
2026-01-19 18:21:30 +09:00
|
|
|
const [numberingRules, setNumberingRules] = useState<NumberingRuleConfig[]>([]);
|
|
|
|
|
const [loadingRules, setLoadingRules] = useState(false);
|
|
|
|
|
const [parentMenus, setParentMenus] = useState<any[]>([]);
|
|
|
|
|
const [loadingMenus, setLoadingMenus] = useState(false);
|
|
|
|
|
const [selectedMenuObjid, setSelectedMenuObjid] = useState<number | undefined>(() => {
|
|
|
|
|
return config.autoGeneration?.selectedMenuObjid || menuObjid;
|
|
|
|
|
});
|
2026-03-11 21:51:37 +09:00
|
|
|
const [advancedOpen, setAdvancedOpen] = useState(false);
|
2026-01-19 18:21:30 +09:00
|
|
|
|
2025-12-23 09:31:18 +09:00
|
|
|
const updateConfig = (field: string, value: any) => {
|
|
|
|
|
onChange({ ...config, [field]: value });
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-19 18:21:30 +09:00
|
|
|
useEffect(() => {
|
|
|
|
|
const loadMenus = async () => {
|
|
|
|
|
setLoadingMenus(true);
|
|
|
|
|
try {
|
|
|
|
|
const { apiClient } = await import("@/lib/api/client");
|
|
|
|
|
const response = await apiClient.get("/admin/menus");
|
|
|
|
|
if (response.data.success && response.data.data) {
|
|
|
|
|
const allMenus = response.data.data;
|
2026-03-12 15:01:05 +09:00
|
|
|
const userMenus = allMenus.filter((menu: any) => {
|
|
|
|
|
const menuType = menu.menu_type || menu.menuType;
|
|
|
|
|
const level = menu.level || menu.lev || menu.LEVEL;
|
|
|
|
|
return menuType === '1' && (level === 2 || level === 3 || level === '2' || level === '3');
|
|
|
|
|
});
|
|
|
|
|
setParentMenus(userMenus);
|
2026-01-19 18:21:30 +09:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("부모 메뉴 로드 실패:", error);
|
|
|
|
|
} finally {
|
|
|
|
|
setLoadingMenus(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
loadMenus();
|
|
|
|
|
}, []);
|
|
|
|
|
|
2026-03-12 15:01:05 +09:00
|
|
|
const inputType = config.inputType || config.type || "text";
|
|
|
|
|
|
2026-01-19 18:21:30 +09:00
|
|
|
useEffect(() => {
|
|
|
|
|
const loadRules = async () => {
|
2026-03-12 15:01:05 +09:00
|
|
|
const isNumbering = inputType === "numbering" || config.autoGeneration?.type === "numbering_rule";
|
|
|
|
|
if (!isNumbering) return;
|
2026-03-11 16:27:18 +09:00
|
|
|
if (!selectedMenuObjid) { setNumberingRules([]); return; }
|
2026-01-19 18:21:30 +09:00
|
|
|
setLoadingRules(true);
|
|
|
|
|
try {
|
|
|
|
|
const response = await getAvailableNumberingRules(selectedMenuObjid);
|
|
|
|
|
if (response.success && response.data) {
|
|
|
|
|
setNumberingRules(response.data);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("채번 규칙 목록 로드 실패:", error);
|
|
|
|
|
setNumberingRules([]);
|
|
|
|
|
} finally {
|
|
|
|
|
setLoadingRules(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
loadRules();
|
2026-03-12 15:01:05 +09:00
|
|
|
}, [selectedMenuObjid, config.autoGeneration?.type, inputType]);
|
2026-03-11 21:51:37 +09:00
|
|
|
|
2025-12-23 09:31:18 +09:00
|
|
|
return (
|
2026-03-11 21:51:37 +09:00
|
|
|
<div className="space-y-4">
|
2026-03-12 10:04:26 +09:00
|
|
|
{/* ─── 1단계: 입력 타입 선택 (카드 방식) ─── */}
|
2026-03-11 21:51:37 +09:00
|
|
|
<div className="space-y-2">
|
2026-03-12 10:04:26 +09:00
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Type className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
<p className="text-sm font-medium">입력 타입</p>
|
|
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
<p className="text-[11px] text-muted-foreground">입력 필드의 종류를 선택해요</p>
|
2025-12-23 09:31:18 +09:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-12 10:04:26 +09:00
|
|
|
<div className="grid grid-cols-2 gap-2">
|
|
|
|
|
{[
|
|
|
|
|
{ value: "text", icon: Type, label: "텍스트", desc: "일반 텍스트 입력" },
|
|
|
|
|
{ value: "number", icon: Hash, label: "숫자", desc: "숫자만 입력" },
|
|
|
|
|
{ value: "password", icon: Lock, label: "비밀번호", desc: "마스킹 처리" },
|
|
|
|
|
{ value: "textarea", icon: AlignLeft, label: "여러 줄", desc: "긴 텍스트 입력" },
|
|
|
|
|
{ value: "slider", icon: SlidersHorizontal, label: "슬라이더", desc: "범위 선택" },
|
|
|
|
|
{ value: "color", icon: Palette, label: "색상", desc: "색상 선택기" },
|
|
|
|
|
{ value: "numbering", icon: ListOrdered, label: "채번", desc: "자동 번호 생성" },
|
|
|
|
|
].map((item) => (
|
|
|
|
|
<button
|
|
|
|
|
key={item.value}
|
|
|
|
|
type="button"
|
2026-03-12 15:01:05 +09:00
|
|
|
onClick={() => {
|
|
|
|
|
if (item.value === "numbering") {
|
|
|
|
|
const autoMenuObjid = selectedMenuObjid || menuObjid;
|
|
|
|
|
onChange({
|
|
|
|
|
...config,
|
|
|
|
|
inputType: "numbering",
|
|
|
|
|
autoGeneration: {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
type: "numbering_rule" as AutoGenerationType,
|
|
|
|
|
selectedMenuObjid: autoMenuObjid,
|
|
|
|
|
},
|
|
|
|
|
readonly: config.readonly ?? true,
|
|
|
|
|
});
|
|
|
|
|
if (autoMenuObjid) setSelectedMenuObjid(autoMenuObjid);
|
|
|
|
|
} else {
|
|
|
|
|
updateConfig("inputType", item.value);
|
|
|
|
|
}
|
|
|
|
|
}}
|
2026-03-12 10:04:26 +09:00
|
|
|
className={cn(
|
|
|
|
|
"flex items-center gap-2 rounded-lg border p-2.5 text-left transition-all",
|
|
|
|
|
inputType === item.value
|
|
|
|
|
? "border-primary bg-primary/5 ring-1 ring-primary/20"
|
|
|
|
|
: "border-border hover:border-primary/30 hover:bg-muted/30"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<item.icon className={cn(
|
|
|
|
|
"h-4 w-4 shrink-0",
|
|
|
|
|
inputType === item.value ? "text-primary" : "text-muted-foreground"
|
|
|
|
|
)} />
|
|
|
|
|
<div className="min-w-0">
|
|
|
|
|
<span className={cn(
|
|
|
|
|
"text-xs font-medium block",
|
|
|
|
|
inputType === item.value ? "text-primary" : "text-foreground"
|
|
|
|
|
)}>{item.label}</span>
|
|
|
|
|
<span className="text-[10px] text-muted-foreground block truncate">{item.desc}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-12 15:01:05 +09:00
|
|
|
{/* ─── 채번 타입 전용 설정 ─── */}
|
2026-03-11 21:51:37 +09:00
|
|
|
{inputType === "numbering" && (
|
|
|
|
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
2026-03-12 15:01:05 +09:00
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<ListOrdered className="h-4 w-4 text-primary" />
|
|
|
|
|
<span className="text-sm font-medium">채번 규칙</span>
|
2026-01-21 13:54:14 +09:00
|
|
|
</div>
|
2026-03-12 15:01:05 +09:00
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<p className="mb-1.5 text-xs text-muted-foreground">적용할 메뉴</p>
|
|
|
|
|
{menuObjid && selectedMenuObjid === menuObjid ? (
|
|
|
|
|
<div className="rounded-md border bg-background p-2">
|
|
|
|
|
<p className="text-xs text-muted-foreground">현재 화면 메뉴 사용 중</p>
|
|
|
|
|
<div className="mt-1 flex items-center justify-between">
|
|
|
|
|
<p className="text-sm font-medium">
|
|
|
|
|
{parentMenus.find((m: any) => m.objid === menuObjid)?.menu_name_kor
|
|
|
|
|
|| parentMenus.find((m: any) => m.objid === menuObjid)?.translated_name
|
|
|
|
|
|| `메뉴 #${menuObjid}`}
|
|
|
|
|
</p>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setSelectedMenuObjid(undefined)}
|
|
|
|
|
className="text-[10px] text-muted-foreground hover:text-foreground"
|
|
|
|
|
>
|
|
|
|
|
변경
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : loadingMenus ? (
|
|
|
|
|
<div className="text-muted-foreground flex items-center gap-2 text-xs py-1">
|
|
|
|
|
<Loader2 className="h-3 w-3 animate-spin" />
|
|
|
|
|
메뉴 목록 로딩 중...
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<Select
|
|
|
|
|
value={selectedMenuObjid ? String(selectedMenuObjid) : ""}
|
|
|
|
|
onValueChange={(v) => {
|
|
|
|
|
const objid = Number(v);
|
|
|
|
|
setSelectedMenuObjid(objid);
|
|
|
|
|
onChange({
|
|
|
|
|
...config,
|
|
|
|
|
autoGeneration: {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
type: "numbering_rule" as AutoGenerationType,
|
|
|
|
|
selectedMenuObjid: objid,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger className="h-8 text-sm">
|
|
|
|
|
<SelectValue placeholder="메뉴를 선택해주세요" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{parentMenus.map((menu: any) => (
|
|
|
|
|
<SelectItem key={menu.objid} value={String(menu.objid)}>
|
|
|
|
|
{menu.menu_name_kor || menu.translated_name || menu.menu_name || `메뉴 ${menu.objid}`}
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{selectedMenuObjid && (
|
|
|
|
|
<div>
|
|
|
|
|
<p className="mb-1.5 text-xs text-muted-foreground">채번 규칙</p>
|
|
|
|
|
{loadingRules ? (
|
|
|
|
|
<div className="text-muted-foreground flex items-center gap-2 text-xs py-1">
|
|
|
|
|
<Loader2 className="h-3 w-3 animate-spin" />
|
|
|
|
|
채번 규칙 로딩 중...
|
|
|
|
|
</div>
|
|
|
|
|
) : numberingRules.length > 0 ? (
|
|
|
|
|
<Select
|
|
|
|
|
value={config.autoGeneration?.numberingRuleId ? String(config.autoGeneration.numberingRuleId) : ""}
|
|
|
|
|
onValueChange={(v) => {
|
|
|
|
|
onChange({
|
|
|
|
|
...config,
|
|
|
|
|
autoGeneration: {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
type: "numbering_rule" as AutoGenerationType,
|
|
|
|
|
numberingRuleId: Number(v),
|
|
|
|
|
selectedMenuObjid,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger className="h-8 text-sm">
|
|
|
|
|
<SelectValue placeholder="채번 규칙 선택" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{numberingRules.map((rule) => (
|
|
|
|
|
<SelectItem key={rule.ruleId} value={String(rule.ruleId)}>
|
|
|
|
|
{rule.ruleName} ({rule.separator || "-"}{"{번호}"})
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
) : (
|
|
|
|
|
<p className="text-xs text-muted-foreground">선택한 메뉴에 등록된 채번 규칙이 없어요</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-sm">읽기전용</p>
|
|
|
|
|
<p className="text-[11px] text-muted-foreground">채번 필드는 자동 생성되므로 읽기전용을 권장해요</p>
|
|
|
|
|
</div>
|
|
|
|
|
<Switch
|
2026-01-21 13:54:14 +09:00
|
|
|
checked={config.readonly !== false}
|
2026-03-11 16:27:18 +09:00
|
|
|
onCheckedChange={(checked) => updateConfig("readonly", checked)}
|
2026-01-21 13:54:14 +09:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* ─── 채번 타입이 아닌 경우: 기본 설정 ─── */}
|
|
|
|
|
{inputType !== "numbering" && (
|
2026-01-21 13:54:14 +09:00
|
|
|
<>
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 기본 설정 영역 */}
|
|
|
|
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
|
|
|
|
{/* 안내 텍스트 (placeholder) */}
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">안내 텍스트</span>
|
|
|
|
|
<Input
|
|
|
|
|
value={config.placeholder || ""}
|
|
|
|
|
onChange={(e) => updateConfig("placeholder", e.target.value)}
|
|
|
|
|
placeholder="입력 안내"
|
|
|
|
|
className="h-7 w-[160px] text-xs"
|
|
|
|
|
/>
|
2025-12-23 09:31:18 +09:00
|
|
|
</div>
|
2026-03-11 16:27:18 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 입력 형식 - 텍스트 타입 전용 */}
|
|
|
|
|
{(inputType === "text" || !config.inputType) && (
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">입력 형식</span>
|
|
|
|
|
<Select value={config.format || "none"} onValueChange={(value) => updateConfig("format", value)}>
|
|
|
|
|
<SelectTrigger className="h-7 w-[160px] text-xs">
|
|
|
|
|
<SelectValue placeholder="형식 선택" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="none">제한 없음</SelectItem>
|
|
|
|
|
<SelectItem value="email">이메일</SelectItem>
|
|
|
|
|
<SelectItem value="tel">전화번호</SelectItem>
|
|
|
|
|
<SelectItem value="url">URL</SelectItem>
|
|
|
|
|
<SelectItem value="currency">통화</SelectItem>
|
|
|
|
|
<SelectItem value="biz_no">사업자번호</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
)}
|
2025-12-23 09:31:18 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 입력 마스크 */}
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<div>
|
|
|
|
|
<span className="text-xs text-muted-foreground">입력 마스크</span>
|
|
|
|
|
<p className="text-[10px] text-muted-foreground mt-0.5"># = 숫자, A = 문자, * = 모두</p>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
<Input
|
|
|
|
|
value={config.mask || ""}
|
|
|
|
|
onChange={(e) => updateConfig("mask", e.target.value)}
|
|
|
|
|
placeholder="###-####-####"
|
|
|
|
|
className="h-7 w-[160px] text-xs"
|
|
|
|
|
/>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-01-19 18:21:30 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 숫자/슬라이더: 범위 설정 */}
|
|
|
|
|
{(inputType === "number" || inputType === "slider") && (
|
|
|
|
|
<div className="space-y-2 pt-1">
|
|
|
|
|
<p className="text-xs text-muted-foreground">값 범위</p>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
<Label className="text-[10px] text-muted-foreground">최소값</Label>
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
value={config.min ?? ""}
|
|
|
|
|
onChange={(e) => updateConfig("min", e.target.value ? Number(e.target.value) : undefined)}
|
|
|
|
|
placeholder="0"
|
|
|
|
|
className="h-7 text-xs"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
<Label className="text-[10px] text-muted-foreground">최대값</Label>
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
value={config.max ?? ""}
|
|
|
|
|
onChange={(e) => updateConfig("max", e.target.value ? Number(e.target.value) : undefined)}
|
|
|
|
|
placeholder="100"
|
|
|
|
|
className="h-7 text-xs"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
<Label className="text-[10px] text-muted-foreground">단계</Label>
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
value={config.step ?? ""}
|
|
|
|
|
onChange={(e) => updateConfig("step", e.target.value ? Number(e.target.value) : undefined)}
|
|
|
|
|
placeholder="1"
|
|
|
|
|
className="h-7 text-xs"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
)}
|
2026-01-19 18:21:30 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 여러 줄 텍스트: 줄 수 */}
|
|
|
|
|
{inputType === "textarea" && (
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">줄 수</span>
|
2026-03-11 16:27:18 +09:00
|
|
|
<Input
|
2026-03-11 21:51:37 +09:00
|
|
|
type="number"
|
|
|
|
|
value={config.rows || 3}
|
|
|
|
|
onChange={(e) => updateConfig("rows", parseInt(e.target.value) || 3)}
|
|
|
|
|
min={2}
|
|
|
|
|
max={20}
|
|
|
|
|
className="h-7 w-[160px] text-xs"
|
2026-03-11 16:27:18 +09:00
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
)}
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-01-19 18:21:30 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* ─── 고급 설정: 자동 생성 (Collapsible) ─── */}
|
|
|
|
|
<Collapsible open={advancedOpen} onOpenChange={setAdvancedOpen}>
|
|
|
|
|
<CollapsibleTrigger asChild>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="flex w-full items-center justify-between rounded-lg border bg-muted/30 px-4 py-2.5 text-left transition-colors hover:bg-muted/50"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Settings className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
<span className="text-sm font-medium">고급 설정</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ChevronDown
|
|
|
|
|
className={cn(
|
|
|
|
|
"h-4 w-4 text-muted-foreground transition-transform duration-200",
|
|
|
|
|
advancedOpen && "rotate-180"
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
|
|
|
|
</CollapsibleTrigger>
|
|
|
|
|
<CollapsibleContent>
|
|
|
|
|
<div className="rounded-b-lg border border-t-0 p-4 space-y-3">
|
|
|
|
|
{/* 자동 생성 토글 */}
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-sm">자동 생성</p>
|
|
|
|
|
<p className="text-[11px] text-muted-foreground">값이 자동으로 채워져요</p>
|
2026-01-19 18:21:30 +09:00
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
<Switch
|
|
|
|
|
checked={config.autoGeneration?.enabled || false}
|
|
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
const currentConfig = config.autoGeneration || { type: "none", enabled: false };
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...currentConfig,
|
|
|
|
|
enabled: checked as boolean,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{config.autoGeneration?.enabled && (
|
|
|
|
|
<div className="space-y-3 ml-1 border-l-2 border-primary/20 pl-3">
|
|
|
|
|
{/* 자동 생성 타입 */}
|
|
|
|
|
<div>
|
|
|
|
|
<p className="mb-1.5 text-xs text-muted-foreground">생성 방식</p>
|
|
|
|
|
<Select
|
|
|
|
|
value={config.autoGeneration?.type || "none"}
|
|
|
|
|
onValueChange={(value: AutoGenerationType) => {
|
|
|
|
|
const currentConfig = config.autoGeneration || { type: "none", enabled: false };
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...currentConfig,
|
|
|
|
|
type: value,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger className="h-8 text-sm">
|
|
|
|
|
<SelectValue placeholder="자동생성 타입 선택" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="none">자동생성 없음</SelectItem>
|
|
|
|
|
<SelectItem value="uuid">UUID 생성</SelectItem>
|
|
|
|
|
<SelectItem value="current_user">현재 사용자 ID</SelectItem>
|
|
|
|
|
<SelectItem value="current_time">현재 시간</SelectItem>
|
|
|
|
|
<SelectItem value="sequence">순차 번호</SelectItem>
|
|
|
|
|
<SelectItem value="numbering_rule">채번 규칙</SelectItem>
|
|
|
|
|
<SelectItem value="random_string">랜덤 문자열</SelectItem>
|
|
|
|
|
<SelectItem value="random_number">랜덤 숫자</SelectItem>
|
|
|
|
|
<SelectItem value="company_code">회사 코드</SelectItem>
|
|
|
|
|
<SelectItem value="department">부서 코드</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
2026-01-19 18:21:30 +09:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{config.autoGeneration?.type && config.autoGeneration.type !== "none" && (
|
|
|
|
|
<p className="text-[11px] text-muted-foreground">
|
|
|
|
|
{AutoGenerationUtils.getTypeDescription(config.autoGeneration.type)}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* 채번 규칙 선택 */}
|
|
|
|
|
{config.autoGeneration?.type === "numbering_rule" && (
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div>
|
|
|
|
|
<p className="mb-1.5 text-xs text-muted-foreground">
|
|
|
|
|
대상 메뉴 <span className="text-destructive">*</span>
|
|
|
|
|
</p>
|
2026-03-11 16:27:18 +09:00
|
|
|
<Select
|
2026-03-11 21:51:37 +09:00
|
|
|
value={selectedMenuObjid?.toString() || ""}
|
2026-03-11 16:27:18 +09:00
|
|
|
onValueChange={(value) => {
|
2026-03-11 21:51:37 +09:00
|
|
|
const menuId = parseInt(value);
|
|
|
|
|
setSelectedMenuObjid(menuId);
|
2026-03-11 16:27:18 +09:00
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...config.autoGeneration,
|
2026-03-11 21:51:37 +09:00
|
|
|
selectedMenuObjid: menuId,
|
2026-03-11 16:27:18 +09:00
|
|
|
});
|
|
|
|
|
}}
|
2026-03-11 21:51:37 +09:00
|
|
|
disabled={loadingMenus}
|
2026-03-11 16:27:18 +09:00
|
|
|
>
|
2026-03-11 21:51:37 +09:00
|
|
|
<SelectTrigger className="h-8 text-sm">
|
|
|
|
|
<SelectValue placeholder={loadingMenus ? "로딩 중..." : "메뉴 선택"} />
|
2026-03-11 16:27:18 +09:00
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
2026-03-11 21:51:37 +09:00
|
|
|
{parentMenus.length === 0 ? (
|
|
|
|
|
<SelectItem value="no-menus" disabled>
|
|
|
|
|
사용 가능한 메뉴가 없습니다
|
2026-03-11 16:27:18 +09:00
|
|
|
</SelectItem>
|
|
|
|
|
) : (
|
2026-03-11 21:51:37 +09:00
|
|
|
parentMenus.map((menu) => (
|
|
|
|
|
<SelectItem key={menu.objid} value={menu.objid.toString()}>
|
|
|
|
|
{menu.menu_name_kor}
|
2026-03-11 16:27:18 +09:00
|
|
|
</SelectItem>
|
|
|
|
|
))
|
|
|
|
|
)}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
|
|
|
|
|
{selectedMenuObjid ? (
|
|
|
|
|
<div>
|
|
|
|
|
<p className="mb-1.5 text-xs text-muted-foreground">
|
|
|
|
|
채번 규칙 <span className="text-destructive">*</span>
|
|
|
|
|
</p>
|
|
|
|
|
{loadingRules ? (
|
|
|
|
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
|
|
|
<Loader2 className="h-3 w-3 animate-spin" />
|
|
|
|
|
규칙 로딩 중...
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<Select
|
|
|
|
|
value={config.autoGeneration?.options?.numberingRuleId || ""}
|
|
|
|
|
onValueChange={(value) => {
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
options: {
|
|
|
|
|
...config.autoGeneration?.options,
|
|
|
|
|
numberingRuleId: value,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger className="h-8 text-sm">
|
|
|
|
|
<SelectValue placeholder="규칙 선택" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{numberingRules.length === 0 ? (
|
|
|
|
|
<SelectItem value="no-rules" disabled>
|
|
|
|
|
사용 가능한 규칙이 없습니다
|
|
|
|
|
</SelectItem>
|
|
|
|
|
) : (
|
|
|
|
|
numberingRules.map((rule) => (
|
|
|
|
|
<SelectItem key={rule.ruleId} value={rule.ruleId}>
|
|
|
|
|
{rule.ruleName}
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))
|
|
|
|
|
)}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="rounded-md border border-amber-200 bg-amber-50 p-2.5 text-xs text-amber-800">
|
|
|
|
|
먼저 대상 메뉴를 선택하세요
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-19 18:21:30 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
{/* 랜덤/순차 옵션 */}
|
|
|
|
|
{config.autoGeneration?.type &&
|
|
|
|
|
["random_string", "random_number", "sequence"].includes(config.autoGeneration.type) && (
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
{["random_string", "random_number"].includes(config.autoGeneration.type) && (
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">길이</span>
|
|
|
|
|
<Input
|
|
|
|
|
type="number"
|
|
|
|
|
min="1"
|
|
|
|
|
max="50"
|
|
|
|
|
value={config.autoGeneration?.options?.length || 8}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
options: {
|
|
|
|
|
...config.autoGeneration?.options,
|
|
|
|
|
length: parseInt(e.target.value) || 8,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
className="h-7 w-[120px] text-xs"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">접두사</span>
|
2026-03-11 16:27:18 +09:00
|
|
|
<Input
|
2026-03-11 21:51:37 +09:00
|
|
|
value={config.autoGeneration?.options?.prefix || ""}
|
2026-03-11 16:27:18 +09:00
|
|
|
onChange={(e) => {
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
options: {
|
|
|
|
|
...config.autoGeneration?.options,
|
2026-03-11 21:51:37 +09:00
|
|
|
prefix: e.target.value,
|
2026-03-11 16:27:18 +09:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
2026-03-11 21:51:37 +09:00
|
|
|
placeholder="예: INV-"
|
|
|
|
|
className="h-7 w-[120px] text-xs"
|
2026-03-11 16:27:18 +09:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
<div className="flex items-center justify-between py-1">
|
|
|
|
|
<span className="text-xs text-muted-foreground">접미사</span>
|
|
|
|
|
<Input
|
|
|
|
|
value={config.autoGeneration?.options?.suffix || ""}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
updateConfig("autoGeneration", {
|
|
|
|
|
...config.autoGeneration,
|
|
|
|
|
options: {
|
|
|
|
|
...config.autoGeneration?.options,
|
|
|
|
|
suffix: e.target.value,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
className="h-7 w-[120px] text-xs"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-11 16:27:18 +09:00
|
|
|
|
2026-03-11 21:51:37 +09:00
|
|
|
<div>
|
|
|
|
|
<span className="text-xs text-muted-foreground">미리보기</span>
|
|
|
|
|
<div className="mt-1 rounded-md border bg-muted p-2 text-xs font-mono">
|
|
|
|
|
{AutoGenerationUtils.generatePreviewValue(config.autoGeneration)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-03-11 16:27:18 +09:00
|
|
|
</div>
|
2026-03-11 21:51:37 +09:00
|
|
|
</CollapsibleContent>
|
|
|
|
|
</Collapsible>
|
2026-01-21 13:54:14 +09:00
|
|
|
</>
|
|
|
|
|
)}
|
2025-12-23 09:31:18 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-28 17:36:19 +09:00
|
|
|
V2InputConfigPanel.displayName = "V2InputConfigPanel";
|
2025-12-23 09:31:18 +09:00
|
|
|
|
2026-01-28 17:36:19 +09:00
|
|
|
export default V2InputConfigPanel;
|