147 lines
4.5 KiB
TypeScript
147 lines
4.5 KiB
TypeScript
/**
|
|
* 코드 채번 규칙 컴포넌트 타입 정의
|
|
* Shadcn/ui 가이드라인 기반
|
|
*/
|
|
|
|
/**
|
|
* 코드 파트 유형 (4가지)
|
|
*/
|
|
export type CodePartType =
|
|
| "sequence" // 순번 (자동 증가 숫자)
|
|
| "number" // 숫자 (고정 자릿수)
|
|
| "date" // 날짜 (다양한 날짜 형식)
|
|
| "text"; // 문자 (텍스트)
|
|
|
|
/**
|
|
* 생성 방식
|
|
*/
|
|
export type GenerationMethod =
|
|
| "auto" // 자동 생성
|
|
| "manual"; // 직접 입력
|
|
|
|
/**
|
|
* 날짜 형식
|
|
*/
|
|
export type DateFormat =
|
|
| "YYYY" // 2025
|
|
| "YY" // 25
|
|
| "YYYYMM" // 202511
|
|
| "YYMM" // 2511
|
|
| "YYYYMMDD" // 20251104
|
|
| "YYMMDD"; // 251104
|
|
|
|
/**
|
|
* 단일 규칙 파트
|
|
*/
|
|
export interface NumberingRulePart {
|
|
id: string; // 고유 ID
|
|
order: number; // 순서 (1-6)
|
|
partType: CodePartType; // 파트 유형
|
|
generationMethod: GenerationMethod; // 생성 방식
|
|
|
|
// 자동 생성 설정
|
|
autoConfig?: {
|
|
// 순번용
|
|
sequenceLength?: number; // 순번 자릿수 (예: 3 → 001)
|
|
startFrom?: number; // 시작 번호 (기본: 1)
|
|
|
|
// 숫자용
|
|
numberLength?: number; // 숫자 자릿수 (예: 4 → 0001)
|
|
numberValue?: number; // 숫자 값
|
|
|
|
// 날짜용
|
|
dateFormat?: DateFormat; // 날짜 형식
|
|
|
|
// 문자용
|
|
textValue?: string; // 텍스트 값 (예: "PRJ", "CODE")
|
|
};
|
|
|
|
// 직접 입력 설정
|
|
manualConfig?: {
|
|
value: string; // 입력값
|
|
placeholder?: string; // 플레이스홀더
|
|
};
|
|
|
|
// 생성된 값 (미리보기용)
|
|
generatedValue?: string;
|
|
}
|
|
|
|
/**
|
|
* 전체 채번 규칙
|
|
*/
|
|
export interface NumberingRuleConfig {
|
|
ruleId: string; // 규칙 ID
|
|
ruleName: string; // 규칙명
|
|
description?: string; // 설명
|
|
parts: NumberingRulePart[]; // 규칙 파트 배열
|
|
|
|
// 설정
|
|
separator?: string; // 구분자 (기본: "-")
|
|
resetPeriod?: "none" | "daily" | "monthly" | "yearly";
|
|
currentSequence?: number; // 현재 시퀀스
|
|
|
|
// 적용 범위
|
|
scopeType?: "global" | "menu"; // 적용 범위 (전역/메뉴별)
|
|
menuObjid?: number; // 적용할 메뉴 OBJID (상위 메뉴 기준)
|
|
|
|
// 적용 대상
|
|
tableName?: string; // 적용할 테이블명
|
|
columnName?: string; // 적용할 컬럼명
|
|
|
|
// 메타 정보
|
|
companyCode?: string;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
createdBy?: string;
|
|
}
|
|
|
|
/**
|
|
* UI 옵션 상수
|
|
*/
|
|
export const CODE_PART_TYPE_OPTIONS: Array<{ value: CodePartType; label: string; description: string }> = [
|
|
{ value: "sequence", label: "순번", description: "자동 증가 순번 (1, 2, 3...)" },
|
|
{ value: "number", label: "숫자", description: "고정 자릿수 숫자 (001, 002...)" },
|
|
{ value: "date", label: "날짜", description: "날짜 형식 (2025-11-04)" },
|
|
{ value: "text", label: "문자", description: "텍스트 또는 코드" },
|
|
];
|
|
|
|
export const DATE_FORMAT_OPTIONS: Array<{ value: DateFormat; label: string; example: string }> = [
|
|
{ value: "YYYY", label: "연도 (4자리)", example: "2025" },
|
|
{ value: "YY", label: "연도 (2자리)", example: "25" },
|
|
{ value: "YYYYMM", label: "연도+월", example: "202511" },
|
|
{ value: "YYMM", label: "연도(2)+월", example: "2511" },
|
|
{ value: "YYYYMMDD", label: "연월일", example: "20251104" },
|
|
{ value: "YYMMDD", label: "연(2)+월일", example: "251104" },
|
|
];
|
|
|
|
export const RESET_PERIOD_OPTIONS: Array<{
|
|
value: "none" | "daily" | "monthly" | "yearly";
|
|
label: string;
|
|
}> = [
|
|
{ value: "none", label: "초기화 안함" },
|
|
{ value: "daily", label: "일별 초기화" },
|
|
{ value: "monthly", label: "월별 초기화" },
|
|
{ value: "yearly", label: "연별 초기화" },
|
|
];
|
|
|
|
/**
|
|
* 구분자 옵션
|
|
* - 규칙과 규칙 사이에 들어가는 문자
|
|
* - "none"은 구분자 없음
|
|
* - "custom"은 직접 입력 (최대 2자)
|
|
*/
|
|
export type SeparatorType = "none" | "-" | "_" | "." | "/" | "custom";
|
|
|
|
export const SEPARATOR_OPTIONS: Array<{
|
|
value: SeparatorType;
|
|
label: string;
|
|
displayValue: string;
|
|
}> = [
|
|
{ value: "none", label: "없음", displayValue: "" },
|
|
{ value: "-", label: "하이픈 (-)", displayValue: "-" },
|
|
{ value: "_", label: "언더스코어 (_)", displayValue: "_" },
|
|
{ value: ".", label: "점 (.)", displayValue: "." },
|
|
{ value: "/", label: "슬래시 (/)", displayValue: "/" },
|
|
{ value: "custom", label: "직접입력", displayValue: "" },
|
|
];
|