118 lines
3.3 KiB
TypeScript
118 lines
3.3 KiB
TypeScript
/**
|
|
* 코드 채번 규칙 컴포넌트 타입 정의
|
|
* Shadcn/ui 가이드라인 기반
|
|
*/
|
|
|
|
/**
|
|
* 코드 파트 유형
|
|
*/
|
|
export type CodePartType =
|
|
| "prefix" // 접두사 (고정 문자열)
|
|
| "sequence" // 순번 (자동 증가)
|
|
| "date" // 날짜 (YYYYMMDD 등)
|
|
| "year" // 연도 (YYYY)
|
|
| "month" // 월 (MM)
|
|
| "custom"; // 사용자 정의
|
|
|
|
/**
|
|
* 생성 방식
|
|
*/
|
|
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?: {
|
|
prefix?: string; // 접두사
|
|
sequenceLength?: number; // 순번 자릿수
|
|
startFrom?: number; // 시작 번호
|
|
dateFormat?: DateFormat; // 날짜 형식
|
|
value?: string; // 커스텀 값
|
|
};
|
|
|
|
// 직접 입력 설정
|
|
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; // 현재 시퀀스
|
|
|
|
// 적용 대상
|
|
tableName?: string; // 적용할 테이블명
|
|
columnName?: string; // 적용할 컬럼명
|
|
|
|
// 메타 정보
|
|
companyCode?: string;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
createdBy?: string;
|
|
}
|
|
|
|
/**
|
|
* UI 옵션 상수
|
|
*/
|
|
export const CODE_PART_TYPE_OPTIONS: Array<{ value: CodePartType; label: string }> = [
|
|
{ value: "prefix", label: "접두사" },
|
|
{ value: "sequence", label: "순번" },
|
|
{ value: "date", label: "날짜" },
|
|
{ value: "year", label: "연도" },
|
|
{ value: "month", label: "월" },
|
|
{ value: "custom", label: "사용자 정의" },
|
|
];
|
|
|
|
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: "연별 초기화" },
|
|
];
|