feat(ui): срез 6.x — кнопка «Скачать в Excel» в панелях сметы и КА

переиспользует готовый клиентский tableToExcel (настоящий .xlsx, не HTML-в-.xls).
Итог сметы — в имени листа. Браузер-verified (Blob 7КБ, корректный MIME xlsx).
APP_VERSION 2026-07-17p.
This commit is contained in:
anor
2026-07-17 23:36:10 +10:00
parent 61e4955987
commit 9a0b29c85a
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-07-17o"
APP_VERSION = "2026-07-17p"
# Audit: path → action name mapping
_AUDIT_MAP = [
+24
View File
@@ -123,6 +123,9 @@ button { font-family: inherit; }
.est-warn { padding: .5rem .9rem; border-top: 1px solid var(--border); background: var(--error-bg); color: var(--error-text, var(--text)); font-size: .8rem; display: flex; flex-direction: column; gap: .25rem; }
.ka-sub { padding: .3rem .9rem; font-size: .72rem; color: var(--text-muted); font-family: monospace; border-bottom: 1px solid var(--border-light, var(--border)); word-break: break-all; }
.est-table tr.ka-winner td { background: var(--accent-light); font-weight: 600; }
.est-actions { padding: .5rem .9rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.est-dl { font-size: .82rem; padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-sunken); color: var(--text); cursor: pointer; }
.est-dl:hover { border-color: var(--accent); color: var(--accent); }
.msg-system { align-self: center; background: var(--system-bg); border: none; font-size: .8rem; color: var(--system-text); box-shadow: none; padding: .4rem .8rem; }
.typing { align-self: flex-start; color: var(--text-light); font-style: italic; font-size: .85rem; padding: .4rem 0; }
@@ -1302,6 +1305,19 @@ function addEstimatePanel(data) {
panel.appendChild(warn);
}
// Скачать в Excel — настоящий .xlsx из таблицы позиций (итог в имени файла)
const acts = document.createElement('div');
acts.className = 'est-actions';
const dl = document.createElement('button');
dl.className = 'est-dl'; dl.type = 'button'; dl.textContent = '⬇ Скачать в Excel';
dl.onclick = () => {
const gt = (data.totals || {}).grand_total;
const title = (data.title || 'Смета') + (typeof gt === 'number' ? ' (итого ' + fmtMoney(gt) + ' руб)' : '');
tableToExcel(panel.querySelector('.est-table'), 'смета.xlsx', title);
};
acts.appendChild(dl);
panel.appendChild(acts);
const ob = document.getElementById('onboarding'); if (ob) ob.remove();
msgs.appendChild(panel);
scrollIfPinned();
@@ -1370,6 +1386,14 @@ function addKaPanel(form) {
form.warnings.forEach(w => { const d = document.createElement('div'); d.textContent = w; warn.appendChild(d); });
panel.appendChild(warn);
}
const acts = document.createElement('div');
acts.className = 'est-actions';
const dl = document.createElement('button');
dl.className = 'est-dl'; dl.type = 'button'; dl.textContent = '⬇ Скачать в Excel';
dl.onclick = () => tableToExcel(panel.querySelector('.est-table'), 'конъюнктурный_анализ.xlsx',
'КА: ' + ((form.resource || {}).name || form.query || 'материал'));
acts.appendChild(dl);
panel.appendChild(acts);
const ob = document.getElementById('onboarding'); if (ob) ob.remove();
msgs.appendChild(panel);
scrollIfPinned();