feat(frontend): Verbesserung der Logik zur Überprüfung von Lagertypen in der Benutzeroberfläche
- Hinzufügen von Konsolenausgaben zur Nachverfolgung des Ladevorgangs von Lagertypen und zur Überprüfung, ob neue Lagertypen hinzugefügt werden können. - Anpassung der Bedingungen zur Anzeige des Hinzufügen-Buttons basierend auf dem Vorhandensein von Lagertypen und bestehenden Stocks in den Branches.
This commit is contained in:
@@ -262,9 +262,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async loadStockTypes() {
|
async loadStockTypes() {
|
||||||
|
console.log('Loading stock types...');
|
||||||
this.loading.stockTypes = true;
|
this.loading.stockTypes = true;
|
||||||
try {
|
try {
|
||||||
const stockTypesResult = await apiClient.get('/api/admin/falukant/stock-types');
|
const stockTypesResult = await apiClient.get('/api/admin/falukant/stock-types');
|
||||||
|
console.log('Stock types loaded:', stockTypesResult.data);
|
||||||
this.stockTypes = stockTypesResult.data;
|
this.stockTypes = stockTypesResult.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading stock types:', error);
|
console.error('Error loading stock types:', error);
|
||||||
@@ -311,9 +313,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
canAddStock(branch) {
|
canAddStock(branch) {
|
||||||
// Prüfe ob noch Stock-Types verfügbar sind, die für diesen Branch noch nicht existieren
|
console.log('canAddStock called for branch:', branch);
|
||||||
if (!branch.stocks || !this.stockTypes.length) {
|
console.log('stockTypes:', this.stockTypes);
|
||||||
return true; // Wenn keine Stocks vorhanden sind, kann immer hinzugefügt werden
|
console.log('branch.stocks:', branch.stocks);
|
||||||
|
|
||||||
|
// Wenn keine Stock-Types geladen sind, zeige den Button nicht
|
||||||
|
if (!this.stockTypes || this.stockTypes.length === 0) {
|
||||||
|
console.log('No stock types loaded, returning false');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wenn keine Stocks vorhanden sind, kann immer hinzugefügt werden
|
||||||
|
if (!branch.stocks || branch.stocks.length === 0) {
|
||||||
|
console.log('No stocks in branch, returning true');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstelle eine Liste der bereits vorhandenen Stock-Type-IDs für diesen Branch
|
// Erstelle eine Liste der bereits vorhandenen Stock-Type-IDs für diesen Branch
|
||||||
@@ -324,6 +337,7 @@ export default {
|
|||||||
!existingStockTypeIds.includes(stockType.id)
|
!existingStockTypeIds.includes(stockType.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('Available stock types:', availableStockTypes);
|
||||||
return availableStockTypes.length > 0;
|
return availableStockTypes.length > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user