forked from verdnatura/salix-front
refs #7366 fix travel
This commit is contained in:
parent
0d25c1b66b
commit
06ddcc5030
|
@ -117,8 +117,8 @@ onMounted(async () => {
|
|||
state.set($props.model, $props.formInitialData);
|
||||
|
||||
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
|
||||
else if (arrayData.store.data) updateAndEmit(arrayData.store.data, 'onFetch');
|
||||
|
||||
else if (arrayData.store.data && !$props.formInitialData)
|
||||
updateAndEmit(arrayData.store.data, 'onFetch');
|
||||
if ($props.observeFormChanges) {
|
||||
watch(
|
||||
() => formData.value,
|
||||
|
|
|
@ -32,11 +32,11 @@ const cloneTravel = () => {
|
|||
redirectToCreateView(stringifiedTravelData);
|
||||
};
|
||||
|
||||
const cloneTravelWithEntries = () => {
|
||||
const cloneTravelWithEntries = async () => {
|
||||
try {
|
||||
axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||
const { id } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
redirectToCreateView();
|
||||
router.push({ name: 'TravelBasicData', params: { id } });
|
||||
} catch (err) {
|
||||
console.err('Error cloning travel with entries');
|
||||
}
|
||||
|
|
|
@ -15,33 +15,23 @@ const { t } = useI18n();
|
|||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const newTravelForm = reactive({
|
||||
ref: null,
|
||||
agencyModeFk: null,
|
||||
shipped: null,
|
||||
landed: null,
|
||||
warehouseOutFk: null,
|
||||
warehouseInFk: null,
|
||||
});
|
||||
|
||||
const agenciesOptions = ref([]);
|
||||
const warehousesOptions = ref([]);
|
||||
const viewAction = ref();
|
||||
|
||||
const newTravelForm = ref({});
|
||||
onBeforeMount(() => {
|
||||
// Esto nos permite decirle a FormModel si queremos observar los cambios o no
|
||||
// Ya que si queremos clonar queremos que nos permita guardar inmediatamente sin realizar cambios en el form
|
||||
viewAction.value = route.query.travelData ? 'clone' : 'create';
|
||||
|
||||
if (route.query.travelData) {
|
||||
const travelData = JSON.parse(route.query.travelData);
|
||||
for (let key in newTravelForm) {
|
||||
newTravelForm[key] = travelData[key];
|
||||
}
|
||||
|
||||
newTravelForm.value = { ...newTravelForm.value, ...travelData };
|
||||
delete newTravelForm.value.id;
|
||||
}
|
||||
});
|
||||
|
||||
const redirectToTravelBasicData = (_, { id }) => {
|
||||
const redirectToTravelBasicData = ({ id }) => {
|
||||
router.push({ name: 'TravelBasicData', params: { id } });
|
||||
};
|
||||
</script>
|
||||
|
@ -60,8 +50,8 @@ const redirectToTravelBasicData = (_, { id }) => {
|
|||
<QPage>
|
||||
<VnSubToolbar />
|
||||
<FormModel
|
||||
url-update="Travels"
|
||||
model="travel"
|
||||
url-create="Travels"
|
||||
model="travelCreate"
|
||||
:form-initial-data="newTravelForm"
|
||||
:observe-form-changes="viewAction === 'create'"
|
||||
@on-data-saved="redirectToTravelBasicData"
|
||||
|
|
Loading…
Reference in New Issue