feat: refs #6919 add customUrl prop to VnCard for dynamic URL handling
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
52e1cfc828
commit
74dd49ffe0
|
@ -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 });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import CustomerFilter from '../CustomerFilter.vue';
|
|||
<template>
|
||||
<VnCard
|
||||
data-key="Client"
|
||||
:url="`Clients/${$route.params.id}/getCard`"
|
||||
:custom-url="`Clients/${$route.params.id}/getCard`"
|
||||
:descriptor="CustomerDescriptor"
|
||||
:filter-panel="$route.name != 'CustomerConsumption' && CustomerFilter"
|
||||
search-data-key="CustomerList"
|
||||
|
|
Loading…
Reference in New Issue