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,
|
||||
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] },
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue