diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index eca957092..99710408d 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -61,6 +61,10 @@ const props = defineProps({ type: Function, default: null, }, + customRouteRedirectName: { + type: String, + default: '', + }, }); const router = useRouter(); @@ -87,8 +91,16 @@ async function search() { }); if (!props.redirect) return; + if (props.customRouteRedirectName) { + router.push({ + name: props.customRouteRedirectName, + params: { id: searchText.value }, + }); + return; + } + const { matched: matches } = route; - const { path } = matches[matches.length-1]; + const { path } = matches[matches.length - 1]; const newRoute = path.replace(':id', searchText.value); await router.push(newRoute); } diff --git a/src/pages/Entry/EntryCreate.vue b/src/pages/Entry/EntryCreate.vue index 3063845b0..80c3f609e 100644 --- a/src/pages/Entry/EntryCreate.vue +++ b/src/pages/Entry/EntryCreate.vue @@ -8,7 +8,9 @@ import VnRow from 'components/ui/VnRow.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import FetchData from 'components/FetchData.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; +import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; +import { useStateStore } from 'stores/useStateStore'; import { useState } from 'src/composables/useState'; import { toDate } from 'src/filters'; @@ -16,6 +18,7 @@ const state = useState(); const { t } = useI18n(); const route = useRoute(); const router = useRouter(); +const stateStore = useStateStore(); const user = state.getUser(); const newEntryForm = reactive({ @@ -55,6 +58,17 @@ const redirectToEntryBasicData = (_, { id }) => { @on-fetch="(data) => (companiesOptions = data)" auto-load /> + {