Produktion: globale Empfaenger-Suche in der bestehenden Suchleiste (Empfaenger-Index ueber alle Auftraege), keine neue Aktion

This commit is contained in:
Lucas Orth
2026-08-26 20:35:56 +02:00
parent 246359f545
commit 41459ddd9e

View File

@@ -204,6 +204,27 @@ const Board = defineComponent({
return api.get('/items/machines', { params: { limit: -1, fields: 'id,name,active,status,last_seen' } });
}
}
// Empfänger-Index über ALLE Aufträge: orderId → zusammengefasste Anschriften
// (klein geschrieben). Damit findet die normale Suche oben auch Empfänger,
// ohne dass man den Auftrag öffnen muss. Wird bei vollem Laden gebaut.
const empfIndex = ref({});
async function ladeEmpfIndex() {
try {
const r = await api.get('/items/order_entries', { params: {
limit: -1, fields: 'order,salutation,first_name,last_name,street,house_no,zip,city,country,free_text',
} });
const idx = {};
for (const e of r.data?.data || []) {
const oid = String(e.order?.id ?? e.order ?? '');
if (!oid) continue;
const txt = [e.salutation, e.first_name, e.last_name, e.street, e.house_no, e.zip, e.city, e.country, e.free_text]
.filter(Boolean).join(' ').toLowerCase();
idx[oid] = idx[oid] ? idx[oid] + ' · ' + txt : txt;
}
empfIndex.value = idx;
} catch { /* Suche läuft dann ohne Empfänger weiter */ }
}
async function laden(leise = false) {
// leise = Hintergrund-Aktualisierung: kein Spinner, kein Fehlerbanner.
if (!leise) { loading.value = true; fehler.value = ''; }
@@ -226,6 +247,9 @@ const Board = defineComponent({
machines.value = (m.data?.data || []);
templates.value = t.data?.data || [];
muster.value = ms.data?.data || { text_du: '', text_sie: '' };
// Empfänger-Index nur beim vollen Laden neu bauen (nicht bei der 15-s-
// Hintergrund-Aktualisierung) – im Hintergrund, blockiert das Board nicht.
if (!leise) ladeEmpfIndex();
} catch (e) {
if (!leise) fehler.value = e?.response?.data?.errors?.[0]?.message || e?.message || 'Laden fehlgeschlagen.';
} finally { if (!leise) loading.value = false; }
@@ -262,7 +286,8 @@ const Board = defineComponent({
return hay.toLowerCase().includes(q);
}
const orderHay = (o) => [o.order_number, kundeName(o), o.customer?.email, o.customer?.phone,
o.product?.name, o.format?.name, o.shipping_type, o.production_status, o.payment_status].filter(Boolean).join(' ');
o.product?.name, o.format?.name, o.shipping_type, o.production_status, o.payment_status,
empfIndex.value[String(o.id)] || ''].filter(Boolean).join(' ');
// Tab-Listen
const neueOrders = computed(() => orders.value.filter((o) =>
@@ -1060,7 +1085,7 @@ const Board = defineComponent({
])));
const kopfzeile = h('div', { style: 'display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:18px;' }, [
h('input', { type: 'search', value: suche.value, placeholder: '🔎 Auftrag, Kunde, E-Mail, Produkt …',
h('input', { type: 'search', value: suche.value, placeholder: '🔎 Auftrag, Kunde, Empfänger …',
style: S_INPUT + 'flex:1;min-width:240px;', onInput: (e) => { suche.value = e.target.value; } }),
sichtbareOrders().length ? btn(alleSichtbarGewaehlt() ? '☐ Auswahl aufheben' : '☑ Alle auswählen', alleAuswaehlen) : null,
btn('↻ Aktualisieren', laden),