| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <section class="left-menu" :class="[shortType ? 'short' : '']">
- <div class="left-menu-user">
- <h1 class="logo"><span style="cursor: pointer" @click="fnMoveHome()">P5G</span></h1>
- <div class="user">
- <i class="ico"></i>
- <span class="type">{{ useAuthStore().getAccountId }}</span>
- <!-- <span class="name">{{ useAuthStore().getAccountName }}</span> -->
- </div>
- </div>
- <nav class="left-navi">
- <ul class="depth1" v-if="shortType == false">
- <li
- v-for="(item, index) in arrMenuLists"
- :key="index"
- :id="'menu_' + item.menu_seq"
- :class="item.menu_url.indexOf(currentTopMenuLocation) > -1 ? 'active' : ''"
- >
- <span class="menu-name" @click="fnMenuEvent(item)"
- ><i :class="'ico ico' + (index + 1)"></i>{{ item.menu_nm }}</span
- >
- <div
- class="depth2"
- :style="
- item.menu_url.indexOf(currentTopMenuLocation) > -1
- ? 'display: block'
- : 'display: none'
- "
- >
- <ul>
- <li
- v-for="(itemSub, indexSub) in item.sub"
- :key="indexSub"
- @click="fnMenuEvent(itemSub)"
- :class="currentMenuLocation == itemSub.menu_url ? 'active' : ''"
- >
- {{ itemSub.menu_nm }}
- </li>
- </ul>
- </div>
- </li>
- </ul>
- <!-- <ul class="depth1" v-else>
- <li v-for="(item, index) in arrMenuLists" :key="index" :id="'menu_'+item.menu_seq" :class="item.menu_url.indexOf(currentTopMenuLocation) > -1 ? 'active' : ''">
- <span class="menu-name" @click="focusIn(index)"><i :class="'ico ico'+(index+1)"></i></span>
- <div class="depth2">
- <strong>{{item.menu_nm}}</strong>
- <ul>
- <li v-for="(itemSub, indexSub) in item.sub" :key="indexSub" @click="fnMenuEvent(itemSub)" :class="currentMenuLocation == itemSub.menu_url ? 'active' : ''">{{itemSub.menu_nm}}</li>
- </ul>
- </div>
- </li>
- </ul> -->
- <ul class="depth1" v-else>
- <li
- v-for="(item, index) in arrMenuLists"
- style="width: 62px"
- :key="index"
- @mouseover="focusIn(index)"
- @mouseleave="twoDept = null"
- :id="'menu_' + item.menu_seq"
- :class="item.menu_url.indexOf(currentTopMenuLocation) > -1 ? 'active' : ''"
- >
- <span class="menu-name"><i :class="'ico ico' + (index + 1)"></i></span>
- <div
- v-if="twoDept == index"
- class="depth2"
- @mouseover="focusIn(index)"
- style="display: block"
- >
- <strong>{{ item.menu_nm }}</strong>
- <ul>
- <li
- v-for="(itemSub, indexSub) in item.sub"
- :key="indexSub"
- @click="fnMenuEvent(itemSub)"
- :class="currentMenuLocation == itemSub.menu_url ? 'active' : ''"
- >
- {{ itemSub.menu_nm }}
- </li>
- </ul>
- </div>
- </li>
- </ul>
- </nav>
- <div class="left-btm">
- <v-btn
- class="custom-btn btn-white"
- v-if="shortType == false"
- @click="logoutPop = true"
- >로그아웃</v-btn
- >
- <button
- style="visibility: hidden"
- class="btn-logout"
- v-else
- @click="logoutPop = true"
- ></button>
- <v-btn
- class="custom-btn btn-white btn-back"
- @click="shortType = !shortType"
- ></v-btn>
- </div>
- </section>
- <v-dialog v-model="logoutPop" persistent width="350">
- <div class="v-common-dialog-wrapper custom-dialog">
- <strong class="modal-tit"> </strong>
- <div class="v-common-dialog-content">
- <p class="modal-txt">시스템에서 로그아웃 하시겠습니까?</p>
- </div>
- <div class="btn-wrap">
- <v-btn class="custom-btn btn-white" @click="logoutPop = false"> 취소 </v-btn>
- <v-btn @click="fnLogout()" class="custom-btn btn-purple"> 확인 </v-btn>
- </div>
- </div>
- </v-dialog>
- </template>
- <script setup>
- /************************
- * import
- ************************/
- import { useRoute } from "vue-router";
- import useAxios from "~/composables/useAxios";
- import useErrorHandler from "~/composables/useErrorHandler";
- /************************
- * plugins inject
- ************************/
- const { $dayjs, $log, $eventBus, $toast } = useNuxtApp();
- const route = useRoute();
- /************************
- * data & created
- ************************/
- let pageId = "leftMenu";
- let logoutPop = ref(false);
- let arrMenuLists = ref([]);
- let currentTopMenuLocation = ref("");
- let currentMenuLocation = ref("");
- let shortType = ref(false);
- let twoDept = ref(null);
- /***********
- * watch
- ***********/
- watch(
- route,
- (newv, oldv) => {
- let arrPaths = newv.path.split("/").filter((str) => str !== "");
- currentTopMenuLocation.value = `/${arrPaths[0]}`;
- currentMenuLocation.value = `/${arrPaths[0]}/${arrPaths[1]}`;
- },
- { deep: true, immediate: true }
- );
- /************************
- * Methods
- ************************/
- // 메뉴 목록 조회하기
- function fnGetMenu() {
- console.log("%c [print][]", "color:#10cdbc", "좌측메뉴 조회하기");
- useAxios()
- .post("/menu/selectMenuList")
- .then((res) => {
- $log.debug("[leftMenu][fnGetMenu][success]");
- let arrRes = res.data.data;
- arrRes.forEach((item, index) => {
- if (item.p_menu_seq == 0) {
- item.sub = [];
- arrMenuLists.value.push(item);
- }
- });
- arrMenuLists.value.forEach((item, index) => {
- arrRes.forEach((itemSub, indexSub) => {
- if (item.menu_seq == itemSub.p_menu_seq) {
- if (arrMenuLists.value[index].menu_url == "") {
- arrMenuLists.value[index].menu_url = itemSub.menu_url;
- }
- arrMenuLists.value[index].sub.push(itemSub);
- }
- });
- });
- })
- .catch((error) => {
- $log.debug("[leftMenu][fnGetMenu][error]");
- useErrorHandler().fnSetCommErrorHandle(error, fnGetMenu);
- })
- .finally(() => {
- $log.debug("[leftMenu][fnGetMenu][finished]");
- });
- }
- // 메뉴 이벤트 처리
- function fnMenuEvent(obj) {
- if (obj.p_menu_seq == 0) {
- // top menu
- $(".depth1 > li").removeClass("active");
- $(".depth2").hide();
- let elTopMenu = $("#menu_" + obj.menu_seq);
- if (elTopMenu.hasClass("active")) {
- elTopMenu.removeClass("active");
- elTopMenu.find(".depth2").hide();
- } else {
- elTopMenu.addClass("active");
- if (obj.sub && obj.sub.length > 0) {
- elTopMenu.find(".depth2").show();
- }
- }
- } else {
- // sub menu
- useUtil.setPageMove(obj.menu_url);
- }
- }
- function focusIn(idx) {
- /*for(let i = 0; i < document.getElementsByClassName("depth2").length; i++){
- document.getElementsByClassName("depth2")[i].style.display = "none"
- }*/
- // if(document.getElementsByClassName("depth2")[idx].style.display == 'block'){
- // document.getElementsByClassName("depth2")[idx].style.display = "none"
- // }else{
- // for(let i = 0; i < document.getElementsByClassName("depth2").length; i++){
- // document.getElementsByClassName("depth2")[i].style.display = "none"
- // }
- // document.getElementsByClassName("depth2")[idx].style.display = "block"
- // }
- twoDept.value = idx;
- }
- // 메인 화면으로 이동
- function fnMoveHome() {
- useUtil.setPageMove(useAuthStore().getRedirectPage);
- }
- // 로그아웃
- function fnLogout() {
- localStorage.removeItem("authStore");
- useAuthStore().setLogout();
- useUtil.setPageMove("/");
- }
- </script>
- <style lang="scss" scoped></style>
|