165 lines
3.4 KiB
TypeScript
165 lines
3.4 KiB
TypeScript
/**
|
|
* 범용 폼 모달 컴포넌트 기본 설정
|
|
*/
|
|
|
|
import { UniversalFormModalConfig } from "./types";
|
|
|
|
// 기본 설정값
|
|
export const defaultConfig: UniversalFormModalConfig = {
|
|
modal: {
|
|
title: "데이터 입력",
|
|
description: "",
|
|
size: "lg",
|
|
closeOnOutsideClick: false,
|
|
showCloseButton: true,
|
|
saveButtonText: "저장",
|
|
cancelButtonText: "취소",
|
|
showResetButton: false,
|
|
resetButtonText: "초기화",
|
|
},
|
|
sections: [
|
|
{
|
|
id: "default",
|
|
title: "기본 정보",
|
|
description: "",
|
|
collapsible: false,
|
|
defaultCollapsed: false,
|
|
columns: 2,
|
|
gap: "16px",
|
|
fields: [],
|
|
repeatable: false,
|
|
},
|
|
],
|
|
saveConfig: {
|
|
tableName: "",
|
|
primaryKeyColumn: "id",
|
|
multiRowSave: {
|
|
enabled: false,
|
|
commonFields: [],
|
|
repeatSectionId: "",
|
|
typeColumn: "",
|
|
mainTypeValue: "main",
|
|
subTypeValue: "concurrent",
|
|
mainSectionFields: [],
|
|
},
|
|
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: "",
|
|
collapsible: false,
|
|
defaultCollapsed: false,
|
|
columns: 2,
|
|
gap: "16px",
|
|
fields: [],
|
|
repeatable: false,
|
|
repeatConfig: {
|
|
minItems: 0,
|
|
maxItems: 10,
|
|
addButtonText: "+ 추가",
|
|
removeButtonText: "삭제",
|
|
itemTitle: "항목 {index}",
|
|
confirmRemove: false,
|
|
},
|
|
linkedFieldGroups: [],
|
|
};
|
|
|
|
// 기본 연동 필드 그룹 설정
|
|
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: "",
|
|
};
|
|
|
|
// 기본 채번규칙 설정
|
|
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");
|
|
};
|
|
|
|
// 유틸리티: 연동 필드 그룹 ID 생성
|
|
export const generateLinkedFieldGroupId = (): string => {
|
|
return generateUniqueId("linked");
|
|
};
|