2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-05-29 07:05:29 +00:00
|
|
|
<li v-if="visible()" :class="[getCXOptions('menuitem'), item.class]" v-bind="ptm('menuitem')">
|
2023-04-28 14:16:56 +00:00
|
|
|
<template v-if="!templates || !templates.item">
|
2022-09-14 11:26:01 +00:00
|
|
|
<router-link v-if="item.to" v-slot="{ navigate, href, isActive, isExactActive }" :to="item.to" custom>
|
2023-05-29 07:05:29 +00:00
|
|
|
<a :href="href" :class="getCXOptions('action', { isActive, isExactActive })" :aria-current="isCurrentUrl()" @click="onClick($event, navigate)" v-bind="ptm('action')">
|
|
|
|
<component v-if="templates.itemicon" :is="templates.itemicon" :item="item" :class="getCXOptions('icon')" />
|
|
|
|
<span v-else-if="item.icon" :class="[getCXOptions('icon'), item.icon]" v-bind="ptm('icon')" />
|
|
|
|
<span v-if="item.label" :class="getCXOptions('label')" v-bind="ptm('label')">{{ label() }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</a>
|
|
|
|
</router-link>
|
2023-05-29 07:05:29 +00:00
|
|
|
<a v-else :href="item.url || '#'" :class="getCXOptions('action')" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action')">
|
|
|
|
<component v-if="templates && templates.itemicon" :is="templates.itemicon" :item="item" :class="getCXOptions('icon')" />
|
|
|
|
<span v-else-if="item.icon" :class="[getCXOptions('icon'), item.icon]" v-bind="ptm('icon')" />
|
|
|
|
<span v-if="item.label" :class="getCXOptions('label')" v-bind="ptm('label')">{{ label() }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</a>
|
|
|
|
</template>
|
2023-04-17 05:42:20 +00:00
|
|
|
<component v-else :is="templates.item" :item="item"></component>
|
2022-09-06 12:03:37 +00:00
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-29 07:05:29 +00:00
|
|
|
import BaseBreadcrumb from './BaseBreadcrumb.vue';
|
2023-04-26 09:57:16 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'BreadcrumbItem',
|
2023-05-29 07:05:29 +00:00
|
|
|
extends: BaseBreadcrumb,
|
2022-09-06 12:03:37 +00:00
|
|
|
props: {
|
|
|
|
item: null,
|
2023-04-17 05:42:20 +00:00
|
|
|
templates: null,
|
2023-04-27 14:11:40 +00:00
|
|
|
exact: null,
|
|
|
|
index: null
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-05-29 07:05:29 +00:00
|
|
|
getCXOptions(key, params) {
|
|
|
|
return this.cx(key, {
|
|
|
|
...params,
|
|
|
|
context: this
|
|
|
|
});
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
onClick(event, navigate) {
|
|
|
|
if (this.item.command) {
|
|
|
|
this.item.command({
|
|
|
|
originalEvent: event,
|
|
|
|
item: this.item
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.item.to && navigate) {
|
|
|
|
navigate(event);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
visible() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2022-12-08 11:04:25 +00:00
|
|
|
disabled() {
|
|
|
|
return typeof this.item.disabled === 'function' ? this.item.disabled() : this.item.disabled;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
label() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.label === 'function' ? this.item.label() : this.item.label;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
isCurrentUrl() {
|
|
|
|
const { to, url } = this.item;
|
|
|
|
let lastPath = this.$router ? this.$router.currentRoute.path : '';
|
|
|
|
|
|
|
|
return to === lastPath || url === lastPath ? 'page' : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|