forked from verdnatura/salix-front
feat: refs #6893 replace id & redirect to Card or list
This commit is contained in:
parent
b46760116f
commit
a0dcd6aee1
|
@ -97,12 +97,18 @@ async function search() {
|
||||||
|
|
||||||
const { matched: matches } = currentRoute.value;
|
const { matched: matches } = currentRoute.value;
|
||||||
const { path } = matches.at(-1);
|
const { path } = matches.at(-1);
|
||||||
|
const [, moduleName] = path.split('/');
|
||||||
|
|
||||||
let targetUrl = path.replace(':id', searchText.value);
|
if (!store.data.length || store.data.length > 1)
|
||||||
if (path.endsWith('/list') && store.data.length === 1)
|
return push({ path: `/${moduleName}/list` });
|
||||||
targetUrl = targetUrl.replace('/list', `/${store.data[0].id}/summary`);
|
|
||||||
|
|
||||||
await push(targetUrl);
|
const targetId = store.data[0].id;
|
||||||
|
let targetUrl;
|
||||||
|
|
||||||
|
if (path.endsWith('/list')) targetUrl = path.replace('/list', `/${targetId}/summary`);
|
||||||
|
else if (path.includes(':id')) targetUrl = path.replace(':id', targetId);
|
||||||
|
|
||||||
|
await push({ path: targetUrl });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue