forked from verdnatura/salix-front
Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6942-improveInvoceIn
This commit is contained in:
parent
c450290d3c
commit
b46760116f
|
@ -1,11 +1,9 @@
|
|||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const quasar = useQuasar();
|
||||
|
||||
|
@ -67,8 +65,7 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { currentRoute, push } = useRouter();
|
||||
const arrayData = useArrayData(props.dataKey, { ...props });
|
||||
const store = arrayData.store;
|
||||
const searchText = ref('');
|
||||
|
@ -92,18 +89,20 @@ async function search() {
|
|||
});
|
||||
if (!props.redirect) return;
|
||||
|
||||
if (props.customRouteRedirectName) {
|
||||
router.push({
|
||||
if (props.customRouteRedirectName)
|
||||
return push({
|
||||
name: props.customRouteRedirectName,
|
||||
params: { id: searchText.value },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const { matched: matches } = route;
|
||||
const { path } = matches[matches.length - 1];
|
||||
const newRoute = path.replace(':id', searchText.value);
|
||||
await router.push(newRoute);
|
||||
const { matched: matches } = currentRoute.value;
|
||||
const { path } = matches.at(-1);
|
||||
|
||||
let targetUrl = path.replace(':id', searchText.value);
|
||||
if (path.endsWith('/list') && store.data.length === 1)
|
||||
targetUrl = targetUrl.replace('/list', `/${store.data[0].id}/summary`);
|
||||
|
||||
await push(targetUrl);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue