diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 89e3e56fd..004607914 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -11,6 +11,7 @@ import RightMenu from 'components/common/RightMenu.vue'; const props = defineProps({ dataKey: { type: String, required: true }, url: { type: String, default: undefined }, + customUrl: { type: String, default: undefined }, filter: { type: Object, default: () => {} }, descriptor: { type: Object, required: true }, filterPanel: { type: Object, default: undefined }, @@ -28,17 +29,20 @@ const searchRightDataKey = computed(() => { if (!props.searchDataKey) return route.name; return props.searchDataKey; }); + +const url = computed(() => props.url || props.customUrl); const arrayData = useArrayData(props.dataKey, { - url: props.url, + url: url.value, filter: props.filter, oneRecord: true, }); onBeforeMount(async () => { try { - if (props.idInWhere) arrayData.store.filter.where = { id: route.params.id }; - else if (!regex.test(props.url)) - arrayData.store.url = `${props.url}/${route.params.id}`; + const id = route.params.id; + if (props.idInWhere) arrayData.store.filter.where = { id }; + else if (props.customUrl) arrayData.store.url = url.value; + else if (!regex.test(url.value)) arrayData.store.url = `${url.value}/${id}`; await arrayData.fetch({ append: false, updateRouter: false }); } catch { @@ -50,8 +54,11 @@ onBeforeMount(async () => { onBeforeRouteUpdate(async (to, from) => { if (to.params.id !== from.params.id) { - if (props.idInWhere) arrayData.store.filter.where = { id: to.params.id }; - else arrayData.store.url = `${props.url}/${to.params.id}`; + const id = to.params.id; + if (props.idInWhere) arrayData.store.filter.where = { id }; + else if (props.customUrl) + arrayData.store.url = url.value.replace(regex, `/${id}`); + else arrayData.store.url = `${url.value}/${id}`; await arrayData.fetch({ updateRouter: false }); } diff --git a/src/pages/Customer/Card/CustomerCard.vue b/src/pages/Customer/Card/CustomerCard.vue index 6e79b31a9..af1231f14 100644 --- a/src/pages/Customer/Card/CustomerCard.vue +++ b/src/pages/Customer/Card/CustomerCard.vue @@ -6,7 +6,7 @@ import CustomerFilter from '../CustomerFilter.vue';