하석형 하석형 04-25
250425 하석형 관리자 메인으로 이동 시 메뉴선택 초기화, 메뉴트리 -> 메뉴배열로 스토어 저장 로직 추가
@2487284334378dd34f06544b22c795a54ccdbc37
 
client/resources/js/defaultMenuSatisfactionParams.js (added)
+++ client/resources/js/defaultMenuSatisfactionParams.js
@@ -0,0 +1,12 @@
+// 관리자 정보 객체
+const defaultMenuDgstfnParams = {
+  menuId: '',
+  rspnsFive: 'N',
+  rspnsFour: 'N',
+  rspnsThree: 'N',
+  rspnsTwo: 'N',
+  rspnsOne: 'N',
+  opnn: '',
+};
+
+export { defaultMenuDgstfnParams };(파일 끝에 줄바꿈 문자 없음)
client/views/layout/AdminHeader.vue
--- client/views/layout/AdminHeader.vue
+++ client/views/layout/AdminHeader.vue
@@ -64,10 +64,11 @@
     },
     watch: {
         'pgNm'(newValue,oldValue){
-            console.log(oldValue)
         },
         '$store.state.menu'(newValue) {
-            this.pgNm = newValue.menuNm
+            if(newValue) {
+                this.pgNm = newValue.menuNm
+            }
         },
 
     },
client/views/layout/AdminMenu.vue
--- client/views/layout/AdminMenu.vue
+++ client/views/layout/AdminMenu.vue
@@ -107,7 +107,7 @@
             if (menu.linkType === "0") {
                 // 현재창
                 this.$router.push({
-                path: menu.routerUrl,
+                    path: menu.routerUrl,
                 });
             } else if (menu.linkType === "1") {
                 // 새창
@@ -177,10 +177,21 @@
                 return formatted;
             });
         },
+
+        // 모든 메뉴 닫기
+        closeAllMenus(menus) {
+            for (const menu of menus) {
+                menu.isOpen = false;
+
+                if (Array.isArray(menu.childList) && menu.childList.length > 0) {
+                    this.closeAllMenus(menu.childList); // 재귀로 하위 메뉴까지 모두 닫기
+                }
+            }
+        }
     },
     watch: {
         // 나중에 네비게이션 가드에서 form 받을 수 있으면 form adm/main으로 갈때 sotre.state값0로 바꿔주기
-        $route(to) {
+        $route(to, from) {
             this.currentPath = to.path;
         },
         "$store.state.mbrNm"(newVal) {
@@ -193,7 +204,13 @@
                     this.menuCheck();
                 }
             }
-        }
+        },
+        '$store.state.menu'(newValue) {
+            if(!newValue) {
+                this.closeAllMenus(this.menuList);
+                this.activeMenus = [];
+            }
+        },
     }
 };
 </script>
client/views/layout/menuSatisfaction.vue
--- client/views/layout/menuSatisfaction.vue
+++ client/views/layout/menuSatisfaction.vue
@@ -48,12 +48,12 @@
         </div>
     </div>
     <div v-else>
-        <label class="form-title">[만족도 조사 비활성화 상태]</label>
     </div>
 </template>
 
 <script>
 import store from "../pages/AppStore.js";
+import { defaultMenuDgstfnParams } from '../../resources/js/defaultMenuSatisfactionParams.js';
 import { menuFindByMenu } from '../../resources/api/menu.js';
 import { findByMenuId, save } from '../../resources/api/menuDgstfn.js';
 
@@ -67,38 +67,30 @@
             dgstfnExmnUseYn: "N", // 메뉴 만족도 사용 여부
             rspnsYn: 'N', // 응답 여부
             checkRspns: '', // '5' ~ '1' 중 하나
-            menuDgstfn: {
-                rspnsFive: 'N',
-                rspnsFour: 'N',
-                rspnsThree: 'N',
-                rspnsTwo: 'N',
-                rspnsOne: 'N',
-                opnn: '', // 의견
-            }, // 메뉴 만족도
+            menuDgstfn: { ...defaultMenuDgstfnParams }, // 메뉴 만족도
         }
     },
     created() {
     },
     methods: {
         // 상세 조회
-        async fnView(menuId) {
+        async fnView() {
             try {
+                this.checkRspns = ''; // 응답 초기화
+                this.menuDgstfn = { ...defaultMenuDgstfnParams }; // 응답 초기화
                 const params = { menuId: this.menuId };
                 const res = await menuFindByMenu(params);
                 if (res.status == 200) {
                     this.dgstfnExmnUseYn = res.data.data.dgstfnExmnUseYn;
-
-                     // 부모에게 전달
-                    this.$emit('menuChecck', res.data.data.dgstfnExmnUseYn);
-
+                    
+                    this.$emit('menuChecck', this.dgstfnExmnUseYn);
                     if(res.data.data.dgstfnExmnUseYn == 'Y') {
                         this.fnViewByMenuId();
-                    } else {
-                        this.dgstfnExmnUseYn = 'N';
                     }
                 }
+                // 부모에게 전달
             } catch (error) {
-                alert(error.response.data.message);
+                alert(error.res.data.message);
             }
         },
 
@@ -115,7 +107,7 @@
                     }
                 }
             } catch (error) {
-                alert(error.response.data.message);
+                alert(error.res.data.message);
             }
         },
 
@@ -146,20 +138,20 @@
 
     },
     watch: {
-        'pgNm'(newValue, oldValue) {
-        },
         '$store.state.menu'(newValue) {
-            this.pgNm = newValue.menuNm
-            this.menuId = newValue.menuId
-            this.fnView();
+            if(newValue) {
+                this.pgNm = newValue.menuNm;
+                this.menuId = newValue.menuId;
+                this.fnView();
+            } else {
+                this.$emit('menuChecck', 'N');
+            }
         },
     },
     computed: {
-
         pgNm() {
             return store.state.menu && store.state.menu.menuNm ? store.state.menu.menuNm : "홈";
         }
-
     },
     mounted() {
 
client/views/pages/AppStore.js
--- client/views/pages/AppStore.js
+++ client/views/pages/AppStore.js
@@ -4,7 +4,7 @@
 
 export default createStore({
   plugins: [createPersistedState({
-    paths: ['loginMode', 'authorization', 'mbrId', 'mbrNm', 'roles', 'contextPath', 'pageAuth', 'menu']
+    paths: ['loginMode', 'authorization', 'mbrId', 'mbrNm', 'roles', 'contextPath', 'pageAuth']
   })],
   state: {
     authorization: null,
@@ -65,6 +65,21 @@
     },
     setMenuList(state, menuList) {
       state.menuList = menuList;
+      // 메뉴트리 펼치기
+      const flattenMenus = (menus) => {
+        const result = [];
+
+        for (const menu of menus) {
+          result.push(menu);
+          if (menu.childList?.length) {
+            result.push(...flattenMenus(menu.childList));
+          }
+        }
+
+        return result;
+      }
+      const flattenedMenuList = flattenMenus(menuList);
+      state.flatMenuList = flattenedMenuList;
     },
     setContextPath(state, ctx) {
       state.contextPath = ctx;
Add a comment
List