Refactor SaleSection component to utilize direct property assignment for betterPrices, enhancing reactivity in Vue3. Update inventory mapping to ensure betterPrices is always an array.
This commit is contained in:
@@ -290,6 +290,8 @@
|
||||
this.inventory = response.data.map(item => ({
|
||||
...item,
|
||||
sellQuantity: item.totalQuantity,
|
||||
// Vue3: besserPrices direkt als Property setzen (statt this.$set)
|
||||
betterPrices: Array.isArray(item.betterPrices) ? item.betterPrices : [],
|
||||
}));
|
||||
await this.loadPricesForInventory();
|
||||
} catch (error) {
|
||||
@@ -310,10 +312,11 @@
|
||||
currentPrice: currentPrice
|
||||
}
|
||||
});
|
||||
this.$set(item, 'betterPrices', data || []);
|
||||
// Vue3: direkte Zuweisung ist reaktiv
|
||||
item.betterPrices = Array.isArray(data) ? data : [];
|
||||
} catch (error) {
|
||||
console.error(`Error loading prices for item ${itemKey}:`, error);
|
||||
this.$set(item, 'betterPrices', []);
|
||||
item.betterPrices = [];
|
||||
} finally {
|
||||
this.loadingPrices.delete(itemKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user