diff --git a/src/layouts/DrawerComponent.vue b/src/layouts/DrawerComponent.vue index 2875fe13..8ede7546 100644 --- a/src/layouts/DrawerComponent.vue +++ b/src/layouts/DrawerComponent.vue @@ -29,7 +29,7 @@ const props = defineProps<{ }>(); const role = ref(); -const menuActive = ref([false, false, false, false, false]); +const menuActive = ref([]); const menuData = ref([]); const currentPath = computed(() => { return router.currentRoute.value.path; @@ -52,8 +52,6 @@ function navigateTo(label: string, destination?: string) { } function reActiveMenu() { - menuActive.value.fill(false); - const currMenu = menuData.value.find((m) => m.children?.some((c) => c.route === currentPath.value), ); @@ -87,6 +85,7 @@ watch( onMounted(async () => { const uid = getUserId(); + role.value = getRole(); if (!uid) return; @@ -98,98 +97,6 @@ onMounted(async () => { const result = await userBranch.fetchListMyBranch(uid); if (result && result.total > 0) currentMyBranch.value = result.result[0]; - // labelMenu.value = [ - // { - // label: 'menu.dashboard', - // icon: 'isax-element-35', - // route: '', - // isax: true, - // disabled: true, - // }, - // { - // label: 'menu.branch', - // icon: 'mdi-chart-donut', - // route: '/branch-management', - // hidden: - // role.value.includes('admin') || - // role.value.includes('branch_admin') || - // role.value.includes('head_of_admin') || - // role.value.includes('system') || - // role.value.includes('owner') || - // role.value.includes('head_of_account') - // ? false - // : true, - // }, - // { - // label: 'menu.user', - // icon: 'fa6-solid:building-user', - // route: '/personnel-management', - // hidden: - // role.value.includes('admin') || - // role.value.includes('branch_admin') || - // role.value.includes('head_of_admin') || - // role.value.includes('system') || - // role.value.includes('owner') || - // role.value.includes('branch_manager') - // ? false - // : true, - // }, - // { - // label: 'menu.customer', - // icon: 'isax-frame5', - // route: '/customer-management', - // isax: true, - // }, - // { - // label: 'menu.product', - // icon: 'heroicons-truck-solid', - // route: '/product-service', - // }, - // { - // label: 'menu.dms', - // icon: 'mdi-folder-file', - // route: '/document-management', - // }, - // { - // label: 'menu.quotation', - // icon: 'mdi-file-document', - // route: '/quotation', - // }, - // { - // label: 'menu.requestList', - // icon: 'isax-device-message5', - // route: '', - // disabled: true, - // isax: true, - // }, - // { - // label: 'menu.workOrder', - // icon: 'isax-receipt-2-15', - // route: '', - // disabled: true, - // isax: true, - // }, - // { - // label: 'menu.invoice', - // icon: 'material-symbols:box', - // route: '', - // disabled: true, - // }, - // { - // label: 'menu.accountingLedger', - // icon: 'isax-dollar-circle4', - // route: '', - // isax: true, - // disabled: true, - // }, - // { - // label: 'menu.report', - // icon: 'mdi-file-document', - // route: '', - // disabled: true, - // }, - // ]; - menuData.value = [ { label: 'menu.manage', @@ -267,6 +174,8 @@ onMounted(async () => { }, ]; + menuActive.value = menuData.value.map(() => false); + if (currentPath.value === '/') menuActive.value[0] = true; else reActiveMenu(); });