// Cpeprovisioning.js Vue.component('tt-chip', { props: { checked: { type: Boolean, default: false } }, template: `
` }); Vue.component('Cpeprovisioning', { template: `
Loading...

Daten werden geladen...

Keine Einträge für die aktuellen Filter gefunden.

{{ item.customer }} SPIN: {{ item.spin }}
Netzgebiet: {{ item.network || 'N/A' }}
{{ item.owner_phone }}
Adresse: {{ item.owner_full_address || 'N/A' }}
{{ item.owner_email }}
Router Konfiguration
Versand & Abschluss
Produkt & VLANs

{{ item.product_name }} {{ item.product_code }}

{{ item.access_type }} {{ item.access_type_down }} {{ item.access_type_up }}

Loading...
Lade weitere Einträge...
`, data() { return { window, loading: true, items: [], filteredItems: [], filters: { network_id: '', routerconfig_finished: '0', hide_delayed_finish: '1', owner: '' }, statusOptions: [ { value: '0', text: 'Offen' }, { value: '1', text: 'Abgeschlossen' } ], delayOptions: [ { value: '1', text: 'Nicht anzeigen' }, { value: '0', text: 'Anzeigen' } ], page: 1, pagination: {}, } }, computed: { networkOptions() { const networks = window.TT_CONFIG.NETWORKS || []; return [{ value: '', text: 'Alle Gebiete' }, ...networks.map(net => ({ value: net.id, text: net.name }))]; }, routerOptions() { return window.TT_CONFIG.ROUTER_OPTIONS || []; } }, methods: { async fetchData(isNewSearch = false) { if (isNewSearch) { this.page = 1; this.items = []; this.filteredItems = []; this.pagination = {}; } if (!isNewSearch && this.pagination.total_pages && this.page > this.pagination.total_pages) { return; // No more pages to load } this.loading = true; const payload = { pagination: { page: this.page, per_page: 25 }, filters: { network_id: this.filters.network_id, routerconfig_finished: this.filters.routerconfig_finished, hide_delayed_finish: this.filters.hide_delayed_finish, }, order: { key: 'order_id', order: 'desc' } }; try { const { data } = await axios.post(window.TT_CONFIG.CPE_PROV_API_GET_URL, payload); const newItems = (data.rows || []).map(item => ({ ...item, isDirty: false, isSaving: false, pop_name: item.pop_name || 'N/A', owner_address: `${item.owner_street || ''} ${item.owner_housenumber || ''}, ${item.owner_zip || ''} ${item.owner_city || ''}`, owner_phone: item.owner_phone || '', owner_email: item.owner_email || '', })); if (isNewSearch) { this.items = newItems; } else { this.items.push(...newItems); } this.pagination = data.pagination; this.page++; this.applyClientSideFilter(); } catch (error) { console.error("Error fetching CPE data:", error); window.notify('error', 'Fehler beim Laden der Daten.'); } finally { this.loading = false; } }, applyClientSideFilter() { if (!this.filters.owner) { this.filteredItems = this.items; return; } const search = this.filters.owner.toLowerCase(); this.filteredItems = this.items.filter(item => { return (item.customer && item.customer.toLowerCase().includes(search)) || (item.spin && item.spin.toLowerCase().includes(search)) || (item.owner_full_address && item.owner_full_address.toLowerCase().includes(search)) || (item.product_name && item.product_name.toLowerCase().includes(search)) || (item.network && item.network.toLowerCase().includes(search)); }); }, resetFilters() { this.filters = { network_id: '', routerconfig_finished: '0', hide_delayed_finish: '1', owner: '' }; this.fetchData(true); }, markDirty(item) { this.$set(item, 'isDirty', true); }, async checkShipping(row) { await this.$nextTick(); let wasPrefilled = false; if (row.cpe_data.shipping && row.cpe_data.routertype) { const shippingData = this.window.TT_CONFIG.ROUTER_SHIPPING_DATA[row.cpe_data.routertype]; if (shippingData) { if (!row.cpe_data.ship_weight) { this.$set(row.cpe_data, 'ship_weight', shippingData.weight); wasPrefilled = true; } if (!row.cpe_data.ship_length) { this.$set(row.cpe_data, 'ship_length', shippingData.length); wasPrefilled = true; } if (!row.cpe_data.ship_width) { this.$set(row.cpe_data, 'ship_width', shippingData.width); wasPrefilled = true; } if (!row.cpe_data.ship_height) { this.$set(row.cpe_data, 'ship_height', shippingData.height); wasPrefilled = true; } } } else if (!row.cpe_data.shipping) { // Clear the fields if shipping is unchecked row.cpe_data.ship_weight = ''; row.cpe_data.ship_length = ''; row.cpe_data.ship_width = ''; row.cpe_data.ship_height = ''; } if (wasPrefilled) { this.markDirty(row); this.window.notify('success', 'Versanddaten wurden automatisch ausgefüllt.'); } }, _buildSavePayload(row) { return { id: row.cpe_id, order_id: row.order_id, orderproduct_id: row.orderproduct_id, termination_id: row.termination_id, ont_sn: row.ont_sn, vlans: row.vlans, ...row.cpe_data, shipping: row.cpe_data.shipping ? 1 : 0, routerconfig_finished: row.cpe_data.routerconfig_finished ? 1 : 0, }; }, async saveCpe(row) { this.$set(row, 'isSaving', true); const payload = this._buildSavePayload(row); try { const { data } = await axios.post(this.window.TT_CONFIG.CPE_PROV_API_SAVE_URL, payload); if (data.success) { this.window.notify('success', data.message); if (this.filters.routerconfig_finished === '0' && payload.routerconfig_finished) { this.items = this.items.filter(item => item.orderproduct_id !== row.orderproduct_id); this.applyClientSideFilter(); } else { const index = this.items.findIndex(item => item.orderproduct_id === row.orderproduct_id); if (index !== -1) { this.$set(this.items[index], 'isDirty', false); } } } else { this.window.notify('error', data.message || 'Fehler beim Speichern.'); } } catch (error) { this.window.notify('error', 'Ein unerwarteter Fehler ist aufgetreten.'); } finally { this.$set(row, 'isSaving', false); } } }, mounted() { this.fetchData(true); } });