perf: formModel
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
4ea0d04b86
commit
1c2c2538ed
|
@ -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');
|
||||
|
||||
|
|
Loading…
Reference in New Issue