594 lines
29 KiB
JavaScript
594 lines
29 KiB
JavaScript
Vue.component('tt-chip', {
|
|
props: {
|
|
checked: { type: Boolean, default: false }
|
|
},
|
|
template: `<div class="tt-chip" :class="{ 'is-checked': checked }"><slot></slot></div>`
|
|
});
|
|
|
|
Vue.component('Cpeprovisioning', {
|
|
template: `
|
|
<div class="cpe-provisioning-page">
|
|
<tt-card>
|
|
<div class="filter-grid">
|
|
<tt-select label="Netzgebiet" :options="networkOptions" v-model="filters.network_id" @input="debouncedFetchData" sm/>
|
|
<tt-select label="Provisioningstatus" :options="statusOptions" v-model="filters.routerconfig_finished" @input="debouncedFetchData" sm/>
|
|
<tt-select label="Verzögerte Herstellung" :options="delayOptions" v-model="filters.hide_delayed_finish" @input="debouncedFetchData" sm/>
|
|
<tt-input label="Suche" v-model="filters.owner" sm placeholder="Kunde, SPIN, Adresse..." @input="debouncedFetchData"/>
|
|
<div class="filter-actions">
|
|
<tt-button text="Anwenden" @click="fetchData(true)" additional-class="btn-primary" sm/>
|
|
<tt-button text="Zurücksetzen" @click="resetFilters" additional-class="btn-secondary" sm/>
|
|
</div>
|
|
</div>
|
|
</tt-card>
|
|
|
|
<div v-if="loading && items.length === 0" class="loading-indicator">
|
|
<div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div>
|
|
<p class="mt-2">Daten werden geladen...</p>
|
|
</div>
|
|
|
|
<div v-if="!loading && filteredItems.length === 0" class="no-results-indicator">
|
|
<i class="fas fa-info-circle fa-2x text-muted mb-2"></i>
|
|
<p>Keine Einträge für die aktuellen Filter gefunden.</p>
|
|
</div>
|
|
|
|
<div class="cpe-cards-container">
|
|
<div v-for="item in filteredItems" :key="item.orderproduct_id" class="cpe-card" :class="{ 'is-dirty': item.isDirty }">
|
|
<div class="cpe-card-header">
|
|
<div class="customer-info">
|
|
<span style="display: ruby;">
|
|
<strong>{{ item.customer }}<small v-if="item.owner_customer_number" class="text-muted ml-2">#{{ item.owner_customer_number }}</small></strong>
|
|
</span>
|
|
<small v-if="item.spin" class="text-muted">SPIN: <span class="text-pink">{{ item.spin }}</span></small>
|
|
</div>
|
|
<div class="location-contact-header">
|
|
<div><strong>Netzgebiet:</strong> {{ item.network || 'N/A' }}</div>
|
|
<div v-if="item.owner_phone"><i class="fas fa-phone mr-2 text-muted"></i>{{ item.owner_phone }}</div>
|
|
<div><strong>Adresse:</strong> {{ item.owner_full_address || 'N/A' }}</div>
|
|
<div v-if="item.owner_email"><i class="fas fa-envelope mr-2 text-muted"></i>{{ item.owner_email }}</div>
|
|
</div>
|
|
<div class="header-actions">
|
|
<a target="_blank" :href="window.TT_CONFIG.ORDER_URL + '/Index/?id=' + item.order_id + '&addJournal=1'">
|
|
<tt-tooltip text="Bestelljournal" position="top"><i class="fas fa-scroll"></i></tt-tooltip>
|
|
</a>
|
|
<a target="_blank" :href="window.TT_CONFIG.CPE_PROV_PRINT_PDF_URL + '?order_id=' + item.order_id">
|
|
<tt-tooltip text="Label drucken" position="top"><i class="fas fa-print"></i></tt-tooltip>
|
|
</a>
|
|
<tt-tooltip v-if="item.vot" text="Vorortinstallation" position="top"><i class="fas fa-tools text-purple"></i></tt-tooltip>
|
|
<tt-tooltip v-if="item.hw" :text="item.hw" position="top"><i class="fas fa-shopping-bag text-purple"></i></tt-tooltip>
|
|
<tt-tooltip v-if="item.voip" text="Voice Produkt vorhanden" position="top"><i class="fas fa-phone text-purple"></i></tt-tooltip>
|
|
<tt-tooltip v-if="item.note" :text="item.note" position="top" allow-wrapping><i class="fas fa-clipboard-list text-purple"></i></tt-tooltip>
|
|
<a target="_blank" :href="item.snopp_url" v-if="item.show_snopp_button">
|
|
<tt-tooltip text="SNOPP" position="top" allow-wrapping>
|
|
<img style="height: 18px;" src="/img/snop-logo.png" alt="Snop Logo">
|
|
</tt-tooltip>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="cpe-card-content">
|
|
<div class="content-column">
|
|
<h5>Router Konfiguration</h5>
|
|
<tt-select label="Router" :options="routerOptions" v-model="item.cpe_data.routertype" @input="markDirty(item); checkShipping(item); handleRouterTypeChange(item)" sm no-form-group/>
|
|
<tt-input label="WLAN SSID" v-model="item.cpe_data.wifi_ssid" @input="markDirty(item)" sm no-form-group/>
|
|
<tt-input label="WPA Key" v-model="item.cpe_data.wifi_pass" @input="markDirty(item)" sm no-form-group/>
|
|
<div class="d-flex align-items-center" style="gap: 5px;">
|
|
<tt-input label="Router MAC" v-model="item.cpe_data.mac" @input="handleMacInput(item)" sm no-form-group style="flex-grow: 1;"/>
|
|
<button @click="copyToClipboard(item.cpe_data.mac)" :disabled="!item.cpe_data.mac" class="btn btn-sm btn-primary" style="height: 28px; margin-top:28px; width: 38px; padding: 0;">
|
|
<i class="fas fa-copy"></i>
|
|
</button>
|
|
</div>
|
|
<tt-input v-if="item.termination_id" label="ONT SN" v-model="item.ont_sn" @input="markDirty(item)" sm no-form-group :additional-props="{ placeholder: item.ont_deployed ? 'ONT montiert' : 'ONT nicht montiert' }"/>
|
|
</div>
|
|
|
|
<div class="content-column">
|
|
<h5>Versand & Abschluss</h5>
|
|
<tt-checkbox label="Versandauftrag" v-model="item.cpe_data.shipping" @input="markDirty(item);checkShipping(item)" sm/>
|
|
<div class="shipping-dims">
|
|
<tt-input label="Gewicht" v-model="item.cpe_data.ship_weight" @input="markDirty(item)" sm type="number" :disabled="!item.cpe_data.shipping" placeholder="kg"/>
|
|
<tt-input label="Länge" v-model="item.cpe_data.ship_length" @input="markDirty(item)" sm type="number" :disabled="!item.cpe_data.shipping" placeholder="cm"/>
|
|
<tt-input label="Breite" v-model="item.cpe_data.ship_width" @input="markDirty(item)" sm type="number" :disabled="!item.cpe_data.shipping" placeholder="cm"/>
|
|
<tt-input label="Höhe" v-model="item.cpe_data.ship_height" @input="markDirty(item)" sm type="number" :disabled="!item.cpe_data.shipping" placeholder="cm"/>
|
|
</div>
|
|
<tt-textarea label="Kommentar" v-model="item.cpe_data.note" @input="markDirty(item)" sm no-form-group/>
|
|
</div>
|
|
|
|
<div class="content-column">
|
|
<h5>Produkt & VLANs</h5>
|
|
<p><strong>{{ item.product_name }}</strong> <small class="text-muted">{{ item.product_code }}</small></p>
|
|
<p>
|
|
<span class="badge badge-info">{{ item.access_type }}</span>
|
|
<span class="ml-2"><i class="fas fa-arrow-down"></i> {{ item.access_type_down }}</span>
|
|
<span class="ml-2"><i class="fas fa-arrow-up"></i> {{ item.access_type_up }}</span>
|
|
</p>
|
|
<div class="vlans-container mt-2">
|
|
<template v-for="(vlan, key) in item.vlans">
|
|
<tt-chip v-if="vlan.tag" class="vlan-chip" :key="key">
|
|
<input type="checkbox" :checked="vlan.checked" @change="markDirty(item); vlan.checked = !vlan.checked"/>
|
|
<span>{{ key.charAt(0).toUpperCase() + key.slice(1) }}: {{ vlan.tag }}</span>
|
|
</tt-chip>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content-column action-column">
|
|
<h5>Aktionen</h5>
|
|
<div class="action-buttons">
|
|
<tt-button text="In Radius anlegen"
|
|
@click="createRadiusUser(item)"
|
|
:disabled="!isValidMac(item.cpe_data.mac)"
|
|
sm
|
|
additional-class="btn-primary"
|
|
title="Sendet Kundendaten an Chrome Extension" />
|
|
</div>
|
|
<div class="finish-wrapper mt-auto">
|
|
<label class="col-form-label col-form-label-sm">Konfig abgeschlossen</label>
|
|
<tt-switch v-model="item.cpe_data.routerconfig_finished" @input="markDirty(item)"/>
|
|
</div>
|
|
<tt-button text="Speichern" @click="saveCpe(item)" :loading="item.isSaving" :disabled="!item.isDirty" :additional-class="item.isDirty ? 'btn-success' : 'btn-secondary'"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="loading && items.length > 0" class="text-center mt-4 mb-4">
|
|
<div class="card d-inline-block p-3 shadow-sm">
|
|
<div class="spinner-border text-primary" role="status">
|
|
<span class="sr-only">Loading...</span>
|
|
</div>
|
|
<span class="ml-2">Lade weitere Einträge...</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-center mt-4 mb-4" v-if="!loading && pagination.total_pages && page <= pagination.total_pages">
|
|
<tt-button text="Weitere laden" @click="fetchData(false)" additional-class="btn-primary" />
|
|
</div>
|
|
|
|
<tt-modal :show="showExtensionIdModal" title="Extension ID Konfigurieren" @close="showExtensionIdModal=false">
|
|
<div>
|
|
<div class="field"><label style="margin-bottom: 8px; font-size: 14px;">Chrome Extension ID</label>
|
|
<div class="input-wrap"><i class="fa-duotone fa-puzzle-piece input-icon"></i><input class="ri" type="text"
|
|
v-model.trim="extensionId"
|
|
placeholder="z.B. jglijfiddilckddlmbnlojmmlahboffh">
|
|
</div>
|
|
</div>
|
|
<div class="cluster" style="justify-content: flex-end; margin-top: 24px; gap: 12px;">
|
|
<button class="primary-btn" @click="saveExtensionId">Speichern</button>
|
|
</div>
|
|
</div>
|
|
</tt-modal>
|
|
</div>
|
|
`,
|
|
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: {},
|
|
debouncedFetchData: null,
|
|
macInputTimers: {}, // Store timers for debouncing MAC input
|
|
extensionId: 'jglijfiddilckddlmbnlojmmlahboffh',
|
|
showExtensionIdModal: false,
|
|
processingMacItems: new Set() // Track items currently being processed
|
|
}
|
|
},
|
|
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 || [];
|
|
}
|
|
},
|
|
created() {
|
|
this.debouncedFetchData = _.debounce(this.fetchData.bind(this, true), 400);
|
|
const savedExtensionId = localStorage.getItem('radiusExtensionId');
|
|
if (savedExtensionId) {
|
|
this.extensionId = savedExtensionId;
|
|
}
|
|
window.addEventListener('keydown', this.handleKeydown);
|
|
},
|
|
beforeDestroy() {
|
|
window.removeEventListener('keydown', this.handleKeydown);
|
|
// Clear all pending MAC input timers
|
|
Object.keys(this.macInputTimers).forEach(key => {
|
|
clearTimeout(this.macInputTimers[key]);
|
|
});
|
|
},
|
|
methods: {
|
|
copyToClipboard(text) {
|
|
navigator.clipboard.writeText(text)
|
|
.then(() => {
|
|
window.notify('success', 'Text erfolgreich in die Zwischenablage kopiert!');
|
|
})
|
|
.catch(err => {
|
|
console.error('Fehler beim Kopieren des Textes: ', err);
|
|
window.notify('error', 'Fehler beim Kopieren des Textes.');
|
|
});
|
|
},
|
|
handleKeydown(e) {
|
|
if (e.code === 'KeyE' && e.ctrlKey && e.altKey) {
|
|
e.preventDefault();
|
|
this.openExtensionIdModal();
|
|
}
|
|
},
|
|
openExtensionIdModal() {
|
|
this.showExtensionIdModal = true;
|
|
},
|
|
saveExtensionId() {
|
|
localStorage.setItem('radiusExtensionId', this.extensionId);
|
|
this.showExtensionIdModal = false;
|
|
window.notify('success', 'Extension ID gespeichert.');
|
|
},
|
|
isValidMac(mac) {
|
|
if (!mac) return false;
|
|
const macRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
|
return macRegex.test(mac);
|
|
},
|
|
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;
|
|
}
|
|
|
|
this.loading = true;
|
|
|
|
const payload = {
|
|
pagination: { page: this.page, per_page: 25 },
|
|
filters: { ...this.filters },
|
|
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.filteredItems = this.items;
|
|
|
|
} catch (error) {
|
|
console.error("Error fetching CPE data:", error);
|
|
window.notify('error', 'Fehler beim Laden der Daten.');
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
resetFilters() {
|
|
this.filters = { network_id: '', routerconfig_finished: '0', hide_delayed_finish: '1', owner: '' };
|
|
this.fetchData(true);
|
|
},
|
|
markDirty(item) {
|
|
this.$set(item, 'isDirty', true);
|
|
},
|
|
parseMacFromQrCode(qrCode) {
|
|
console.log('[MAC Parser] Raw QR Code input:', qrCode);
|
|
|
|
// Remove any whitespace/newlines (barcode scanner input doesn't support newlines, but just in case)
|
|
const cleaned = qrCode.replace(/\s+/g, '');
|
|
console.log('[MAC Parser] Cleaned QR Code:', cleaned);
|
|
|
|
// Extract MAC address from QR format: 00040E-802395709D7C
|
|
// The MAC address is the 12 hex characters AFTER the dash
|
|
const match = cleaned.match(/-([0-9A-Fa-f]{12})/);
|
|
console.log('[MAC Parser] Regex match result:', match);
|
|
|
|
if (match) {
|
|
const macAddress = match[1]; // Get only the part after the dash: 802395709D7C
|
|
console.log('[MAC Parser] Extracted MAC:', macAddress);
|
|
return macAddress;
|
|
}
|
|
|
|
console.log('[MAC Parser] No match found, returning null');
|
|
return null;
|
|
},
|
|
calculateMacOffset(macAddress, offset) {
|
|
console.log('[MAC Offset] Input MAC:', macAddress, 'Offset:', offset);
|
|
|
|
// Convert MAC to decimal using BigInt for large numbers
|
|
const macDecimal = BigInt('0x' + macAddress);
|
|
console.log('[MAC Offset] MAC as decimal:', macDecimal.toString());
|
|
|
|
// Apply offset (add or subtract)
|
|
const newMacDecimal = macDecimal + BigInt(offset);
|
|
console.log('[MAC Offset] New MAC as decimal:', newMacDecimal.toString());
|
|
|
|
// Convert back to hex (12 chars, padded with zeros)
|
|
let newMacHex = newMacDecimal.toString(16).toUpperCase();
|
|
newMacHex = newMacHex.padStart(12, '0');
|
|
console.log('[MAC Offset] Result MAC:', newMacHex);
|
|
|
|
return newMacHex;
|
|
},
|
|
formatMacAddress(macAddress) {
|
|
console.log('[MAC Format] Input MAC:', macAddress);
|
|
|
|
// Remove any existing formatting
|
|
const cleaned = macAddress.replace(/[:-]/g, '');
|
|
console.log('[MAC Format] Cleaned MAC:', cleaned);
|
|
|
|
// Format as AA:BB:CC:DD:EE:FF (uppercase)
|
|
const formatted = cleaned.match(/.{1,2}/g).join(':').toUpperCase();
|
|
console.log('[MAC Format] Formatted MAC:', formatted);
|
|
|
|
return formatted;
|
|
},
|
|
handleMacInput(item) {
|
|
console.log('[MAC Input] === START handleMacInput ===');
|
|
console.log('[MAC Input] Item:', item);
|
|
console.log('[MAC Input] Current MAC value:', item.cpe_data.mac);
|
|
console.log('[MAC Input] Router type:', item.cpe_data.routertype);
|
|
|
|
const itemKey = item.orderproduct_id;
|
|
|
|
// Check if we're already processing this item to prevent recursion
|
|
if (this.processingMacItems.has(itemKey)) {
|
|
console.log('[MAC Input] Already processing this item, returning to prevent recursion');
|
|
return;
|
|
}
|
|
|
|
this.markDirty(item);
|
|
|
|
// Clear existing timer for this item
|
|
if (this.macInputTimers[itemKey]) {
|
|
console.log('[MAC Input] Clearing existing timer for item:', itemKey);
|
|
clearTimeout(this.macInputTimers[itemKey]);
|
|
}
|
|
|
|
// Create new timer (debounce with 300ms delay)
|
|
console.log('[MAC Input] Creating new debounce timer for item:', itemKey);
|
|
this.macInputTimers[itemKey] = setTimeout(() => {
|
|
console.log('[MAC Input] Debounce timer fired for item:', itemKey);
|
|
this.processMacAddress(item);
|
|
}, 300); // 300ms delay to wait for barcode scanner to finish
|
|
},
|
|
handleRouterTypeChange(item) {
|
|
console.log('[Router Type Change] Router type changed, checking if MAC needs processing');
|
|
this.processMacAddress(item);
|
|
},
|
|
processMacAddress(item) {
|
|
const inputValue = item.cpe_data.mac;
|
|
const routerType = item.cpe_data.routertype;
|
|
const itemKey = item.orderproduct_id;
|
|
|
|
console.log('[MAC Process] === START processMacAddress ===');
|
|
console.log('[MAC Process] Input value:', inputValue);
|
|
console.log('[MAC Process] Router type:', routerType);
|
|
|
|
// Only process if it's a QR code format (contains dash, no colons)
|
|
// This prevents reprocessing already formatted MAC addresses
|
|
if (!inputValue) {
|
|
console.log('[MAC Process] No input value, returning');
|
|
return;
|
|
}
|
|
|
|
if (!inputValue.includes('-')) {
|
|
console.log('[MAC Process] No dash found in input, returning');
|
|
return;
|
|
}
|
|
|
|
if (inputValue.includes(':')) {
|
|
console.log('[MAC Process] Already formatted (contains colons), returning');
|
|
return;
|
|
}
|
|
|
|
console.log('[MAC Process] Input contains dash and no colons, proceeding...');
|
|
|
|
// Check if this is a 4050 or 7690 router
|
|
if (routerType !== 'FritzBox 4050' && routerType !== 'FritzBox 7690') {
|
|
console.log('[MAC Process] Router type is not FritzBox 4050 or FritzBox 7690, returning. Current type:', routerType);
|
|
return;
|
|
}
|
|
|
|
console.log('[MAC Process] Router type is valid:', routerType);
|
|
|
|
// Mark this item as being processed
|
|
this.processingMacItems.add(itemKey);
|
|
console.log('[MAC Process] Added item to processing set:', itemKey);
|
|
|
|
// Safety timeout to ensure we don't get stuck in processing state
|
|
const safetyTimeout = setTimeout(() => {
|
|
console.log('[MAC Process] Safety timeout - removing item from processing set:', itemKey);
|
|
this.processingMacItems.delete(itemKey);
|
|
}, 2000);
|
|
|
|
try {
|
|
// Parse MAC from QR code
|
|
const parsedMac = this.parseMacFromQrCode(inputValue);
|
|
|
|
if (!parsedMac) {
|
|
console.log('[MAC Process] Failed to parse MAC from QR code');
|
|
window.notify('error', 'Konnte MAC-Adresse nicht aus QR-Code parsen');
|
|
clearTimeout(safetyTimeout);
|
|
this.processingMacItems.delete(itemKey);
|
|
return;
|
|
}
|
|
|
|
console.log('[MAC Process] Successfully parsed MAC:', parsedMac);
|
|
|
|
// Calculate offset based on router type
|
|
const offset = routerType === 'FritzBox 4050' ? -3 : 2;
|
|
console.log('[MAC Process] Applying offset:', offset);
|
|
|
|
const newMac = this.calculateMacOffset(parsedMac, offset);
|
|
console.log('[MAC Process] Calculated new MAC:', newMac);
|
|
|
|
// Format MAC address
|
|
const formattedMac = this.formatMacAddress(newMac);
|
|
console.log('[MAC Process] Formatted MAC:', formattedMac);
|
|
|
|
// Update the field using Vue.set for proper reactivity
|
|
console.log('[MAC Process] Updating item.cpe_data.mac to:', formattedMac);
|
|
this.$set(item.cpe_data, 'mac', formattedMac);
|
|
|
|
// Force Vue to update the DOM
|
|
this.$nextTick(() => {
|
|
console.log('[MAC Process] After nextTick, MAC value is:', item.cpe_data.mac);
|
|
// Clear safety timeout and remove from processing set
|
|
clearTimeout(safetyTimeout);
|
|
this.processingMacItems.delete(itemKey);
|
|
console.log('[MAC Process] Removed item from processing set after nextTick:', itemKey);
|
|
});
|
|
|
|
// Show notification
|
|
const offsetStr = offset > 0 ? `+${offset}` : `${offset}`;
|
|
window.notify('success', `MAC-Adresse aus QR-Code geparst (${offsetStr}): ${formattedMac}`);
|
|
|
|
} catch (error) {
|
|
console.error('[MAC Process] Error processing MAC:', error);
|
|
clearTimeout(safetyTimeout);
|
|
this.processingMacItems.delete(itemKey);
|
|
}
|
|
|
|
console.log('[MAC Process] === END processMacAddress ===');
|
|
},
|
|
checkShipping(item) {
|
|
if (item.cpe_data.shipping && item.cpe_data.routertype) {
|
|
const shippingData = this.window.TT_CONFIG.ROUTER_SHIPPING_DATA[item.cpe_data.routertype];
|
|
if (shippingData) {
|
|
item.cpe_data.ship_weight = shippingData.weight;
|
|
item.cpe_data.ship_length = shippingData.length;
|
|
item.cpe_data.ship_width = shippingData.width;
|
|
item.cpe_data.ship_height = shippingData.height;
|
|
item.cpe_data = { ...item.cpe_data }; // Trigger reactivity
|
|
this.window.notify('success', 'Versanddaten wurden automatisch ausgefüllt.');
|
|
}
|
|
} else if (!item.cpe_data.shipping) {
|
|
item.cpe_data.ship_weight = '';
|
|
item.cpe_data.ship_length = '';
|
|
item.cpe_data.ship_width = '';
|
|
item.cpe_data.ship_height = '';
|
|
item.cpe_data = { ...item.cpe_data }; // Trigger reactivity
|
|
}
|
|
},
|
|
createRadiusUser(item) {
|
|
console.log('[Create Radius User] === START ===');
|
|
console.log('[Create Radius User] Item:', item);
|
|
|
|
// Prepare the data to send to the Chrome extension
|
|
const customerNumber = item.owner_customer_number || 'N/A';
|
|
const macAddress = item.cpe_data.mac;
|
|
const address = item.owner_full_address || 'N/A';
|
|
const customerName = item.customer || 'N/A';
|
|
const productName = item.product_name || 'N/A';
|
|
|
|
console.log('[Create Radius User] Customer Number:', customerNumber);
|
|
console.log('[Create Radius User] MAC Address:', macAddress);
|
|
console.log('[Create Radius User] Address:', address);
|
|
console.log('[Create Radius User] Customer Name:', customerName);
|
|
console.log('[Create Radius User] Product Name:', productName);
|
|
|
|
window.notify('info', 'Sende Daten an Chrome Extension...');
|
|
|
|
const extensionId = this.extensionId;
|
|
const message = {
|
|
type: "CREATE_RADIUS_USER",
|
|
payload: {
|
|
customerNumber: customerNumber,
|
|
macAddress: macAddress,
|
|
address: address,
|
|
customerName: customerName,
|
|
productName: productName
|
|
}
|
|
};
|
|
|
|
console.log('[Create Radius User] Extension ID:', extensionId);
|
|
console.log('[Create Radius User] Message:', message);
|
|
|
|
if (window.chrome && chrome.runtime && chrome.runtime.sendMessage) {
|
|
try {
|
|
chrome.runtime.sendMessage(extensionId, message, (response) => {
|
|
if (chrome.runtime.lastError) {
|
|
console.warn('[Create Radius User] Senden an Erweiterung fehlgeschlagen:', chrome.runtime.lastError.message);
|
|
window.notify('warning', 'Daten konnten nicht an die Erweiterung gesendet werden. (Drücke STRG + ALT + E zum Konfigurieren)');
|
|
} else {
|
|
console.log('[Create Radius User] Erweiterung hat geantwortet:', response);
|
|
window.notify('success', 'Daten erfolgreich an Chrome Extension gesendet!');
|
|
}
|
|
});
|
|
} catch (e) {
|
|
console.error('[Create Radius User] Fehler beim Senden an die Erweiterung:', e);
|
|
window.notify('error', 'Fehler beim Senden an die Erweiterung.');
|
|
}
|
|
} else {
|
|
console.warn('[Create Radius User] Chrome Extension Messaging API nicht verfügbar.');
|
|
window.notify('warning', 'Chrome Messaging API nicht gefunden.');
|
|
}
|
|
|
|
console.log('[Create Radius User] === END ===');
|
|
},
|
|
_buildSavePayload(item) {
|
|
return {
|
|
id: item.cpe_id,
|
|
order_id: item.order_id,
|
|
orderproduct_id: item.orderproduct_id,
|
|
termination_id: item.termination_id,
|
|
ont_sn: item.ont_sn,
|
|
vlans: item.vlans,
|
|
...item.cpe_data,
|
|
shipping: item.cpe_data.shipping ? 1 : 0,
|
|
routerconfig_finished: item.cpe_data.routerconfig_finished ? 1 : 0,
|
|
};
|
|
},
|
|
async saveCpe(item) {
|
|
this.$set(item, 'isSaving', true);
|
|
const payload = this._buildSavePayload(item);
|
|
|
|
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(i => i.orderproduct_id !== item.orderproduct_id);
|
|
this.filteredItems = this.items;
|
|
} else {
|
|
const index = this.items.findIndex(i => i.orderproduct_id === item.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(item, 'isSaving', false);
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
this.fetchData(true);
|
|
window.addEventListener('keydown', this.handleKeydown);
|
|
}
|
|
}); |