diff --git a/miniapp/assets/clients.js b/miniapp/assets/clients.js index 1c9d92d..3464e88 100644 --- a/miniapp/assets/clients.js +++ b/miniapp/assets/clients.js @@ -408,6 +408,15 @@ const Clients = (function () { }); root.appendChild(addBtn); + // Поиск (рендерится сразу, до загрузки) + const searchWrap = el(` +
+ +
+ `); + root.appendChild(searchWrap); + const searchInput = searchWrap.querySelector(".client-search"); + const loading = el(`
`); root.appendChild(loading); @@ -434,18 +443,42 @@ const Clients = (function () { return; } - const meta = el(` -
- ${data.count} ${pluralize(data.count, "клиент", "клиента", "клиентов")} · ${countLeads(data.clients)} ${pluralize(countLeads(data.clients), "подбор", "подбора", "подборов")} -
- `); - root.appendChild(meta); + const metaEl = el(`
`); + root.appendChild(metaEl); const list = el(`
`); - for (const c of data.clients) { - list.appendChild(renderClientCard(c)); - } root.appendChild(list); + + function renderFiltered(q) { + q = (q || "").trim().toLowerCase(); + const qDigits = q.replace(/\D/g, ""); + const filtered = q + ? data.clients.filter(c => { + const nameMatch = (c.client_name || "").toLowerCase().includes(q); + const phoneMatch = qDigits && (c.client_phone || "").replace(/\D/g, "").includes(qDigits); + const contractMatch = (c.contract_no || "").toLowerCase().includes(q); + return nameMatch || phoneMatch || contractMatch; + }) + : data.clients; + + const n = filtered.length; + const total = data.clients.length; + metaEl.textContent = q + ? `Найдено: ${n} из ${total}` + : `${total} ${pluralize(total, "клиент", "клиента", "клиентов")} · ${countLeads(data.clients)} ${pluralize(countLeads(data.clients), "подбор", "подбора", "подборов")}`; + + list.innerHTML = ""; + if (!filtered.length) { + list.innerHTML = `
Ничего не найдено
`; + return; + } + for (const c of filtered) { + list.appendChild(renderClientCard(c)); + } + } + + searchInput.addEventListener("input", () => renderFiltered(searchInput.value)); + renderFiltered(""); } function renderClientCard(c) { diff --git a/miniapp/assets/podbor.css b/miniapp/assets/podbor.css index 037db28..f7db2c2 100644 --- a/miniapp/assets/podbor.css +++ b/miniapp/assets/podbor.css @@ -3358,6 +3358,30 @@ border-top: 1px dashed var(--line); } +/* ===== Поиск по списку клиентов ===== */ +.client-search-wrap { + padding: 0 0 10px; +} +.client-search { + width: 100%; + padding: 10px 14px; + background: var(--paper, #FBF7F0); + border: 1.5px solid rgba(107,74,43,0.18); + border-radius: 10px; + font-family: inherit; + font-size: 14px; + color: var(--ink, #1F1A14); + box-sizing: border-box; + -webkit-appearance: none; +} +.client-search:focus { + outline: none; + border-color: var(--walnut, #6B4A2B); + background: white; +} +.client-search::placeholder { color: var(--muted, #998877); } +.client-search-meta { transition: color 0.15s; } + /* ===== Поля адреса (addr-grid) ===== */ .addr-grid { display: grid; diff --git a/miniapp/index.html b/miniapp/index.html index 5f5cec9..0699599 100644 --- a/miniapp/index.html +++ b/miniapp/index.html @@ -12,14 +12,14 @@ - - + +
- +
- - - - - - - - - - + + + + + + + + + +