diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 28b42d498..377708143 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -117,7 +117,7 @@ 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) updateAndEmit('onFetch', arrayData.store.data); if ($props.observeFormChanges) { watch( @@ -137,7 +137,7 @@ onMounted(async () => { if (!$props.url) watch( () => arrayData.store.data, - (val) => updateAndEmit(val, 'onFetch') + (val) => updateAndEmit('onFetch', val) ); watch(formUrl, async () => { @@ -172,8 +172,8 @@ async function fetch() { }); if (Array.isArray(data)) data = data[0] ?? {}; - updateAndEmit(data, 'onFetch'); - } catch (error) { + updateAndEmit('onFetch', data); + } catch (e) { state.set($props.model, {}); originalData.value = {}; } @@ -196,7 +196,7 @@ async function save() { if ($props.urlCreate) notify('globals.dataCreated', 'positive'); - updateAndEmit(response?.data, 'onDataSaved'); + updateAndEmit('onDataSaved', formData.value, response?.data); } catch (err) { console.error(err); notify('errors.writeRequest', 'negative'); @@ -212,7 +212,7 @@ async function saveAndGo() { } function reset() { - updateAndEmit(originalData.value, 'onFetch'); + updateAndEmit('onFetch', originalData.value); if ($props.observeFormChanges) { hasChanges.value = false; isResetting.value = true; @@ -234,12 +234,12 @@ function filter(value, update, filterOptions) { ); } -function updateAndEmit(val, evt) { +function updateAndEmit(evt, val, res) { state.set($props.model, val); originalData.value = val && JSON.parse(JSON.stringify(val)); if (!$props.url) arrayData.store.data = val; - emit(evt, state.get($props.model)); + emit(evt, state.get($props.model), res); } defineExpose({ save, isLoading, hasChanges }); diff --git a/src/pages/InvoiceIn/InvoiceInCreate.vue b/src/pages/InvoiceIn/InvoiceInCreate.vue index df73a0005..4dec9ac7d 100644 --- a/src/pages/InvoiceIn/InvoiceInCreate.vue +++ b/src/pages/InvoiceIn/InvoiceInCreate.vue @@ -29,7 +29,7 @@ const newInvoiceIn = reactive({ const suppliersOptions = ref([]); const companiesOptions = ref([]); -const redirectToInvoiceInBasicData = ({ id }) => { +const redirectToInvoiceInBasicData = (__, { id }) => { router.push({ name: 'InvoiceInBasicData', params: { id } }); };