컴포넌트 잘림현상 수정
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { MenuItem, MenuFormData, menuApi, LangKey } from "@/lib/api/menu";
|
||||
import { companyAPI } from "@/lib/api/company";
|
||||
import { screenApi } from "@/lib/api/screen";
|
||||
import { screenApi, menuScreenApi } from "@/lib/api/screen";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
@@ -598,6 +598,48 @@ export const MenuFormModal: React.FC<MenuFormModalProps> = ({
|
||||
}
|
||||
|
||||
if (response.success) {
|
||||
// 화면 할당이 있는 경우 추가 처리
|
||||
if (urlType === "screen" && selectedScreen) {
|
||||
try {
|
||||
// menuId는 response에서 반환되거나 기존 menuId 사용
|
||||
const targetMenuId = menuId || response.data?.objid;
|
||||
const menuObjid = parseInt(targetMenuId?.toString() || "0");
|
||||
|
||||
if (menuObjid > 0) {
|
||||
console.log("📋 화면-메뉴 관계 테이블 업데이트 시작:", {
|
||||
screenId: selectedScreen.screenId,
|
||||
menuObjid,
|
||||
});
|
||||
|
||||
// 1. 기존 할당된 화면들 먼저 조회
|
||||
try {
|
||||
const existingScreens = await menuScreenApi.getScreensByMenu(menuObjid);
|
||||
console.log("📋 기존 할당된 화면:", existingScreens.length, "개");
|
||||
|
||||
// 2. 기존 화면들 모두 제거
|
||||
for (const existingScreen of existingScreens) {
|
||||
try {
|
||||
await menuScreenApi.unassignScreenFromMenu(existingScreen.screenId, menuObjid);
|
||||
console.log(`✅ 기존 화면 제거 완료: ${existingScreen.screenName}`);
|
||||
} catch (unassignError) {
|
||||
console.warn(`⚠️ 기존 화면 제거 실패: ${existingScreen.screenName}`, unassignError);
|
||||
}
|
||||
}
|
||||
} catch (getError) {
|
||||
console.warn("⚠️ 기존 화면 조회 실패 (계속 진행):", getError);
|
||||
}
|
||||
|
||||
// 3. 새 화면 할당
|
||||
await menuScreenApi.assignScreenToMenu(selectedScreen.screenId, menuObjid);
|
||||
console.log("✅ 새 화면 할당 완료");
|
||||
}
|
||||
} catch (assignError) {
|
||||
console.error("❌ 화면-메뉴 관계 테이블 할당 실패:", assignError);
|
||||
// 할당 실패는 경고만 하고 메뉴 저장은 성공으로 처리
|
||||
toast.warning("메뉴는 저장되었으나 화면 할당에 실패했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
toast.success(response.message);
|
||||
onSuccess();
|
||||
onClose();
|
||||
|
||||
Reference in New Issue
Block a user