diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index fa733baa5..59d362463 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -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; + } +});