salix-front/src/components/LeftMenuItemGroup.vue

52 lines
1.3 KiB
Vue
Raw Normal View History

2022-11-29 13:45:48 +00:00
<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import LeftMenuItem from './LeftMenuItem.vue';
const route = useRoute();
const { t } = useI18n();
const props = defineProps({
item: {
type: Object,
required: true,
},
group: {
type: String,
default: '',
},
});
2023-05-26 12:01:24 +00:00
const item = computed(() => props.item); // eslint-disable-line vue/no-dupe-keys
2022-11-29 13:45:48 +00:00
const isOpened = computed(() => {
const { matched } = route;
const { name } = item.value;
return matched.some((item) => item.name === name);
});
</script>
<template>
2023-04-11 11:31:03 +00:00
<QExpansionItem
2022-11-29 13:45:48 +00:00
:group="props.group"
active-class="text-primary"
:label="item.title"
:to="{ name: item.name }"
expand-separator
:default-opened="isOpened"
>
<template #header>
2023-04-11 11:31:03 +00:00
<QItemSection avatar>
<QIcon :name="item.icon"></QIcon>
</QItemSection>
<QItemSection>{{ t(item.title) }}</QItemSection>
<QItemSection side>
2022-11-29 13:45:48 +00:00
<slot name="side" :item="item" />
2023-04-11 11:31:03 +00:00
</QItemSection>
2022-11-29 13:45:48 +00:00
</template>
<template v-for="section in item.children" :key="section.name">
2023-04-11 11:31:03 +00:00
<LeftMenuItem :item="section" />
2022-11-29 13:45:48 +00:00
</template>
2023-04-11 11:31:03 +00:00
</QExpansionItem>
2022-11-29 13:45:48 +00:00
</template>