Enhance RevenueSection to conditionally load product prices based on currentRegionId
- Updated watchers in RevenueSection to ensure product prices are only loaded when currentRegionId is not null. - Added a check in loadPricesForAllProducts to skip execution if currentRegionId is null or undefined, improving performance and preventing unnecessary calls. - Enhanced overall logic to ensure accurate price loading based on the selected region, contributing to a better user experience.
This commit is contained in:
@@ -78,17 +78,22 @@
|
||||
},
|
||||
watch: {
|
||||
isRevenueTableOpen(newVal) {
|
||||
if (newVal) {
|
||||
if (newVal && this.currentRegionId !== null) {
|
||||
this.loadPricesForAllProducts();
|
||||
}
|
||||
},
|
||||
products: {
|
||||
handler() {
|
||||
if (this.isRevenueTableOpen) {
|
||||
if (this.isRevenueTableOpen && this.currentRegionId !== null) {
|
||||
this.loadPricesForAllProducts();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
currentRegionId(newVal) {
|
||||
if (this.isRevenueTableOpen && newVal !== null) {
|
||||
this.loadPricesForAllProducts();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -99,6 +104,10 @@
|
||||
}
|
||||
},
|
||||
async loadPricesForAllProducts() {
|
||||
if (this.currentRegionId === null || this.currentRegionId === undefined) {
|
||||
console.log(`[RevenueSection] Skipping loadPricesForAllProducts - currentRegionId is null/undefined`);
|
||||
return;
|
||||
}
|
||||
console.log(`[RevenueSection] loadPricesForAllProducts called, products: ${this.products.length}, currentRegionId: ${this.currentRegionId}`);
|
||||
for (const product of this.products) {
|
||||
if (this.loadingPrices.has(product.id)) continue;
|
||||
|
||||
Reference in New Issue
Block a user