310 lines
16 KiB
JavaScript
310 lines
16 KiB
JavaScript
// Cpeprovisioning.js
|
|
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="fetchData(true)" sm/>
|
|
<tt-select label="Provisioningstatus" :options="statusOptions" v-model="filters.routerconfig_finished" @input="fetchData(true)" sm/>
|
|
<tt-select label="Verzögerte Herstellung" :options="delayOptions" v-model="filters.hide_delayed_finish" @input="fetchData(true)" sm/>
|
|
<tt-input label="Suche" v-model="filters.owner" sm placeholder="Kunde, SPIN, Adresse..." @input="applyClientSideFilter"/>
|
|
<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">
|
|
<strong>{{ item.customer }}</strong>
|
|
<small 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)" 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/>
|
|
<tt-input label="Router MAC" v-model="item.cpe_data.mac" @input="markDirty(item)" sm no-form-group/>
|
|
<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 action-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 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>
|
|
</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: {},
|
|
}
|
|
},
|
|
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);
|
|
}
|
|
}); |