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() {
|
function handleRequestArgs() {
|
||||||
const isUrlCreate = $props.urlCreate;
|
const isUrlCreate = $props.urlCreate;
|
||||||
const differences = getDifferences(formData.value, originalData.value);
|
const differences = getUpdatedValues(
|
||||||
|
Object.keys(getDifferences(formData.value, originalData.value)),
|
||||||
|
formData.value
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
method: isUrlCreate ? 'post' : 'patch',
|
method: isUrlCreate ? 'post' : 'patch',
|
||||||
url: isUrlCreate || $props.urlUpdate || $props.url || arrayData.store.url,
|
url: isUrlCreate || $props.urlUpdate || $props.url || arrayData.store.url,
|
||||||
|
@ -251,16 +254,16 @@ async function save() {
|
||||||
try {
|
try {
|
||||||
formData.value = trimData(formData.value);
|
formData.value = trimData(formData.value);
|
||||||
const { method, body, url } = handleRequestArgs();
|
const { method, body, url } = handleRequestArgs();
|
||||||
// Obtener las claves del objeto original
|
// // Obtener las claves del objeto original
|
||||||
const originalKeys = Object.keys(body);
|
// const originalKeys = Object.keys(body);
|
||||||
|
|
||||||
// Construir el objeto con valores actualizados
|
// // Construir el objeto con valores actualizados
|
||||||
const updatedValues = getUpdatedValues(originalKeys, formData.value);
|
// const updatedValues = getUpdatedValues(originalKeys, formData.value);
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
|
|
||||||
if ($props.saveFn) response = await $props.saveFn(updatedValues);
|
if ($props.saveFn) response = await $props.saveFn(body);
|
||||||
else response = await axios[method](url, updatedValues);
|
else response = await axios[method](url, body);
|
||||||
|
|
||||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue