Files
thetool/public/js/pages/WarehouseAdministration/WarehouseAdministration.js
2024-10-10 08:49:50 +02:00

56 lines
2.2 KiB
JavaScript

Vue.component('warehouse-administration', {
//language=Vue
template: `
<tt-card title="Warehouse Administration">
<warehouse-administration-switch/>
<div class="button-group" style="max-width: 300px;display: flex; flex-direction: column; gap: 10px;">
<button
class="btn btn-primary"
:disabled="isLoading"
@click="createLocationsForAllEmployees"
title="Automatische Lagerorterstellung für Mitarbeiter. Mitarbeiter mit Firmenwagen erhalten einen zugehörigen Fahrzeuglagerort.">
Lagerorte für alle Mitarbeiter erstellen
</button>
<button
class="btn btn-primary"
:disabled="isLoading"
@click="updateAllSalesPrices">
Alle Verkaufspreise updaten
</button>
</div>
</tt-card>
`,
data() {
return {
isLoading: false,
window: window,
};
},
methods: {
async createLocationsForAllEmployees() {
this.isLoading = true;
const response = await axios.get(window.TT_CONFIG.BASE_URL + '/createLocations');
if (response.data.success) {
this.window.notify('success', response.data.message || 'Lagerorte wurden erfolgreich erstellt.');
} else {
this.window.notify('error', response.data.message || 'Fehler beim Erstellen der Lagerorte.');
}
this.isLoading = false;
},
async updateAllSalesPrices() {
this.isLoading = true;
const response = await axios.get(window.TT_CONFIG.BASE_PATH + '/WarehouseArticle/updatePrices');
if (response.data.success) {
this.window.notify('success', 'Verkaufspreise wurden erfolgreich aktualisiert.');
} else {
this.window.notify('error', 'Fehler beim Aktualisieren der Verkaufspreise.');
}
this.isLoading = false;
},
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
});