Add detailed debug logging in loadPricesForAllProducts method of RevenueSection
- Enhanced the loadPricesForAllProducts method with additional console logs to track the loading process of product prices, including the current region ID and the number of products being processed. - Improved visibility into the state of betterPricesMap after updates and provided detailed logs for each product's price loading, facilitating easier debugging and monitoring of price retrieval. - Aims to enhance traceability and provide clearer insights into the price handling process within the RevenueSection component.
This commit is contained in:
@@ -113,15 +113,19 @@
|
||||
}
|
||||
},
|
||||
async loadPricesForAllProducts() {
|
||||
console.log('[RevenueSection] loadPricesForAllProducts called, currentRegionId:', this.currentRegionId);
|
||||
if (this.currentRegionId === null || this.currentRegionId === undefined) {
|
||||
console.log('[RevenueSection] currentRegionId is null/undefined, returning');
|
||||
return;
|
||||
}
|
||||
console.log('[RevenueSection] Loading prices for', this.products.length, 'products');
|
||||
for (const product of this.products) {
|
||||
if (this.loadingPrices.has(product.id)) continue;
|
||||
this.loadingPrices.add(product.id);
|
||||
try {
|
||||
// Verwende den gerundeten Preis aus calculateProductRevenue (wie gewollt)
|
||||
const currentPrice = parseFloat(this.calculateProductRevenue(product).absolute);
|
||||
console.log(`[RevenueSection] Loading prices for product ${product.id} (${product.labelTr}), currentPrice: ${currentPrice}`);
|
||||
|
||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', {
|
||||
params: {
|
||||
@@ -130,12 +134,14 @@
|
||||
currentRegionId: this.currentRegionId
|
||||
}
|
||||
});
|
||||
console.log(`[RevenueSection] Received ${data?.length || 0} better prices for product ${product.id}:`, data);
|
||||
// Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt
|
||||
// In Vue 3 müssen wir ein neues Objekt erstellen, um die Reaktivität zu triggern
|
||||
this.betterPricesMap = {
|
||||
...this.betterPricesMap,
|
||||
[product.id]: data || []
|
||||
};
|
||||
console.log(`[RevenueSection] Updated betterPricesMap for product ${product.id}:`, this.betterPricesMap[product.id]);
|
||||
} catch (error) {
|
||||
console.error(`Error loading prices for product ${product.id}:`, error);
|
||||
this.betterPricesMap = {
|
||||
@@ -146,9 +152,12 @@
|
||||
this.loadingPrices.delete(product.id);
|
||||
}
|
||||
}
|
||||
console.log('[RevenueSection] Finished loading prices, betterPricesMap:', this.betterPricesMap);
|
||||
},
|
||||
getBetterPrices(productId) {
|
||||
return this.betterPricesMap[productId] || [];
|
||||
const prices = this.betterPricesMap[productId] || [];
|
||||
console.log(`[RevenueSection] getBetterPrices(${productId}):`, prices, 'full map:', this.betterPricesMap);
|
||||
return prices;
|
||||
},
|
||||
getCityPriceClass(branchType) {
|
||||
if (branchType === 'store') return 'city-price-green';
|
||||
|
||||
Reference in New Issue
Block a user