feat(falukant): enhance product pricing and nobility advancement features
- Updated the `getAllProductPricesInRegion` method in `FalukantService` to accept additional parameters for network worth and branch ID, improving pricing calculations based on user branches. - Enhanced the nobility advancement logic in `NobilityView` to display unmet requirements clearly, providing users with better feedback on advancement conditions. - Refactored the revenue calculation in `ProductionSection` to utilize a cached product prices object, optimizing performance and reducing redundant API calls. - Updated localization files to include new translations for attack sources across multiple languages, enhancing the user experience for diverse audiences. - Removed obsolete C++ worker references and streamlined the retention logic for production logs, ensuring efficient data management.
This commit is contained in:
@@ -107,6 +107,7 @@
|
||||
:branchId="selectedBranch.id"
|
||||
:products="products"
|
||||
:current-certificate="currentCertificate"
|
||||
:product-prices-cache="productPricesCache"
|
||||
ref="productionSection"
|
||||
/>
|
||||
<!-- Tax summary for production -->
|
||||
@@ -435,7 +436,8 @@ export default {
|
||||
vehicles: [],
|
||||
activeTab: 'production',
|
||||
productPricesCache: {}, // Cache für regionale Preise: { productId: price }
|
||||
productPricesCacheRegionId: null, // regionId, für die der Cache gültig ist
|
||||
/** Cache-Schlüssel: Region + ob MAX(worth) über alle Filialregionen (bei Fahrzeug) */
|
||||
productPricesCacheKey: null,
|
||||
tabs: [
|
||||
{ value: 'production', label: 'falukant.branch.tabs.production' },
|
||||
{ value: 'inventory', label: 'falukant.branch.tabs.inventory' },
|
||||
@@ -625,6 +627,11 @@ export default {
|
||||
this.$refs.statusBar?.fetchStatus();
|
||||
await this.loadCurrentCertificate();
|
||||
await this.loadProducts();
|
||||
if (this.selectedBranch) {
|
||||
await this.loadVehicles();
|
||||
this.productPricesCacheKey = null;
|
||||
await this.loadProductPricesForCurrentBranch();
|
||||
}
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.productionSection?.loadStorage();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
@@ -732,20 +739,23 @@ export default {
|
||||
async loadProductPricesForCurrentBranch() {
|
||||
if (!this.selectedBranch || !this.selectedBranch.regionId) {
|
||||
this.productPricesCache = {};
|
||||
this.productPricesCacheRegionId = null;
|
||||
this.productPricesCacheKey = null;
|
||||
return;
|
||||
}
|
||||
if (this.productPricesCacheRegionId === this.selectedBranch.regionId && Object.keys(this.productPricesCache).length > 0) {
|
||||
const useNetworkWorth = Array.isArray(this.vehicles) && this.vehicles.length > 0;
|
||||
const cacheKey = `${this.selectedBranch.regionId}:${useNetworkWorth ? 'net' : 'loc'}:${this.selectedBranch.id}`;
|
||||
if (this.productPricesCacheKey === cacheKey && Object.keys(this.productPricesCache).length > 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-region', {
|
||||
params: {
|
||||
regionId: this.selectedBranch.regionId
|
||||
}
|
||||
});
|
||||
const params = { regionId: this.selectedBranch.regionId };
|
||||
if (useNetworkWorth) {
|
||||
params.networkWorth = '1';
|
||||
params.branchId = this.selectedBranch.id;
|
||||
}
|
||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-region', { params });
|
||||
this.productPricesCache = data.prices || {};
|
||||
this.productPricesCacheRegionId = this.selectedBranch.regionId;
|
||||
this.productPricesCacheKey = cacheKey;
|
||||
} catch (error) {
|
||||
console.error(`Error loading product prices for region ${this.selectedBranch.regionId}:`, error);
|
||||
// Fallback: Lade Preise einzeln (alte Methode)
|
||||
@@ -770,7 +780,7 @@ export default {
|
||||
}
|
||||
}
|
||||
this.productPricesCache = prices;
|
||||
this.productPricesCacheRegionId = this.selectedBranch?.regionId ?? null;
|
||||
this.productPricesCacheKey = cacheKey;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user