Refactor betterPricesMap handling in RevenueSection for Vue 3 compatibility
- Removed the use of $set for updating betterPricesMap, leveraging direct assignment instead, which is now the standard in Vue 3. - Simplified the getBetterPrices method by eliminating unnecessary logging, enhancing code clarity while maintaining functionality. - These changes aim to improve performance and align with Vue 3 best practices for state management.
This commit is contained in:
@@ -130,22 +130,19 @@
|
|||||||
currentRegionId: this.currentRegionId
|
currentRegionId: this.currentRegionId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(`[RevenueSection] Product ${product.id} (${product.labelTr}): received ${data?.length || 0} better prices:`, data);
|
|
||||||
// Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt
|
// Speichere betterPrices in einem separaten Map, nicht auf dem product Objekt
|
||||||
this.$set(this.betterPricesMap, product.id, data || []);
|
// In Vue 3 ist $set nicht mehr nötig, direkte Zuweisung funktioniert
|
||||||
console.log(`[RevenueSection] betterPricesMap after update:`, JSON.parse(JSON.stringify(this.betterPricesMap)));
|
this.betterPricesMap[product.id] = data || [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error loading prices for product ${product.id}:`, error);
|
console.error(`Error loading prices for product ${product.id}:`, error);
|
||||||
this.$set(this.betterPricesMap, product.id, []);
|
this.betterPricesMap[product.id] = [];
|
||||||
} finally {
|
} finally {
|
||||||
this.loadingPrices.delete(product.id);
|
this.loadingPrices.delete(product.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getBetterPrices(productId) {
|
getBetterPrices(productId) {
|
||||||
const prices = this.betterPricesMap[productId] || [];
|
return this.betterPricesMap[productId] || [];
|
||||||
console.log(`[RevenueSection] getBetterPrices(${productId}): returning`, prices);
|
|
||||||
return prices;
|
|
||||||
},
|
},
|
||||||
getCityPriceClass(branchType) {
|
getCityPriceClass(branchType) {
|
||||||
if (branchType === 'store') return 'city-price-green';
|
if (branchType === 'store') return 'city-price-green';
|
||||||
|
|||||||
Reference in New Issue
Block a user