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 => ({
|
this.inventory = response.data.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
sellQuantity: item.totalQuantity,
|
sellQuantity: item.totalQuantity,
|
||||||
|
// Vue3: besserPrices direkt als Property setzen (statt this.$set)
|
||||||
|
betterPrices: Array.isArray(item.betterPrices) ? item.betterPrices : [],
|
||||||
}));
|
}));
|
||||||
await this.loadPricesForInventory();
|
await this.loadPricesForInventory();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -310,10 +312,11 @@
|
|||||||
currentPrice: currentPrice
|
currentPrice: currentPrice
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$set(item, 'betterPrices', data || []);
|
// Vue3: direkte Zuweisung ist reaktiv
|
||||||
|
item.betterPrices = Array.isArray(data) ? data : [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error loading prices for item ${itemKey}:`, error);
|
console.error(`Error loading prices for item ${itemKey}:`, error);
|
||||||
this.$set(item, 'betterPrices', []);
|
item.betterPrices = [];
|
||||||
} finally {
|
} finally {
|
||||||
this.loadingPrices.delete(itemKey);
|
this.loadingPrices.delete(itemKey);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user