// Stocktake Progress Modal Component - Fullscreen Vue.component('stocktake-progress-modal', { props: { show: { type: Boolean, default: false }, id: { type: Number, default: null } }, //language=Vue template: `

Inventur Fortschritt {{ stocktake.stocktakeNumber }}

Laden...

Lade Inventurdaten...

Inventur
{{ stocktake.title }}
Gescannte Artikel
{{ stocktake.totalScannedItems }}
Lagerort
{{ stocktake.locationName }}
Gesamtwert (Einkauf)
{{ formatCurrency(summary.totalValue) }}
Status
{{ statusText }}
Gestartet am: {{ stocktake.startedAt }} Aktualisiere... Nächste Aktualisierung in {{ countdown }}s
Gescannte Artikel
{{ items.length }} Einträge
Artikel-Nr. Artikel Einzelpreis Menge Gesamtpreis Regal Fach Gescannt am Gescannt von Status
{{ item.articleNumber }} {{ item.articleTitle }} {{ formatCurrency(item.unitPrice) }} {{ item.countedQuantity }} {{ formatCurrency(item.lineTotal) }} {{ item.rack || '-' }} {{ item.shelf || '-' }} {{ item.scannedAt || '-' }} {{ item.scannedBy || '-' }} Überschrieben
Summe: {{ formatCurrency(summary.totalValue) }}
Noch keine Artikel gescannt

Scannen Sie Artikel mit der PWA-App, um sie hier zu sehen.

`, data() { return { loading: false, refreshing: false, stocktake: null, items: [], summary: { totalValue: 0, totalQuantity: 0 }, refreshInterval: null, countdownInterval: null, countdown: 5, }; }, computed: { statusText() { if (!this.stocktake) return ''; const statusMap = { 'planned': 'Geplant', 'in_progress': 'In Bearbeitung', 'completed': 'Abgeschlossen', 'cancelled': 'Abgebrochen' }; return statusMap[this.stocktake.status] || this.stocktake.status; }, statusCardClass() { if (!this.stocktake) return 'card-secondary'; const classMap = { 'planned': 'card-secondary', 'in_progress': 'card-warning', 'completed': 'card-success', 'cancelled': 'card-danger' }; return classMap[this.stocktake.status] || 'card-secondary'; } }, watch: { show(newVal) { if (newVal && this.id) { document.body.style.overflow = 'hidden'; this.loadProgress(); this.startAutoRefresh(); } else { document.body.style.overflow = ''; this.stopAutoRefresh(); } }, id(newVal) { if (this.show && newVal) { this.loadProgress(); } } }, methods: { close() { this.$emit('update:show', false); }, async loadProgress() { if (!this.id) return; if (!this.stocktake) { this.loading = true; } else { this.refreshing = true; } try { const response = await axios.get(`${window.TT_CONFIG.BASE_PATH}/WarehouseStocktake/getProgress`, { params: { id: this.id } }); if (response.data.success) { this.stocktake = response.data.stocktake; this.items = response.data.items; this.summary = response.data.summary || { totalValue: 0, totalQuantity: 0 }; } } catch (error) { console.error('Failed to load progress:', error); } finally { this.loading = false; this.refreshing = false; this.countdown = 5; } }, startAutoRefresh() { this.stopAutoRefresh(); this.countdown = 5; // Countdown timer this.countdownInterval = setInterval(() => { if (this.countdown > 0) { this.countdown--; } }, 1000); // Refresh data this.refreshInterval = setInterval(() => { if (this.show && this.id) { this.loadProgress(); } }, 5000); }, stopAutoRefresh() { if (this.refreshInterval) { clearInterval(this.refreshInterval); this.refreshInterval = null; } if (this.countdownInterval) { clearInterval(this.countdownInterval); this.countdownInterval = null; } }, formatCurrency(value) { return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(value || 0); } }, beforeDestroy() { document.body.style.overflow = ''; this.stopAutoRefresh(); } }); // Main Stocktake Component Vue.component('warehouse-stocktake', { //language=Vue template: ` `, data() { return { historyModal: false, historyModalId: null, progressModal: false, progressModalId: null, }; }, methods: { async startStocktake(event) { const row = event; if (row.rawStatus !== 'planned') { window.notify('warning', 'Inventur kann nur im Status "Geplant" gestartet werden'); return; } if (!confirm('Möchten Sie diese Inventur wirklich starten?')) { return; } try { const response = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WarehouseStocktake/startStocktake`, { id: row.id }); if (response.data.success) { window.notify('success', response.data.message); window.dispatchEvent(new Event('refreshTable')); } else { window.notify('error', response.data.message); } } catch (error) { window.notify('error', 'Fehler beim Starten der Inventur'); } }, viewProgress(event) { this.progressModalId = event.id; this.progressModal = true; }, async completeStocktake(event) { const row = event; if (!confirm('Möchten Sie diese Inventur wirklich abschließen?')) { return; } try { const response = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WarehouseStocktake/completeStocktake`, { id: row.id }); if (response.data.success) { window.notify('success', response.data.message); window.dispatchEvent(new Event('refreshTable')); } else { window.notify('error', response.data.message); } } catch (error) { window.notify('error', 'Fehler beim Abschließen der Inventur'); } }, applyToStock(event) { window.notify('warning', 'Aktuell noch nicht möglich'); }, exportReport(event) { window.open(`${window.TT_CONFIG.BASE_PATH}/WarehouseStocktake/exportReport?id=${event.id}`, '_blank'); } } });