feat: refs #8045 added new logic to show the correct icon and the correct path to redirect
This commit is contained in:
parent
561f82fa08
commit
d64ac223e3
|
@ -51,6 +51,9 @@ let store;
|
|||
let entity;
|
||||
const isLoading = ref(false);
|
||||
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
||||
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
||||
const moduleName = ref();
|
||||
const isSameModuleName = route.matched[1].meta.moduleName !== moduleName.value;
|
||||
defineExpose({ getData });
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
@ -77,15 +80,18 @@ onBeforeMount(async () => {
|
|||
);
|
||||
});
|
||||
|
||||
const routeName = computed(() => {
|
||||
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
||||
|
||||
function getName() {
|
||||
let name = $props.dataKey;
|
||||
if ($props.dataKey.includes(DESCRIPTOR_PROXY)) {
|
||||
name = name.split(DESCRIPTOR_PROXY)[0];
|
||||
}
|
||||
return `${name}Summary`;
|
||||
return name;
|
||||
}
|
||||
const routeName = computed(() => {
|
||||
let routeName = getName();
|
||||
return `${routeName}Summary`;
|
||||
});
|
||||
|
||||
async function getData() {
|
||||
store.url = $props.url;
|
||||
store.filter = $props.filter ?? {};
|
||||
|
@ -121,16 +127,27 @@ function copyIdText(id) {
|
|||
|
||||
const emit = defineEmits(['onFetch']);
|
||||
|
||||
const iconModule = computed(
|
||||
() =>
|
||||
router.options.routes[1].children.find((r) => r.name === $props.dataKey).meta
|
||||
.icon,
|
||||
);
|
||||
const toModule = computed(
|
||||
() =>
|
||||
router.options.routes[1].children.find((r) => r.name === $props.dataKey)
|
||||
.children[0].redirect,
|
||||
);
|
||||
const iconModuleV = computed(() => {
|
||||
moduleName.value = getName();
|
||||
if (isSameModuleName) {
|
||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
||||
?.meta?.icon;
|
||||
} else {
|
||||
return route.matched[1].meta.icon;
|
||||
}
|
||||
});
|
||||
|
||||
const toModuleV = computed(() => {
|
||||
moduleName.value = getName();
|
||||
if (isSameModuleName) {
|
||||
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
|
||||
?.children[0]?.redirect;
|
||||
} else {
|
||||
return route.matched[1].path.split('/').length > 2
|
||||
? route.matched[1].redirect
|
||||
: route.matched[1].children[0].redirect;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -143,10 +160,10 @@ const toModule = computed(
|
|||
flat
|
||||
dense
|
||||
size="md"
|
||||
:icon="iconModule"
|
||||
:icon="iconModuleV"
|
||||
color="white"
|
||||
class="link"
|
||||
:to="toModule"
|
||||
:to="toModuleV"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('globals.goToModuleIndex') }}
|
||||
|
|
Loading…
Reference in New Issue