diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index d45bb51c1..fdb799545 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -226,7 +226,10 @@ async function fetch() { } function handleRequestArgs() { const isUrlCreate = $props.urlCreate; - const differences = getDifferences(formData.value, originalData.value); + const differences = getUpdatedValues( + Object.keys(getDifferences(formData.value, originalData.value)), + formData.value + ); return { method: isUrlCreate ? 'post' : 'patch', url: isUrlCreate || $props.urlUpdate || $props.url || arrayData.store.url, @@ -251,16 +254,16 @@ async function save() { try { formData.value = trimData(formData.value); const { method, body, url } = handleRequestArgs(); - // Obtener las claves del objeto original - const originalKeys = Object.keys(body); + // // Obtener las claves del objeto original + // const originalKeys = Object.keys(body); - // Construir el objeto con valores actualizados - const updatedValues = getUpdatedValues(originalKeys, formData.value); + // // Construir el objeto con valores actualizados + // const updatedValues = getUpdatedValues(originalKeys, formData.value); let response; - if ($props.saveFn) response = await $props.saveFn(updatedValues); - else response = await axios[method](url, updatedValues); + if ($props.saveFn) response = await $props.saveFn(body); + else response = await axios[method](url, body); if ($props.urlCreate) notify('globals.dataCreated', 'positive');