Merge branch 'feature/v2-renewal' of http://39.117.244.52:3000/kjs/ERP-node into feat/multilang
This commit is contained in:
commit
98870b3348
|
|
@ -78,7 +78,7 @@ import {
|
||||||
deleteFieldJoin,
|
deleteFieldJoin,
|
||||||
FieldJoin,
|
FieldJoin,
|
||||||
} from "@/lib/api/screenGroup";
|
} from "@/lib/api/screenGroup";
|
||||||
import { tableManagementApi, ColumnTypeInfo, TableInfo } from "@/lib/api/tableManagement";
|
import { tableManagementApi, ColumnTypeInfo, TableInfo, ColumnSettings } from "@/lib/api/tableManagement";
|
||||||
import { screenApi } from "@/lib/api/screen";
|
import { screenApi } from "@/lib/api/screen";
|
||||||
import { INPUT_TYPE_OPTIONS } from "@/types/input-types";
|
import { INPUT_TYPE_OPTIONS } from "@/types/input-types";
|
||||||
import TableManagementPage from "@/app/(main)/admin/systemMng/tableMngList/page";
|
import TableManagementPage from "@/app/(main)/admin/systemMng/tableMngList/page";
|
||||||
|
|
@ -434,22 +434,97 @@ export function TableSettingModal({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 전체 저장
|
// 전체 저장 (테이블타입관리 페이지와 동일한 로직)
|
||||||
const handleSaveAll = async () => {
|
const handleSaveAll = async () => {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
// 각 컬럼 설정 저장
|
// 변경된 컬럼들만 저장
|
||||||
for (const [columnName, settings] of Object.entries(editedColumns)) {
|
for (const [columnName, editedSettings] of Object.entries(editedColumns)) {
|
||||||
await tableManagementApi.updateColumnSettings(tableName, columnName, {
|
// 기존 컬럼 정보 찾기
|
||||||
column_label: settings.displayName || "",
|
const originalColumn = tableColumns.find((c) => c.columnName === columnName);
|
||||||
input_type: (settings.inputType as string) || "text",
|
if (!originalColumn) continue;
|
||||||
reference_table: settings.referenceTable || null,
|
|
||||||
reference_column: settings.referenceColumn || null,
|
// 기존 값과 편집된 값 병합
|
||||||
display_column: settings.displayColumn || null,
|
const mergedColumn = {
|
||||||
});
|
...originalColumn,
|
||||||
|
...editedSettings,
|
||||||
|
};
|
||||||
|
|
||||||
|
// detailSettings 처리 (Entity 타입인 경우)
|
||||||
|
let finalDetailSettings = mergedColumn.detailSettings || "";
|
||||||
|
|
||||||
|
if (mergedColumn.inputType === "entity" && mergedColumn.referenceTable) {
|
||||||
|
// 기존 detailSettings를 파싱하거나 새로 생성
|
||||||
|
let existingSettings: Record<string, unknown> = {};
|
||||||
|
if (typeof mergedColumn.detailSettings === "string" && mergedColumn.detailSettings.trim().startsWith("{")) {
|
||||||
|
try {
|
||||||
|
existingSettings = JSON.parse(mergedColumn.detailSettings);
|
||||||
|
} catch {
|
||||||
|
existingSettings = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 엔티티 설정 추가
|
||||||
|
const entitySettings = {
|
||||||
|
...existingSettings,
|
||||||
|
entityTable: mergedColumn.referenceTable,
|
||||||
|
entityCodeColumn: mergedColumn.referenceColumn || "id",
|
||||||
|
entityLabelColumn: mergedColumn.displayColumn || "name",
|
||||||
|
placeholder: (existingSettings.placeholder as string) || "항목을 선택하세요",
|
||||||
|
searchable: existingSettings.searchable ?? true,
|
||||||
|
};
|
||||||
|
|
||||||
|
finalDetailSettings = JSON.stringify(entitySettings);
|
||||||
|
console.log("Entity 설정 JSON 생성:", entitySettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code 타입인 경우 hierarchyRole을 detailSettings에 포함
|
||||||
|
if (mergedColumn.inputType === "code" && (mergedColumn as any).hierarchyRole) {
|
||||||
|
let existingSettings: Record<string, unknown> = {};
|
||||||
|
if (typeof finalDetailSettings === "string" && finalDetailSettings.trim().startsWith("{")) {
|
||||||
|
try {
|
||||||
|
existingSettings = JSON.parse(finalDetailSettings);
|
||||||
|
} catch {
|
||||||
|
existingSettings = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const codeSettings = {
|
||||||
|
...existingSettings,
|
||||||
|
hierarchyRole: (mergedColumn as any).hierarchyRole,
|
||||||
|
};
|
||||||
|
|
||||||
|
finalDetailSettings = JSON.stringify(codeSettings);
|
||||||
|
console.log("Code 계층 역할 설정 JSON 생성:", codeSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ColumnSettings 인터페이스에 맞게 데이터 구성
|
||||||
|
const columnSetting: ColumnSettings = {
|
||||||
|
columnName: columnName,
|
||||||
|
columnLabel: mergedColumn.displayName || originalColumn.displayName || "",
|
||||||
|
webType: mergedColumn.inputType || originalColumn.inputType || "text",
|
||||||
|
detailSettings: finalDetailSettings,
|
||||||
|
codeCategory: mergedColumn.codeCategory || originalColumn.codeCategory || "",
|
||||||
|
codeValue: mergedColumn.codeValue || originalColumn.codeValue || "",
|
||||||
|
referenceTable: mergedColumn.referenceTable || "",
|
||||||
|
referenceColumn: mergedColumn.referenceColumn || "",
|
||||||
|
displayColumn: mergedColumn.displayColumn || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("저장할 컬럼 설정:", columnSetting);
|
||||||
|
|
||||||
|
// API 호출
|
||||||
|
const response = await tableManagementApi.updateColumnSettings(tableName, columnName, columnSetting);
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
console.error(`컬럼 '${columnName}' 저장 실패:`, response.message);
|
||||||
|
toast.error(`컬럼 '${columnName}' 저장 실패: ${response.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success("테이블 설정이 저장되었습니다.");
|
toast.success("테이블 설정이 저장되었습니다.");
|
||||||
|
setEditedColumns({}); // 편집 상태 초기화
|
||||||
onSaveSuccess?.();
|
onSaveSuccess?.();
|
||||||
await loadTableData();
|
await loadTableData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -461,3 +461,4 @@ export default function DataFlowPanel({ groupId, screenId, screens = [] }: DataF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -413,3 +413,4 @@ export default function FieldJoinPanel({ screenId, componentId, layoutId }: Fiel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue