Merge branch 'feature/v2-renewal' of http://39.117.244.52:3000/kjs/ERP-node into feature/v2-unified-renewal
This commit is contained in:
parent
f7dda7a666
commit
73b8a6f46d
|
|
@ -66,6 +66,33 @@ export function TabsWidget({
|
||||||
const [visibleTabs, setVisibleTabs] = useState<ExtendedTabItem[]>(tabs as ExtendedTabItem[]);
|
const [visibleTabs, setVisibleTabs] = useState<ExtendedTabItem[]>(tabs as ExtendedTabItem[]);
|
||||||
const [mountedTabs, setMountedTabs] = useState<Set<string>>(() => new Set([getInitialTab()]));
|
const [mountedTabs, setMountedTabs] = useState<Set<string>>(() => new Set([getInitialTab()]));
|
||||||
|
|
||||||
|
// 🆕 화면 진입 시 첫 번째 탭 자동 선택 및 마운트
|
||||||
|
useEffect(() => {
|
||||||
|
// 현재 선택된 탭이 유효하지 않거나 비어있으면 첫 번째 탭 선택
|
||||||
|
const validTabs = (tabs as ExtendedTabItem[]).filter((tab) => !tab.disabled);
|
||||||
|
const firstValidTabId = validTabs[0]?.id;
|
||||||
|
|
||||||
|
if (firstValidTabId) {
|
||||||
|
// 선택된 탭이 없거나 유효하지 않으면 첫 번째 탭으로 설정
|
||||||
|
setSelectedTab((currentSelected) => {
|
||||||
|
if (!currentSelected || !validTabs.some((t) => t.id === currentSelected)) {
|
||||||
|
return firstValidTabId;
|
||||||
|
}
|
||||||
|
return currentSelected;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 첫 번째 탭이 mountedTabs에 없으면 추가
|
||||||
|
setMountedTabs((prev) => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
// 첫 번째 탭 추가
|
||||||
|
if (firstValidTabId && !newSet.has(firstValidTabId)) {
|
||||||
|
newSet.add(firstValidTabId);
|
||||||
|
}
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [tabs]); // tabs가 변경될 때마다 실행
|
||||||
|
|
||||||
// screenId 기반 화면 로드 상태
|
// screenId 기반 화면 로드 상태
|
||||||
const [screenLayouts, setScreenLayouts] = useState<Record<string, ComponentData[]>>({});
|
const [screenLayouts, setScreenLayouts] = useState<Record<string, ComponentData[]>>({});
|
||||||
const [screenLoadingStates, setScreenLoadingStates] = useState<Record<string, boolean>>({});
|
const [screenLoadingStates, setScreenLoadingStates] = useState<Record<string, boolean>>({});
|
||||||
|
|
|
||||||
|
|
@ -1676,7 +1676,7 @@ export const SplitPanelLayoutComponent: React.FC<SplitPanelLayoutComponentProps>
|
||||||
// 커스텀 모달 화면 열기
|
// 커스텀 모달 화면 열기
|
||||||
const rightTableName = componentConfig.rightPanel?.tableName || "";
|
const rightTableName = componentConfig.rightPanel?.tableName || "";
|
||||||
|
|
||||||
// Primary Key 찾기 (우선순위: id > ID > 첫 번째 필드)
|
// Primary Key 찾기 (우선순위: id > ID > user_id > {table}_id > 첫 번째 필드)
|
||||||
let primaryKeyName = "id";
|
let primaryKeyName = "id";
|
||||||
let primaryKeyValue: any;
|
let primaryKeyValue: any;
|
||||||
|
|
||||||
|
|
@ -1686,12 +1686,23 @@ export const SplitPanelLayoutComponent: React.FC<SplitPanelLayoutComponentProps>
|
||||||
} else if (item.ID !== undefined && item.ID !== null) {
|
} else if (item.ID !== undefined && item.ID !== null) {
|
||||||
primaryKeyName = "ID";
|
primaryKeyName = "ID";
|
||||||
primaryKeyValue = item.ID;
|
primaryKeyValue = item.ID;
|
||||||
|
} else if (item.user_id !== undefined && item.user_id !== null) {
|
||||||
|
// user_info 테이블 등 user_id를 Primary Key로 사용하는 경우
|
||||||
|
primaryKeyName = "user_id";
|
||||||
|
primaryKeyValue = item.user_id;
|
||||||
} else {
|
} else {
|
||||||
// 첫 번째 필드를 Primary Key로 간주
|
// 테이블명_id 패턴 확인 (예: dept_id, item_id 등)
|
||||||
|
const tableIdKey = rightTableName ? `${rightTableName.replace(/_info$/, "")}_id` : "";
|
||||||
|
if (tableIdKey && item[tableIdKey] !== undefined && item[tableIdKey] !== null) {
|
||||||
|
primaryKeyName = tableIdKey;
|
||||||
|
primaryKeyValue = item[tableIdKey];
|
||||||
|
} else {
|
||||||
|
// 마지막으로 첫 번째 필드를 Primary Key로 간주
|
||||||
const firstKey = Object.keys(item)[0];
|
const firstKey = Object.keys(item)[0];
|
||||||
primaryKeyName = firstKey;
|
primaryKeyName = firstKey;
|
||||||
primaryKeyValue = item[firstKey];
|
primaryKeyValue = item[firstKey];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("✅ 수정 모달 열기:", {
|
console.log("✅ 수정 모달 열기:", {
|
||||||
tableName: rightTableName,
|
tableName: rightTableName,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue