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);
|
state.set($props.model, $props.formInitialData);
|
||||||
|
|
||||||
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
|
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) {
|
if ($props.observeFormChanges) {
|
||||||
watch(
|
watch(
|
||||||
() => formData.value,
|
() => formData.value,
|
||||||
|
|
|
@ -32,11 +32,11 @@ const cloneTravel = () => {
|
||||||
redirectToCreateView(stringifiedTravelData);
|
redirectToCreateView(stringifiedTravelData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const cloneTravelWithEntries = () => {
|
const cloneTravelWithEntries = async () => {
|
||||||
try {
|
try {
|
||||||
axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
const { id } = await axios.post(`Travels/${$props.travel.id}/cloneWithEntries`);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
redirectToCreateView();
|
router.push({ name: 'TravelBasicData', params: { id } });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.err('Error cloning travel with entries');
|
console.err('Error cloning travel with entries');
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,33 +15,23 @@ const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const newTravelForm = reactive({
|
|
||||||
ref: null,
|
|
||||||
agencyModeFk: null,
|
|
||||||
shipped: null,
|
|
||||||
landed: null,
|
|
||||||
warehouseOutFk: null,
|
|
||||||
warehouseInFk: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
const agenciesOptions = ref([]);
|
const agenciesOptions = ref([]);
|
||||||
const warehousesOptions = ref([]);
|
const warehousesOptions = ref([]);
|
||||||
const viewAction = ref();
|
const viewAction = ref();
|
||||||
|
|
||||||
|
const newTravelForm = ref({});
|
||||||
onBeforeMount(() => {
|
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';
|
viewAction.value = route.query.travelData ? 'clone' : 'create';
|
||||||
|
|
||||||
if (route.query.travelData) {
|
if (route.query.travelData) {
|
||||||
const travelData = JSON.parse(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 } });
|
router.push({ name: 'TravelBasicData', params: { id } });
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -60,8 +50,8 @@ const redirectToTravelBasicData = (_, { id }) => {
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<FormModel
|
<FormModel
|
||||||
url-update="Travels"
|
url-create="Travels"
|
||||||
model="travel"
|
model="travelCreate"
|
||||||
:form-initial-data="newTravelForm"
|
:form-initial-data="newTravelForm"
|
||||||
:observe-form-changes="viewAction === 'create'"
|
:observe-form-changes="viewAction === 'create'"
|
||||||
@on-data-saved="redirectToTravelBasicData"
|
@on-data-saved="redirectToTravelBasicData"
|
||||||
|
|
Loading…
Reference in New Issue