blob: ddeb5e6d76949e2b192b98c25de9f31aa3b5cf9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// docu-list-rule 모듈 공통 유틸리티 함수들
/**
* Code Group ID에서 다음 번호를 생성하는 함수
* DOC_CLASS는 제외하고 계산
*/
export function generateNextCodeGroupId(lastGroupId: string): string {
if (!lastGroupId.startsWith('GROUP')) {
return 'GROUP001'
}
const numberPart = lastGroupId.substring(5)
const nextNumber = parseInt(numberPart) + 1
return `GROUP${nextNumber.toString().padStart(3, '0')}`
}
/**
* Document Class Code에서 다음 번호를 생성하는 함수
*/
export function generateNextDocumentClassCode(lastCode: string): string {
if (!lastCode.startsWith('DOC_CLASS_')) {
return 'DOC_CLASS_001'
}
const numberPart = lastCode.substring(10)
const nextNumber = parseInt(numberPart) + 1
return `DOC_CLASS_${nextNumber.toString().padStart(3, '0')}`
}
/**
* Number Type Config에서 다음 SDQ를 생성하는 함수
*/
export function generateNextSdq(configs: Array<{ sdq: number }>): number {
if (configs.length === 0) {
return 1
}
const maxSdq = Math.max(...configs.map(config => config.sdq))
return maxSdq + 1
}
/**
* 활성화된 항목만 필터링하는 함수
*/
export function filterActiveItems<T extends { isActive: boolean }>(items: T[]): T[] {
return items.filter(item => item.isActive)
}
/**
* 날짜를 포맷팅하는 함수
*/
export function formatDate(date: Date): string {
return new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
}).format(date)
}
|