
250425 하석형 관리자 메인으로 이동 시 메뉴선택 초기화, 메뉴트리 -> 메뉴배열로 스토어 저장 로직 추가
@2487284334378dd34f06544b22c795a54ccdbc37
+++ client/resources/js/defaultMenuSatisfactionParams.js
... | ... | @@ -0,0 +1,12 @@ |
1 | +// 관리자 정보 객체 | |
2 | +const defaultMenuDgstfnParams = { | |
3 | + menuId: '', | |
4 | + rspnsFive: 'N', | |
5 | + rspnsFour: 'N', | |
6 | + rspnsThree: 'N', | |
7 | + rspnsTwo: 'N', | |
8 | + rspnsOne: 'N', | |
9 | + opnn: '', | |
10 | +}; | |
11 | + | |
12 | +export { defaultMenuDgstfnParams };(파일 끝에 줄바꿈 문자 없음) |
--- client/views/layout/AdminHeader.vue
+++ client/views/layout/AdminHeader.vue
... | ... | @@ -64,10 +64,11 @@ |
64 | 64 |
}, |
65 | 65 |
watch: { |
66 | 66 |
'pgNm'(newValue,oldValue){ |
67 |
- console.log(oldValue) |
|
68 | 67 |
}, |
69 | 68 |
'$store.state.menu'(newValue) { |
70 |
- this.pgNm = newValue.menuNm |
|
69 |
+ if(newValue) { |
|
70 |
+ this.pgNm = newValue.menuNm |
|
71 |
+ } |
|
71 | 72 |
}, |
72 | 73 |
|
73 | 74 |
}, |
--- client/views/layout/AdminMenu.vue
+++ client/views/layout/AdminMenu.vue
... | ... | @@ -107,7 +107,7 @@ |
107 | 107 |
if (menu.linkType === "0") { |
108 | 108 |
// 현재창 |
109 | 109 |
this.$router.push({ |
110 |
- path: menu.routerUrl, |
|
110 |
+ path: menu.routerUrl, |
|
111 | 111 |
}); |
112 | 112 |
} else if (menu.linkType === "1") { |
113 | 113 |
// 새창 |
... | ... | @@ -177,10 +177,21 @@ |
177 | 177 |
return formatted; |
178 | 178 |
}); |
179 | 179 |
}, |
180 |
+ |
|
181 |
+ // 모든 메뉴 닫기 |
|
182 |
+ closeAllMenus(menus) { |
|
183 |
+ for (const menu of menus) { |
|
184 |
+ menu.isOpen = false; |
|
185 |
+ |
|
186 |
+ if (Array.isArray(menu.childList) && menu.childList.length > 0) { |
|
187 |
+ this.closeAllMenus(menu.childList); // 재귀로 하위 메뉴까지 모두 닫기 |
|
188 |
+ } |
|
189 |
+ } |
|
190 |
+ } |
|
180 | 191 |
}, |
181 | 192 |
watch: { |
182 | 193 |
// 나중에 네비게이션 가드에서 form 받을 수 있으면 form adm/main으로 갈때 sotre.state값0로 바꿔주기 |
183 |
- $route(to) { |
|
194 |
+ $route(to, from) { |
|
184 | 195 |
this.currentPath = to.path; |
185 | 196 |
}, |
186 | 197 |
"$store.state.mbrNm"(newVal) { |
... | ... | @@ -193,7 +204,13 @@ |
193 | 204 |
this.menuCheck(); |
194 | 205 |
} |
195 | 206 |
} |
196 |
- } |
|
207 |
+ }, |
|
208 |
+ '$store.state.menu'(newValue) { |
|
209 |
+ if(!newValue) { |
|
210 |
+ this.closeAllMenus(this.menuList); |
|
211 |
+ this.activeMenus = []; |
|
212 |
+ } |
|
213 |
+ }, |
|
197 | 214 |
} |
198 | 215 |
}; |
199 | 216 |
</script> |
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
|
5 | 5 |
export default createStore({ |
6 | 6 |
plugins: [createPersistedState({ |
7 |
- paths: ['loginMode', 'authorization', 'mbrId', 'mbrNm', 'roles', 'contextPath', 'pageAuth', 'menu'] |
|
7 |
+ paths: ['loginMode', 'authorization', 'mbrId', 'mbrNm', 'roles', 'contextPath', 'pageAuth'] |
|
8 | 8 |
})], |
9 | 9 |
state: { |
10 | 10 |
authorization: null, |
... | ... | @@ -65,6 +65,21 @@ |
65 | 65 |
}, |
66 | 66 |
setMenuList(state, menuList) { |
67 | 67 |
state.menuList = menuList; |
68 |
+ // 메뉴트리 펼치기 |
|
69 |
+ const flattenMenus = (menus) => { |
|
70 |
+ const result = []; |
|
71 |
+ |
|
72 |
+ for (const menu of menus) { |
|
73 |
+ result.push(menu); |
|
74 |
+ if (menu.childList?.length) { |
|
75 |
+ result.push(...flattenMenus(menu.childList)); |
|
76 |
+ } |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ return result; |
|
80 |
+ } |
|
81 |
+ const flattenedMenuList = flattenMenus(menuList); |
|
82 |
+ state.flatMenuList = flattenedMenuList; |
|
68 | 83 |
}, |
69 | 84 |
setContextPath(state, ctx) { |
70 | 85 |
state.contextPath = ctx; |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?