refactor: refs #8944 modified fixedPrice to use the existing backs
This commit is contained in:
parent
c679b77bbd
commit
1d0febaa22
|
@ -77,10 +77,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
hasDifferentVerb: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
@ -91,7 +87,7 @@ const formData = ref();
|
||||||
const saveButtonRef = ref(null);
|
const saveButtonRef = ref(null);
|
||||||
const watchChanges = ref();
|
const watchChanges = ref();
|
||||||
const formUrl = computed(() => $props.url);
|
const formUrl = computed(() => $props.url);
|
||||||
const saveData = ref();
|
|
||||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
@ -185,7 +181,6 @@ async function saveChanges(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let changes = data || getChanges();
|
let changes = data || getChanges();
|
||||||
let url = $props.saveUrl || $props.url + '/crud';
|
|
||||||
if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges);
|
if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -193,8 +188,7 @@ async function saveChanges(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($props.hasDifferentVerb) await axios.patch(url, saveData.value);
|
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||||
else await axios.post(url, changes);
|
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +265,6 @@ function getChanges() {
|
||||||
} else if (originalData.value[i]) {
|
} else if (originalData.value[i]) {
|
||||||
const data = getDifferences(originalData.value[i], row);
|
const data = getDifferences(originalData.value[i], row);
|
||||||
if (!isEmpty(data)) {
|
if (!isEmpty(data)) {
|
||||||
saveData.value = row;
|
|
||||||
updates.push({
|
updates.push({
|
||||||
data,
|
data,
|
||||||
where: { [pk]: row[pk] },
|
where: { [pk]: row[pk] },
|
||||||
|
|
|
@ -273,8 +273,7 @@ watch(
|
||||||
data-key="ItemFixedPrices"
|
data-key="ItemFixedPrices"
|
||||||
url="FixedPrices/filter"
|
url="FixedPrices/filter"
|
||||||
:order="'name DESC'"
|
:order="'name DESC'"
|
||||||
save-url="FixedPrices/upsertFixedPrice"
|
save-url="FixedPrices/formatFixedPriceData"
|
||||||
:hasDifferentVerb="true"
|
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:is-editable="true"
|
:is-editable="true"
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
|
|
Loading…
Reference in New Issue