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: {
|
watch: {
|
||||||
isRevenueTableOpen(newVal) {
|
isRevenueTableOpen(newVal) {
|
||||||
if (newVal) {
|
if (newVal && this.currentRegionId !== null) {
|
||||||
this.loadPricesForAllProducts();
|
this.loadPricesForAllProducts();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
products: {
|
products: {
|
||||||
handler() {
|
handler() {
|
||||||
if (this.isRevenueTableOpen) {
|
if (this.isRevenueTableOpen && this.currentRegionId !== null) {
|
||||||
this.loadPricesForAllProducts();
|
this.loadPricesForAllProducts();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
},
|
||||||
|
currentRegionId(newVal) {
|
||||||
|
if (this.isRevenueTableOpen && newVal !== null) {
|
||||||
|
this.loadPricesForAllProducts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -99,6 +104,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async loadPricesForAllProducts() {
|
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}`);
|
console.log(`[RevenueSection] loadPricesForAllProducts called, products: ${this.products.length}, currentRegionId: ${this.currentRegionId}`);
|
||||||
for (const product of this.products) {
|
for (const product of this.products) {
|
||||||
if (this.loadingPrices.has(product.id)) continue;
|
if (this.loadingPrices.has(product.id)) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user