2025-12-04 17:40:41 +09:00
|
|
|
/**
|
|
|
|
|
* 범용 폼 모달 컴포넌트 기본 설정
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-18 15:19:59 +09:00
|
|
|
import {
|
|
|
|
|
UniversalFormModalConfig,
|
|
|
|
|
TableSectionConfig,
|
|
|
|
|
TableColumnConfig,
|
|
|
|
|
ValueMappingConfig,
|
|
|
|
|
ColumnModeConfig,
|
|
|
|
|
TablePreFilter,
|
|
|
|
|
TableModalFilter,
|
|
|
|
|
TableCalculationRule,
|
2025-12-28 19:32:13 +09:00
|
|
|
ConditionalTableConfig,
|
|
|
|
|
ConditionalTableOption,
|
2025-12-18 15:19:59 +09:00
|
|
|
} from "./types";
|
2025-12-04 17:40:41 +09:00
|
|
|
|
|
|
|
|
// 기본 설정값
|
|
|
|
|
export const defaultConfig: UniversalFormModalConfig = {
|
|
|
|
|
modal: {
|
|
|
|
|
title: "데이터 입력",
|
|
|
|
|
description: "",
|
|
|
|
|
size: "lg",
|
|
|
|
|
closeOnOutsideClick: false,
|
|
|
|
|
showCloseButton: true,
|
|
|
|
|
},
|
|
|
|
|
sections: [
|
|
|
|
|
{
|
|
|
|
|
id: "default",
|
|
|
|
|
title: "기본 정보",
|
|
|
|
|
description: "",
|
|
|
|
|
collapsible: false,
|
|
|
|
|
defaultCollapsed: false,
|
|
|
|
|
columns: 2,
|
|
|
|
|
gap: "16px",
|
|
|
|
|
fields: [],
|
|
|
|
|
repeatable: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
saveConfig: {
|
|
|
|
|
tableName: "",
|
|
|
|
|
primaryKeyColumn: "id",
|
|
|
|
|
afterSave: {
|
|
|
|
|
closeModal: true,
|
|
|
|
|
refreshParent: true,
|
|
|
|
|
showToast: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
editMode: {
|
|
|
|
|
enabled: false,
|
|
|
|
|
loadDataOnOpen: true,
|
|
|
|
|
identifierField: "id",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 필드 설정
|
|
|
|
|
export const defaultFieldConfig = {
|
|
|
|
|
id: "",
|
|
|
|
|
columnName: "",
|
|
|
|
|
label: "",
|
|
|
|
|
fieldType: "text" as const,
|
|
|
|
|
required: false,
|
|
|
|
|
defaultValue: "",
|
|
|
|
|
placeholder: "",
|
|
|
|
|
disabled: false,
|
|
|
|
|
readOnly: false,
|
|
|
|
|
width: "100%",
|
|
|
|
|
gridSpan: 6,
|
|
|
|
|
receiveFromParent: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 섹션 설정
|
|
|
|
|
export const defaultSectionConfig = {
|
|
|
|
|
id: "",
|
|
|
|
|
title: "새 섹션",
|
|
|
|
|
description: "",
|
2025-12-18 15:19:59 +09:00
|
|
|
type: "fields" as const,
|
2025-12-04 17:40:41 +09:00
|
|
|
collapsible: false,
|
|
|
|
|
defaultCollapsed: false,
|
|
|
|
|
columns: 2,
|
|
|
|
|
gap: "16px",
|
|
|
|
|
fields: [],
|
|
|
|
|
repeatable: false,
|
|
|
|
|
repeatConfig: {
|
|
|
|
|
minItems: 0,
|
|
|
|
|
maxItems: 10,
|
|
|
|
|
addButtonText: "+ 추가",
|
|
|
|
|
removeButtonText: "삭제",
|
|
|
|
|
itemTitle: "항목 {index}",
|
|
|
|
|
confirmRemove: false,
|
|
|
|
|
},
|
2025-12-17 14:30:29 +09:00
|
|
|
optionalFieldGroups: [],
|
2025-12-05 12:59:03 +09:00
|
|
|
linkedFieldGroups: [],
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-18 15:19:59 +09:00
|
|
|
// ============================================
|
|
|
|
|
// 테이블 섹션 관련 기본값
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
// 기본 테이블 섹션 설정
|
|
|
|
|
export const defaultTableSectionConfig: TableSectionConfig = {
|
|
|
|
|
source: {
|
|
|
|
|
tableName: "",
|
|
|
|
|
displayColumns: [],
|
|
|
|
|
searchColumns: [],
|
|
|
|
|
columnLabels: {},
|
|
|
|
|
},
|
|
|
|
|
filters: {
|
|
|
|
|
preFilters: [],
|
|
|
|
|
modalFilters: [],
|
|
|
|
|
},
|
|
|
|
|
columns: [],
|
|
|
|
|
calculations: [],
|
|
|
|
|
saveConfig: {
|
|
|
|
|
targetTable: undefined,
|
|
|
|
|
uniqueField: undefined,
|
|
|
|
|
},
|
|
|
|
|
uiConfig: {
|
|
|
|
|
addButtonText: "항목 검색",
|
|
|
|
|
modalTitle: "항목 검색 및 선택",
|
|
|
|
|
multiSelect: true,
|
|
|
|
|
maxHeight: "400px",
|
|
|
|
|
},
|
2025-12-28 19:32:13 +09:00
|
|
|
conditionalTable: undefined,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 조건부 테이블 설정
|
|
|
|
|
export const defaultConditionalTableConfig: ConditionalTableConfig = {
|
|
|
|
|
enabled: false,
|
|
|
|
|
triggerType: "checkbox",
|
|
|
|
|
conditionColumn: "",
|
|
|
|
|
options: [],
|
|
|
|
|
optionSource: {
|
|
|
|
|
enabled: false,
|
|
|
|
|
tableName: "",
|
|
|
|
|
valueColumn: "",
|
|
|
|
|
labelColumn: "",
|
|
|
|
|
filterCondition: "",
|
|
|
|
|
},
|
|
|
|
|
sourceFilter: {
|
|
|
|
|
enabled: false,
|
|
|
|
|
filterColumn: "",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 조건부 테이블 옵션 설정
|
|
|
|
|
export const defaultConditionalTableOptionConfig: ConditionalTableOption = {
|
|
|
|
|
id: "",
|
|
|
|
|
value: "",
|
|
|
|
|
label: "",
|
2025-12-18 15:19:59 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 테이블 컬럼 설정
|
|
|
|
|
export const defaultTableColumnConfig: TableColumnConfig = {
|
|
|
|
|
field: "",
|
|
|
|
|
label: "",
|
|
|
|
|
type: "text",
|
|
|
|
|
editable: true,
|
|
|
|
|
calculated: false,
|
|
|
|
|
required: false,
|
|
|
|
|
width: "150px",
|
|
|
|
|
minWidth: "60px",
|
|
|
|
|
maxWidth: "400px",
|
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
selectOptions: [],
|
|
|
|
|
valueMapping: undefined,
|
|
|
|
|
columnModes: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 값 매핑 설정
|
|
|
|
|
export const defaultValueMappingConfig: ValueMappingConfig = {
|
|
|
|
|
type: "source",
|
|
|
|
|
sourceField: "",
|
|
|
|
|
externalRef: undefined,
|
|
|
|
|
internalField: undefined,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 컬럼 모드 설정
|
|
|
|
|
export const defaultColumnModeConfig: ColumnModeConfig = {
|
|
|
|
|
id: "",
|
|
|
|
|
label: "",
|
|
|
|
|
isDefault: false,
|
|
|
|
|
valueMapping: {
|
|
|
|
|
type: "source",
|
|
|
|
|
sourceField: "",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 사전 필터 설정
|
|
|
|
|
export const defaultPreFilterConfig: TablePreFilter = {
|
|
|
|
|
column: "",
|
|
|
|
|
operator: "=",
|
|
|
|
|
value: "",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 모달 필터 설정
|
|
|
|
|
export const defaultModalFilterConfig: TableModalFilter = {
|
|
|
|
|
column: "",
|
|
|
|
|
label: "",
|
|
|
|
|
type: "category",
|
|
|
|
|
categoryRef: undefined,
|
|
|
|
|
options: [],
|
|
|
|
|
optionsFromTable: undefined,
|
|
|
|
|
defaultValue: undefined,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 계산 규칙 설정
|
|
|
|
|
export const defaultCalculationRuleConfig: TableCalculationRule = {
|
|
|
|
|
resultField: "",
|
|
|
|
|
formula: "",
|
|
|
|
|
dependencies: [],
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-17 14:30:29 +09:00
|
|
|
// 기본 옵셔널 필드 그룹 설정
|
|
|
|
|
export const defaultOptionalFieldGroupConfig = {
|
|
|
|
|
id: "",
|
|
|
|
|
fields: [],
|
|
|
|
|
// 섹션 스타일 설정
|
|
|
|
|
title: "옵셔널 그룹",
|
|
|
|
|
description: "",
|
|
|
|
|
columns: undefined, // undefined면 부모 섹션 columns 상속
|
|
|
|
|
collapsible: false,
|
|
|
|
|
defaultCollapsed: false,
|
|
|
|
|
// 버튼 설정
|
|
|
|
|
addButtonText: "",
|
|
|
|
|
removeButtonText: "제거",
|
|
|
|
|
confirmRemove: false,
|
|
|
|
|
// 연동 필드 설정
|
|
|
|
|
triggerField: "",
|
|
|
|
|
triggerValueOnAdd: "",
|
|
|
|
|
triggerValueOnRemove: "",
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-05 12:59:03 +09:00
|
|
|
// 기본 연동 필드 그룹 설정
|
|
|
|
|
export const defaultLinkedFieldGroupConfig = {
|
|
|
|
|
id: "",
|
|
|
|
|
label: "연동 필드",
|
|
|
|
|
sourceTable: "dept_info",
|
|
|
|
|
displayFormat: "code_name" as const,
|
|
|
|
|
displayColumn: "dept_name",
|
|
|
|
|
valueColumn: "dept_code",
|
|
|
|
|
mappings: [],
|
|
|
|
|
required: false,
|
|
|
|
|
placeholder: "선택하세요",
|
|
|
|
|
gridSpan: 6,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 연동 필드 매핑 설정
|
|
|
|
|
export const defaultLinkedFieldMappingConfig = {
|
|
|
|
|
sourceColumn: "",
|
|
|
|
|
targetColumn: "",
|
2025-12-04 17:40:41 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 채번규칙 설정
|
|
|
|
|
export const defaultNumberingRuleConfig = {
|
|
|
|
|
enabled: false,
|
|
|
|
|
ruleId: "",
|
|
|
|
|
editable: false,
|
|
|
|
|
hidden: false,
|
|
|
|
|
generateOnOpen: true,
|
|
|
|
|
generateOnSave: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 기본 Select 옵션 설정
|
|
|
|
|
export const defaultSelectOptionsConfig = {
|
|
|
|
|
type: "static" as const,
|
|
|
|
|
staticOptions: [],
|
|
|
|
|
tableName: "",
|
|
|
|
|
valueColumn: "",
|
|
|
|
|
labelColumn: "",
|
|
|
|
|
filterCondition: "",
|
|
|
|
|
codeCategory: "",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 모달 크기별 너비
|
|
|
|
|
export const MODAL_SIZE_MAP = {
|
|
|
|
|
sm: 400,
|
|
|
|
|
md: 600,
|
|
|
|
|
lg: 800,
|
|
|
|
|
xl: 1000,
|
|
|
|
|
full: "100%",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
// 유틸리티: 고유 ID 생성
|
|
|
|
|
export const generateUniqueId = (prefix: string = "item"): string => {
|
|
|
|
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 유틸리티: 섹션 ID 생성
|
|
|
|
|
export const generateSectionId = (): string => {
|
|
|
|
|
return generateUniqueId("section");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 유틸리티: 필드 ID 생성
|
|
|
|
|
export const generateFieldId = (): string => {
|
|
|
|
|
return generateUniqueId("field");
|
|
|
|
|
};
|
2025-12-05 12:59:03 +09:00
|
|
|
|
|
|
|
|
// 유틸리티: 연동 필드 그룹 ID 생성
|
|
|
|
|
export const generateLinkedFieldGroupId = (): string => {
|
|
|
|
|
return generateUniqueId("linked");
|
|
|
|
|
};
|
2025-12-18 15:19:59 +09:00
|
|
|
|
|
|
|
|
// 유틸리티: 테이블 컬럼 ID 생성
|
|
|
|
|
export const generateTableColumnId = (): string => {
|
|
|
|
|
return generateUniqueId("tcol");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 유틸리티: 컬럼 모드 ID 생성
|
|
|
|
|
export const generateColumnModeId = (): string => {
|
|
|
|
|
return generateUniqueId("mode");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 유틸리티: 필터 ID 생성
|
|
|
|
|
export const generateFilterId = (): string => {
|
|
|
|
|
return generateUniqueId("filter");
|
|
|
|
|
};
|
2025-12-28 19:32:13 +09:00
|
|
|
|
|
|
|
|
// 유틸리티: 조건부 테이블 옵션 ID 생성
|
|
|
|
|
export const generateConditionalOptionId = (): string => {
|
|
|
|
|
return generateUniqueId("cond");
|
|
|
|
|
};
|