refactor: role admin view
This commit is contained in:
parent
b2290ddf0e
commit
8286ea19b9
2 changed files with 201 additions and 168 deletions
|
|
@ -10,39 +10,22 @@ defineProps<{
|
||||||
mini?: boolean;
|
mini?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const role = ref();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const uid = getUserId();
|
const uid = getUserId();
|
||||||
const role = getRole();
|
role.value = getRole();
|
||||||
|
|
||||||
if (!uid) return;
|
if (!uid) return;
|
||||||
|
|
||||||
if (role?.includes('system')) {
|
if (role.value.includes('system')) {
|
||||||
const result = await userBranch.fetchListOptionBranch();
|
const result = await userBranch.fetchListOptionBranch();
|
||||||
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
||||||
}
|
}
|
||||||
const result = await userBranch.fetchListMyBranch(uid);
|
const result = await userBranch.fetchListMyBranch(uid);
|
||||||
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
if (result && result.total > 0) currentMyBranch.value = result.result[0];
|
||||||
});
|
|
||||||
|
|
||||||
const router = useRouter();
|
labelMenu.value = [
|
||||||
const userBranch = useMyBranch();
|
|
||||||
const { currentMyBranch } = storeToRefs(userBranch);
|
|
||||||
|
|
||||||
const currentRoute = ref<string>('');
|
|
||||||
const currentPath = computed(() => {
|
|
||||||
return router.currentRoute.value.path;
|
|
||||||
});
|
|
||||||
|
|
||||||
const labelMenu = ref<
|
|
||||||
{
|
|
||||||
label: string;
|
|
||||||
icon: string;
|
|
||||||
route: string;
|
|
||||||
hidden?: boolean;
|
|
||||||
disabled?: boolean;
|
|
||||||
isax?: boolean;
|
|
||||||
}[]
|
|
||||||
>([
|
|
||||||
{
|
{
|
||||||
label: 'drawerDashboard',
|
label: 'drawerDashboard',
|
||||||
icon: 'isax-element-35',
|
icon: 'isax-element-35',
|
||||||
|
|
@ -54,11 +37,23 @@ const labelMenu = ref<
|
||||||
label: 'drawerBranchManagement',
|
label: 'drawerBranchManagement',
|
||||||
icon: 'mdi-chart-donut',
|
icon: 'mdi-chart-donut',
|
||||||
route: '/branch-management',
|
route: '/branch-management',
|
||||||
|
hidden:
|
||||||
|
role.value.includes('admin') ||
|
||||||
|
role.value.includes('branch_admin') ||
|
||||||
|
role.value.includes('head_of_admin')
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'drawerPersonnelManagement',
|
label: 'drawerPersonnelManagement',
|
||||||
icon: 'fa6-solid:building-user',
|
icon: 'fa6-solid:building-user',
|
||||||
route: '/personnel-management',
|
route: '/personnel-management',
|
||||||
|
hidden:
|
||||||
|
role.value.includes('admin') ||
|
||||||
|
role.value.includes('branch_admin') ||
|
||||||
|
role.value.includes('head_of_admin')
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'drawerCustomerManagement',
|
label: 'drawerCustomerManagement',
|
||||||
|
|
@ -115,7 +110,28 @@ const labelMenu = ref<
|
||||||
route: '',
|
route: '',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
]);
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const userBranch = useMyBranch();
|
||||||
|
const { currentMyBranch } = storeToRefs(userBranch);
|
||||||
|
|
||||||
|
const currentRoute = ref<string>('');
|
||||||
|
const currentPath = computed(() => {
|
||||||
|
return router.currentRoute.value.path;
|
||||||
|
});
|
||||||
|
|
||||||
|
const labelMenu = ref<
|
||||||
|
{
|
||||||
|
label: string;
|
||||||
|
icon: string;
|
||||||
|
route: string;
|
||||||
|
hidden?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
isax?: boolean;
|
||||||
|
}[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
const leftDrawerOpen = defineModel<boolean>('leftDrawerOpen', {
|
const leftDrawerOpen = defineModel<boolean>('leftDrawerOpen', {
|
||||||
default: true,
|
default: true,
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,31 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MenuItem from 'components/00_home/MenuItem.vue';
|
import MenuItem from 'components/00_home/MenuItem.vue';
|
||||||
import useUtilsStore from 'stores/utils';
|
import useUtilsStore from 'stores/utils';
|
||||||
import { onMounted } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
import { getRole } from 'src/services/keycloak';
|
||||||
|
|
||||||
const utilsStore = useUtilsStore();
|
const utilsStore = useUtilsStore();
|
||||||
const menu = [
|
const menu = ref<InstanceType<typeof MenuItem>['$props']['list']>([]);
|
||||||
|
const role = ref();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
utilsStore.currentTitle.title = '';
|
||||||
|
utilsStore.currentTitle.path = [{ text: '' }];
|
||||||
|
|
||||||
|
role.value = getRole();
|
||||||
|
menu.value = [
|
||||||
{
|
{
|
||||||
value: 'branch-management',
|
value: 'branch-management',
|
||||||
icon: 'mdi-chart-donut',
|
icon: 'mdi-chart-donut',
|
||||||
color: 'green',
|
color: 'green',
|
||||||
title: 'mainBranchTitle',
|
title: 'mainBranchTitle',
|
||||||
caption: 'mainBranchCaption',
|
caption: 'mainBranchCaption',
|
||||||
|
hidden:
|
||||||
|
role.value.includes('admin') ||
|
||||||
|
role.value.includes('branch_admin') ||
|
||||||
|
role.value.includes('head_of_admin')
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'personnel-management',
|
value: 'personnel-management',
|
||||||
|
|
@ -18,6 +33,12 @@ const menu = [
|
||||||
color: 'cyan',
|
color: 'cyan',
|
||||||
title: 'mainPersonnelTitle',
|
title: 'mainPersonnelTitle',
|
||||||
caption: 'mainPersonnelCaption',
|
caption: 'mainPersonnelCaption',
|
||||||
|
hidden:
|
||||||
|
role.value.includes('admin') ||
|
||||||
|
role.value.includes('branch_admin') ||
|
||||||
|
role.value.includes('head_of_admin')
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'customer-management',
|
value: 'customer-management',
|
||||||
|
|
@ -94,11 +115,7 @@ const menu = [
|
||||||
caption: 'mainReportCaption',
|
caption: 'mainReportCaption',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
] satisfies InstanceType<typeof MenuItem>['$props']['list'];
|
];
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
utilsStore.currentTitle.title = '';
|
|
||||||
utilsStore.currentTitle.path = [{ text: '' }];
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue