diff --git a/src/components/ui/CardSummary.vue b/src/components/ui/CardSummary.vue index a06837cf4..bac72334c 100644 --- a/src/components/ui/CardSummary.vue +++ b/src/components/ui/CardSummary.vue @@ -32,7 +32,7 @@ const arrayData = useArrayData(props.dataKey || route.meta.moduleName, { skip: 0, }); const { store } = arrayData; -const entity = computed(() => Array.isArray(store.data) ? store.data[0] : store.data); +const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data)); const isLoading = ref(false); defineExpose({ @@ -48,9 +48,10 @@ onBeforeMount(async () => { async function fetch() { store.url = props.url; + store.filter = props.filter ?? {}; isLoading.value = true; const { data } = await arrayData.fetch({ append: false, updateRouter: false }); - emit('onFetch', data); + emit('onFetch', Array.isArray(data) ? data[0] : data); isLoading.value = false; } diff --git a/src/pages/Worker/Card/WorkerSummary.vue b/src/pages/Worker/Card/WorkerSummary.vue index 43c493565..3a79d12bb 100644 --- a/src/pages/Worker/Card/WorkerSummary.vue +++ b/src/pages/Worker/Card/WorkerSummary.vue @@ -10,7 +10,7 @@ import CardSummary from 'components/ui/CardSummary.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; -const { params } = useRoute(); +const route = useRoute(); const { t } = useI18n(); const $props = defineProps({ @@ -20,18 +20,25 @@ const $props = defineProps({ }, }); -const entityId = computed(() => $props.id || params.id); +const entityId = computed(() => $props.id || route.params.id); const workerUrl = ref(); onMounted(async () => { workerUrl.value = (await getUrl('')) + `worker/${entityId.value}/`; }); -const filter = { where: { id: entityId.value } }; +const filter = computed(() => { + return { where: { id: entityId.value } }; +});