Avoid firing request if quantity does not change

This commit is contained in:
William Buezas 2024-06-13 14:14:46 -03:00
parent 975e8f06c0
commit 531f4bb8cd
2 changed files with 7 additions and 6 deletions

View File

@ -1,7 +1,6 @@
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
export default function (value, fractionSize = 2) { export default function (value, fractionSize = 2) {
console.log('toPercentage value: ', value);
if (value == null || value === '') return; if (value == null || value === '') return;
const { locale } = useI18n(); const { locale } = useI18n();

View File

@ -195,11 +195,13 @@ const addSale = async (sale) => {
}; };
const changeQuantity = (sale) => { const changeQuantity = (sale) => {
console.log('edit.quantity', edit.value.quantity); if (
console.log('sale.quantity', sale.quantity); !sale.itemFk ||
if (!sale.itemFk || sale.quantity == null) return; sale.quantity == null ||
edit.value?.oldQuantity === sale.quantity
)
return;
if (!sale.id) return addSale(sale); if (!sale.id) return addSale(sale);
updateQuantity(sale); updateQuantity(sale);
}; };
@ -566,7 +568,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
v-model.number="row.quantity" v-model.number="row.quantity"
@keyup.enter="changeQuantity(row)" @keyup.enter="changeQuantity(row)"
@blur="changeQuantity(row)" @blur="changeQuantity(row)"
@focus="edit.quantity = row.quantity" @focus="edit.oldQuantity = row.quantity"
/> />
<span v-else>{{ row.quantity }}</span> <span v-else>{{ row.quantity }}</span>
</QTd> </QTd>