diff --git a/src/pages/Travel/TravelCreate.vue b/src/pages/Travel/TravelCreate.vue index fa8520f95..b0ea45917 100644 --- a/src/pages/Travel/TravelCreate.vue +++ b/src/pages/Travel/TravelCreate.vue @@ -3,10 +3,12 @@ import { useI18n } from 'vue-i18n'; import { reactive, computed } from 'vue'; import FetchData from 'components/FetchData.vue'; import { useTravelStore } from 'src/stores/travel'; -import { useRouter } from 'vue-router'; +import { useRouter, useRoute } from 'vue-router'; import { inputSelectFilter } from 'src/composables/inputSelectFilterFn.js'; +import { onBeforeMount } from 'vue'; const { t } = useI18n(); +const route = useRoute(); const router = useRouter(); const travelStore = useTravelStore(); @@ -29,6 +31,15 @@ const warehousesOptions = reactive({ filtered: [], }); +onBeforeMount(() => { + if (route.query.travelData) { + const travelData = JSON.parse(route.query.travelData); + for (let key in travelData) { + newTravelData[key] = travelData[key]; + } + } +}); + const createTravel = async () => { const response = await travelStore.createTravel(newTravelData); if (response.status === 200) router.push({ path: `/travel/${response.data.id}` }); @@ -52,6 +63,10 @@ const canSubmit = computed(() => { } return true; }); + +const redirectToTravelList = () => { + router.push({ name: 'TravelList' }); +};