refactor: refs #8944 modified fixedPrice to use the existing backs

This commit is contained in:
Jon Elias 2025-05-06 13:49:30 +02:00
parent c679b77bbd
commit 1d0febaa22
2 changed files with 3 additions and 11 deletions

View File

@ -77,10 +77,6 @@ const $props = defineProps({
type: Boolean,
default: true,
},
hasDifferentVerb: {
type: Boolean,
default: false,
},
});
const isLoading = ref(false);
@ -91,7 +87,7 @@ const formData = ref();
const saveButtonRef = ref(null);
const watchChanges = ref();
const formUrl = computed(() => $props.url);
const saveData = ref();
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
defineExpose({
@ -185,7 +181,6 @@ async function saveChanges(data) {
return;
}
let changes = data || getChanges();
let url = $props.saveUrl || $props.url + '/crud';
if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges);
try {
@ -193,8 +188,7 @@ async function saveChanges(data) {
return;
}
if ($props.hasDifferentVerb) await axios.patch(url, saveData.value);
else await axios.post(url, changes);
await axios.post($props.saveUrl || $props.url + '/crud', changes);
} finally {
isLoading.value = false;
}
@ -271,7 +265,6 @@ function getChanges() {
} else if (originalData.value[i]) {
const data = getDifferences(originalData.value[i], row);
if (!isEmpty(data)) {
saveData.value = row;
updates.push({
data,
where: { [pk]: row[pk] },

View File

@ -273,8 +273,7 @@ watch(
data-key="ItemFixedPrices"
url="FixedPrices/filter"
:order="'name DESC'"
save-url="FixedPrices/upsertFixedPrice"
:hasDifferentVerb="true"
save-url="FixedPrices/formatFixedPriceData"
:columns="columns"
:is-editable="true"
:right-search="false"