49 lines
1.0 KiB
Vue
49 lines
1.0 KiB
Vue
<script setup>
|
|
const props = defineProps({
|
|
row: {
|
|
type: Object,
|
|
required: true,
|
|
default: {}
|
|
}
|
|
})
|
|
|
|
const relations = ref([])
|
|
|
|
const normalizeId = (value) => {
|
|
if (value === null || value === undefined || value === "") return null
|
|
const parsed = Number(value)
|
|
return Number.isNaN(parsed) ? String(value) : parsed
|
|
}
|
|
|
|
const relationLabel = computed(() => {
|
|
const id = normalizeId(props.row?.infoData?.memberrelation)
|
|
if (!id) return ""
|
|
return relations.value.find((i) => normalizeId(i.id) === id)?.type || ""
|
|
})
|
|
|
|
const relationId = computed(() => {
|
|
return normalizeId(props.row?.infoData?.memberrelation)
|
|
})
|
|
|
|
const loadRelations = async () => {
|
|
try {
|
|
relations.value = await useEntities("memberrelations").select()
|
|
} catch (e) {
|
|
relations.value = []
|
|
}
|
|
}
|
|
|
|
loadRelations()
|
|
</script>
|
|
|
|
<template>
|
|
<NuxtLink
|
|
v-if="relationId && relationLabel"
|
|
:to="`/standardEntity/memberrelations/show/${relationId}`"
|
|
class="text-primary"
|
|
>
|
|
{{ relationLabel }}
|
|
</NuxtLink>
|
|
<span v-else>{{ relationLabel }}</span>
|
|
</template>
|