Merge pull request '분할패널 수정버튼 동작하게 수정' (#344) from feature/screen-management into main

Reviewed-on: http://39.117.244.52:3000/kjs/ERP-node/pulls/344
This commit is contained in:
kjs 2026-01-08 17:37:15 +09:00
commit 65e1c1a995
1 changed files with 9 additions and 30 deletions

View File

@ -1451,27 +1451,8 @@ export const SplitPanelLayoutComponent: React.FC<SplitPanelLayoutComponentProps>
// 커스텀 모달 화면 열기 // 커스텀 모달 화면 열기
const rightTableName = componentConfig.rightPanel?.tableName || ""; const rightTableName = componentConfig.rightPanel?.tableName || "";
// Primary Key 찾기 (우선순위: id > ID > 첫 번째 필드)
let primaryKeyName = "id";
let primaryKeyValue: any;
if (item.id !== undefined && item.id !== null) {
primaryKeyName = "id";
primaryKeyValue = item.id;
} else if (item.ID !== undefined && item.ID !== null) {
primaryKeyName = "ID";
primaryKeyValue = item.ID;
} else {
// 첫 번째 필드를 Primary Key로 간주
const firstKey = Object.keys(item)[0];
primaryKeyName = firstKey;
primaryKeyValue = item[firstKey];
}
console.log("✅ 수정 모달 열기:", { console.log("✅ 수정 모달 열기:", {
tableName: rightTableName, tableName: rightTableName,
primaryKeyName,
primaryKeyValue,
screenId: modalScreenId, screenId: modalScreenId,
fullItem: item, fullItem: item,
}); });
@ -1490,27 +1471,25 @@ export const SplitPanelLayoutComponent: React.FC<SplitPanelLayoutComponentProps>
hasGroupByColumns: groupByColumns.length > 0, hasGroupByColumns: groupByColumns.length > 0,
}); });
// ScreenModal 열기 이벤트 발생 (URL 파라미터로 ID + groupByColumns 전달) // 🔧 수정: URL 파라미터 대신 editData로 직접 전달
// 이렇게 하면 테이블의 Primary Key가 무엇이든 상관없이 데이터가 정확히 전달됨
window.dispatchEvent( window.dispatchEvent(
new CustomEvent("openScreenModal", { new CustomEvent("openScreenModal", {
detail: { detail: {
screenId: modalScreenId, screenId: modalScreenId,
urlParams: { editData: item, // 전체 데이터를 직접 전달
mode: "edit", ...(groupByColumns.length > 0 && {
editId: primaryKeyValue, urlParams: {
tableName: rightTableName,
...(groupByColumns.length > 0 && {
groupByColumns: JSON.stringify(groupByColumns), groupByColumns: JSON.stringify(groupByColumns),
}), },
}, }),
}, },
}), }),
); );
console.log("✅ [SplitPanel] openScreenModal 이벤트 발생:", { console.log("✅ [SplitPanel] openScreenModal 이벤트 발생 (editData 직접 전달):", {
screenId: modalScreenId, screenId: modalScreenId,
editId: primaryKeyValue, editData: item,
tableName: rightTableName,
groupByColumns: groupByColumns.length > 0 ? JSON.stringify(groupByColumns) : "없음", groupByColumns: groupByColumns.length > 0 ? JSON.stringify(groupByColumns) : "없음",
}); });