admin.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="admin--layout">
  3. <!-- Header -->
  4. <header class="admin--header">
  5. <div class="admin--header-left">
  6. <div class="admin--logo">
  7. <h1>AUDI</h1>
  8. <span class="admin--logo-sub">고진모터스</span>
  9. </div>
  10. </div>
  11. <div class="admin--header-right">
  12. <button class="admin--header-btn" @click="goToProfile">정보수정</button>
  13. <button
  14. type="button"
  15. class="admin--header-btn admin--header-btn-logout"
  16. @click.prevent="handleLogout"
  17. >
  18. 로그아웃
  19. </button>
  20. </div>
  21. </header>
  22. <!-- Main Content Area -->
  23. <div class="admin--content-wrapper">
  24. <!-- Sidebar GNB -->
  25. <aside class="admin--sidebar">
  26. <nav class="admin--gnb">
  27. <div v-for="menu in menuItems" :key="menu.id" class="admin--gnb-group">
  28. <div class="admin--gnb-title" @click="toggleMenu(menu.id)">
  29. {{ menu.title }}
  30. <span
  31. class="admin--gnb-arrow"
  32. :class="{ 'is-open': openMenus.includes(menu.id) }"
  33. >
  34. </span>
  35. </div>
  36. <transition name="admin--submenu">
  37. <ul v-show="openMenus.includes(menu.id)" class="admin--gnb-submenu">
  38. <li
  39. v-for="submenu in menu.children"
  40. :key="submenu.path"
  41. class="admin--gnb-item"
  42. :class="{ 'is-active': isActiveRoute(submenu.path) }"
  43. >
  44. <NuxtLink :to="submenu.path" class="admin--gnb-link">
  45. {{ submenu.title }}
  46. </NuxtLink>
  47. </li>
  48. </ul>
  49. </transition>
  50. </div>
  51. </nav>
  52. </aside>
  53. <!-- Content Area -->
  54. <main class="admin--main">
  55. <!-- Breadcrumb & Title -->
  56. <div class="admin--page-header">
  57. <h2 class="admin--page-title">{{ pageTitle }}</h2>
  58. <div class="admin--breadcrumb">
  59. <span v-for="(crumb, index) in breadcrumbs" :key="index">
  60. <NuxtLink v-if="crumb.path" :to="crumb.path" class="admin--breadcrumb-link">
  61. {{ crumb.title }}
  62. </NuxtLink>
  63. <span v-else class="admin--breadcrumb-current">{{ crumb.title }}</span>
  64. <span
  65. v-if="index < breadcrumbs.length - 1"
  66. class="admin--breadcrumb-separator"
  67. >/</span
  68. >
  69. </span>
  70. </div>
  71. </div>
  72. <!-- Page Content -->
  73. <div class="admin--page-content">
  74. <slot />
  75. </div>
  76. <!-- Admin Footer -->
  77. <footer class="admin--footer">
  78. <p>
  79. &copy; {{ new Date().getFullYear() }} Audi 고진모터스. All rights reserved.
  80. </p>
  81. </footer>
  82. </main>
  83. </div>
  84. <!-- 로그아웃 확인 모달 -->
  85. <AdminAlertModal
  86. v-if="showLogoutModal"
  87. title="로그아웃"
  88. message="로그아웃 하시겠습니까?"
  89. type="confirm"
  90. @confirm="confirmLogout"
  91. @cancel="closeLogoutModal"
  92. @close="closeLogoutModal"
  93. />
  94. </div>
  95. </template>
  96. <script setup>
  97. import { ref, computed } from "vue";
  98. import { useRoute, useRouter } from "vue-router";
  99. import AdminAlertModal from "~/components/admin/AdminAlertModal.vue";
  100. const route = useRoute();
  101. const router = useRouter();
  102. // 메뉴 열림 상태 관리
  103. const openMenus = ref(["basic", "branch", "staff", "service", "board", "system"]);
  104. // GNB 메뉴 구조
  105. const menuItems = ref([
  106. {
  107. id: "basic",
  108. title: "기본정보관리",
  109. children: [
  110. { title: "사이트 정보", path: "/admin/basic/site-info" },
  111. { title: "팝업관리", path: "/admin/basic/popup" },
  112. ],
  113. },
  114. {
  115. id: "branch",
  116. title: "지점장관리",
  117. children: [
  118. { title: "지점목록", path: "/admin/branch/list" },
  119. { title: "지점장목록", path: "/admin/branch/manager" },
  120. ],
  121. },
  122. {
  123. id: "staff",
  124. title: "사원관리",
  125. children: [
  126. { title: "영업사원관리", path: "/admin/staff/sales" },
  127. { title: "어드바이저등록", path: "/admin/staff/advisor" },
  128. ],
  129. },
  130. // {
  131. // id: 'service',
  132. // title: '서비스관리',
  133. // children: [
  134. // { title: '브로셔요청', path: '/admin/service/brochure' }
  135. // ]
  136. // },
  137. {
  138. id: "board",
  139. title: "게시판관리",
  140. children: [
  141. { title: "이벤트", path: "/admin/board/event" },
  142. { title: "뉴스", path: "/admin/board/news" },
  143. { title: "IR", path: "/admin/board/ir" },
  144. ],
  145. },
  146. {
  147. id: "system",
  148. title: "시스템관리",
  149. children: [{ title: "관리자관리", path: "/admin/admins" }],
  150. },
  151. ]);
  152. // 메뉴 토글
  153. const toggleMenu = (menuId) => {
  154. const index = openMenus.value.indexOf(menuId);
  155. if (index > -1) {
  156. openMenus.value.splice(index, 1);
  157. } else {
  158. openMenus.value.push(menuId);
  159. }
  160. };
  161. // 현재 활성 라우트 체크
  162. const isActiveRoute = (path) => {
  163. return route.path === path;
  164. };
  165. // 페이지 타이틀 계산
  166. const pageTitle = computed(() => {
  167. for (const menu of menuItems.value) {
  168. const found = menu.children.find((child) => child.path === route.path);
  169. if (found) return found.title;
  170. }
  171. return "대시보드";
  172. });
  173. // Breadcrumb 계산
  174. const breadcrumbs = computed(() => {
  175. const crumbs = [{ title: "Home", path: "/admin/dashboard" }];
  176. for (const menu of menuItems.value) {
  177. const found = menu.children.find((child) => child.path === route.path);
  178. if (found) {
  179. crumbs.push({ title: menu.title, path: null });
  180. crumbs.push({ title: found.title, path: null });
  181. break;
  182. }
  183. }
  184. return crumbs;
  185. });
  186. // 로그아웃 모달
  187. const showLogoutModal = ref(false);
  188. const handleLogout = () => {
  189. console.log("[Logout] 로그아웃 버튼 클릭");
  190. showLogoutModal.value = true;
  191. console.log("[Logout] showLogoutModal:", showLogoutModal.value);
  192. };
  193. const confirmLogout = () => {
  194. console.log("[Logout] 로그아웃 확인");
  195. localStorage.removeItem("admin_token");
  196. localStorage.removeItem("admin_user");
  197. router.push("/admin");
  198. };
  199. const closeLogoutModal = () => {
  200. console.log("[Logout] 모달 닫기");
  201. showLogoutModal.value = false;
  202. };
  203. // 정보수정
  204. const goToProfile = () => {
  205. router.push("/admin/profile");
  206. };
  207. </script>