This commit is contained in:
Viet An
2026-06-11 22:08:17 +07:00
parent a1450c7bde
commit a4f71ddb90
7 changed files with 74 additions and 47 deletions

View File

@@ -127,16 +127,16 @@ const route = useRoute();
const emit = defineEmits(["changeTab"]);
const { $find, $filter, $store, $snackbar } = useNuxtApp();
const lang = computed(() => $store.lang);
const menu = $filter($store.common, { category: "topmenu" });
const topmenus = $filter($store.common, { category: "topmenu" });
const submenus = $filter($store.common, { category: "submenu" });
// if($store.rights.length>0) {
// menu = menu.filter(v=>$findIndex($store.rights, {setting: v.id})>=0)
// }
if (menu.length === 0) {
if (topmenus.length === 0) {
$snackbar($store.lang === "vi" ? "Bạn không có quyền truy cập" : "You do not have permission to access.");
}
menu.forEach((topmenu) => {
topmenus.forEach((topmenu) => {
let submenus = $filter($store.common, { category: "submenu", classify: topmenu.code });
if ($store.rights.length > 0) {
submenus = submenus.filter((x) => $findIndex($store.rights, { setting: x.id }) >= 0);
@@ -144,10 +144,10 @@ menu.forEach((topmenu) => {
topmenu.submenu = submenus.length > 0 ? submenus : null;
});
const leftmenu = $filter(menu, { category: "topmenu", classify: "left" });
const leftmenu = $filter(topmenus, { category: "topmenu", classify: "left" });
const currentTab = ref(leftmenu[0]);
const subTab = ref();
const tabConfig = $find(menu, { code: "configuration" });
const tabConfig = $find(topmenus, { code: "configuration" });
const avatar = ref();
const isAdmin = computed(() => $store.login.type__code === "admin");
@@ -175,8 +175,12 @@ function changeTab(tab, subtab) {
subTab.value = subtab;
emit("changeTab", tab, subtab);
closeMenu();
const query = subtab ? { tab: tab.code, subtab: subtab.code } : { tab: tab.code };
router.push({ query });
router.push({
query: {
tab: tab.code,
subtab: subtab?.code,
},
});
}
function openProfile() {
$store.commit("showmodal", {
@@ -186,7 +190,7 @@ function openProfile() {
title: $store.lang === "vi" ? "Thông tin cá nhân" : "User profile",
});
}
const foundTab = route.query.tab && $find(menu, { code: route.query.tab });
const foundTab = route.query.tab && $find(topmenus, { code: route.query.tab });
const foundSub = route.query.subtab && $find(submenus, { code: route.query.subtab });
if (foundTab || currentTab.value) changeTab(foundTab || currentTab.value, foundSub);