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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
// 기본 계약 관련 컬럼 설정 파일
import {
BasicContractTemplate,
BasicContractView
} from "@/db/schema";
// 컬럼 설정 인터페이스
export interface BasicContractColumnConfig {
/** 테이블에서 접근할 필드 */
id: keyof BasicContractView;
/** 화면에 표시될 컬럼명 */
label: string;
/** (선택) 그룹핑/카테고리 */
group?: string;
/** (선택) Excel 내보내기용 헤더 */
excelHeader?: string;
/** (선택) 데이터 타입(포맷팅 용도) */
type?: 'string' | 'number' | 'date' | 'boolean';
}
// 템플릿 컬럼 설정 인터페이스
export interface BasicContractTemplateColumnConfig {
/** 테이블에서 접근할 필드 */
id: keyof BasicContractTemplate;
/** 화면에 표시될 컬럼명 */
label: string;
/** (선택) 그룹핑/카테고리 */
group?: string;
/** (선택) Excel 내보내기용 헤더 */
excelHeader?: string;
/** (선택) 데이터 타입(포맷팅 용도) */
type?: 'string' | 'number' | 'date' | 'boolean';
}
// 기본 계약 뷰 컬럼 설정 (업데이트된 뷰 테이블 기준)
export const basicContractColumnsConfig: BasicContractColumnConfig[] = [
// 벤더 정보 그룹
{
id: "vendorCode",
label: "Vendor Code",
excelHeader: "Vendor Code",
group: "벤더 정보",
},
{
id: "vendorName",
label: "업체명",
excelHeader: "업체명",
group: "벤더 정보",
},
{
id: "vendorEmail",
label: "업체대표이메일",
excelHeader: "업체대표이메일",
group: "벤더 정보",
},
// 템플릿 정보 그룹
{
id: "templateCode",
label: "템플릿 코드",
excelHeader: "템플릿 코드",
group: "템플릿 정보",
},
{
id: "templateName",
label: "템플릿 이름",
excelHeader: "템플릿 이름",
group: "템플릿 정보",
},
{
id: "templateRevision",
label: "리비전",
excelHeader: "리비전",
group: "템플릿 정보",
type: "number",
},
{
id: "validityPeriod",
label: "유효기간(개월)",
excelHeader: "유효기간(개월)",
group: "템플릿 정보",
type: "number",
},
{
id: "legalReviewRequired",
label: "법무검토 필요",
excelHeader: "법무검토 필요",
group: "템플릿 정보",
type: "boolean",
},
// 계약 상태 정보
{
id: "status",
label: "서명 상태",
excelHeader: "서명 상태",
group: "계약 상태",
},
{
id: "templateStatus",
label: "템플릿 상태",
excelHeader: "템플릿 상태",
group: "계약 상태",
},
// 요청자 정보
{
id: "requestedByName",
label: "요청자",
excelHeader: "요청자",
group: "요청자 정보",
},
// 날짜 정보 그룹
{
id: "createdAt",
label: "요청일",
excelHeader: "요청일",
group: "날짜 정보",
type: "date",
},
{
id: "completedAt",
label: "서명완료일",
excelHeader: "서명완료일",
group: "날짜 정보",
type: "date",
},
{
id: "updatedAt",
label: "최종수정일",
excelHeader: "최종수정일",
group: "날짜 정보",
type: "date",
},
];
// 기본 계약 템플릿 컬럼 설정 (업데이트된 스키마 기준)
export const basicContractTemplateColumnsConfig: BasicContractTemplateColumnConfig[] = [
{
id: "templateName",
label: "템플릿 이름",
excelHeader: "템플릿 이름",
group: "기본 정보",
},
{
id: "revision",
label: "리비전",
excelHeader: "리비전",
group: "기본 정보",
type: "number",
},
{
id: "status",
label: "상태",
excelHeader: "상태",
group: "기본 정보",
},
// {
// id: "validityPeriod",
// label: "유효기간(개월)",
// excelHeader: "유효기간(개월)",
// group: "기본 정보",
// type: "number",
// },
{
id: "legalReviewRequired",
label: "법무검토 필요",
excelHeader: "법무검토 필요",
group: "기본 정보",
type: "boolean",
},
// 파일 정보 그룹
{
id: "fileName",
label: "파일명",
excelHeader: "파일명",
group: "파일 정보",
},
// 감사 정보 그룹
{
id: "createdAt",
label: "생성일",
excelHeader: "생성일",
group: "감사 정보",
type: "date",
},
{
id: "updatedAt",
label: "수정일",
excelHeader: "수정일",
group: "감사 정보",
type: "date",
},
{
id: "disposedAt",
label: "폐기일",
excelHeader: "폐기일",
group: "감사 정보",
type: "date",
},
{
id: "restoredAt",
label: "복구일",
excelHeader: "복구일",
group: "감사 정보",
type: "date",
},
];
// 벤더용 계약 뷰 컬럼 설정 (벤더가 보는 화면용)
export const basicContractVendorColumnsConfig: BasicContractColumnConfig[] = [
// 템플릿 정보
{
id: "templateName",
label: "계약 유형",
excelHeader: "계약 유형",
// group: "계약 정보",
},
{
id: "templateRevision",
label: "리비전",
excelHeader: "리비전",
// group: "계약 정보",
type: "number",
},
// 상태 정보
{
id: "status",
label: "서명 상태",
excelHeader: "서명 상태",
// group: "계약 상태",
},
// 요청자 정보
{
id: "requestedByName",
label: "요청자",
excelHeader: "요청자",
// group: "요청자 정보",
},
// 날짜 정보
{
id: "createdAt",
label: "요청일",
excelHeader: "요청일",
// group: "날짜 정보",
type: "date",
},
{
id: "completedAt",
label: "서명완료일",
excelHeader: "서명완료일",
// group: "날짜 정보",
type: "date",
},
{
id: "updatedAt",
label: "최종수정일",
excelHeader: "최종수정일",
// group: "날짜 정보",
type: "date",
},
];
// 적용 범위 상수 및 유틸리티
export const BUSINESS_UNITS = [
{ key: 'shipBuildingApplicable', label: '조선해양', shortLabel: '조선' },
{ key: 'windApplicable', label: '풍력', shortLabel: '풍력' },
{ key: 'pcApplicable', label: 'PC', shortLabel: 'PC' },
{ key: 'nbApplicable', label: 'NB', shortLabel: 'NB' },
{ key: 'rcApplicable', label: 'RC', shortLabel: 'RC' },
{ key: 'gyApplicable', label: 'GY', shortLabel: 'GY' },
{ key: 'sysApplicable', label: 'S&Sys', shortLabel: 'S&S' },
{ key: 'infraApplicable', label: 'Infra', shortLabel: 'Infra' },
] as const;
// 적용 범위 관련 헬퍼 함수들
export const scopeHelpers = {
// 적용된 사업부 목록을 문자열로 반환
getApplicableScopeLabels: (template: BasicContractTemplate): string[] => {
return BUSINESS_UNITS
.filter(unit => template[unit.key as keyof BasicContractTemplate])
.map(unit => unit.shortLabel);
},
// 적용된 사업부 수 반환
getApplicableScopeCount: (template: BasicContractTemplate): number => {
return BUSINESS_UNITS
.filter(unit => template[unit.key as keyof BasicContractTemplate])
.length;
},
// 모든 사업부가 적용되었는지 확인
isAllScopesApplicable: (template: BasicContractTemplate): boolean => {
return BUSINESS_UNITS
.every(unit => template[unit.key as keyof BasicContractTemplate]);
},
// 적용 범위 문자열 생성 (UI 표시용)
getScopeDisplayText: (template: BasicContractTemplate): string => {
const applicable = scopeHelpers.getApplicableScopeLabels(template);
if (applicable.length === 0) return '적용 범위 없음';
if (applicable.length === BUSINESS_UNITS.length) return '전체 적용';
if (applicable.length <= 3) return applicable.join(', ');
return `${applicable.slice(0, 2).join(', ')} 외 ${applicable.length - 2}개`;
}
};
|