0
0
Fork 0

deploy: test to dev

This commit is contained in:
Alex Moreno 2024-06-06 12:24:08 +02:00
commit 985ce9a643
2 changed files with 9 additions and 9 deletions

View File

@ -117,7 +117,7 @@ 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) updateAndEmit('onFetch', arrayData.store.data);
if ($props.observeFormChanges) { if ($props.observeFormChanges) {
watch( watch(
@ -137,7 +137,7 @@ onMounted(async () => {
if (!$props.url) if (!$props.url)
watch( watch(
() => arrayData.store.data, () => arrayData.store.data,
(val) => updateAndEmit(val, 'onFetch') (val) => updateAndEmit('onFetch', val)
); );
watch(formUrl, async () => { watch(formUrl, async () => {
@ -172,8 +172,8 @@ async function fetch() {
}); });
if (Array.isArray(data)) data = data[0] ?? {}; if (Array.isArray(data)) data = data[0] ?? {};
updateAndEmit(data, 'onFetch'); updateAndEmit('onFetch', data);
} catch (error) { } catch (e) {
state.set($props.model, {}); state.set($props.model, {});
originalData.value = {}; originalData.value = {};
} }
@ -196,7 +196,7 @@ async function save() {
if ($props.urlCreate) notify('globals.dataCreated', 'positive'); if ($props.urlCreate) notify('globals.dataCreated', 'positive');
updateAndEmit(response?.data, 'onDataSaved'); updateAndEmit('onDataSaved', formData.value, response?.data);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
notify('errors.writeRequest', 'negative'); notify('errors.writeRequest', 'negative');
@ -212,7 +212,7 @@ async function saveAndGo() {
} }
function reset() { function reset() {
updateAndEmit(originalData.value, 'onFetch'); updateAndEmit('onFetch', originalData.value);
if ($props.observeFormChanges) { if ($props.observeFormChanges) {
hasChanges.value = false; hasChanges.value = false;
isResetting.value = true; 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); state.set($props.model, val);
originalData.value = val && JSON.parse(JSON.stringify(val)); originalData.value = val && JSON.parse(JSON.stringify(val));
if (!$props.url) arrayData.store.data = 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 }); defineExpose({ save, isLoading, hasChanges });

View File

@ -29,7 +29,7 @@ const newInvoiceIn = reactive({
const suppliersOptions = ref([]); const suppliersOptions = ref([]);
const companiesOptions = ref([]); const companiesOptions = ref([]);
const redirectToInvoiceInBasicData = ({ id }) => { const redirectToInvoiceInBasicData = (__, { id }) => {
router.push({ name: 'InvoiceInBasicData', params: { id } }); router.push({ name: 'InvoiceInBasicData', params: { id } });
}; };
</script> </script>