feat(ui): срез 7 — КА-форма панелью (офферы таблицей вместо 20-колон. markdown)
addKaPanel рендерит конъюнктурный анализ: заголовок+код ТЦ, ключевые графы офферов (поставщик/цены/перевозка/заготовит/сметная/регион/период), победитель подсвечен, маркер «нет в источнике» виден, принятая цена+медиана, предупреждения. build_ka_form авто-пишет _ka_panel.json → main эмитит event ka_form + role='ka_form' (restore, вне контекста LLM). Браузер-verified. APP_VERSION 2026-07-17o.
This commit is contained in:
@@ -121,6 +121,8 @@ button { font-family: inherit; }
|
||||
.est-tot-row .num { font-variant-numeric: tabular-nums; }
|
||||
.est-tot-strong { font-weight: 700; color: var(--text); font-size: .95rem; }
|
||||
.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; }
|
||||
.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; }
|
||||
|
||||
@@ -1198,6 +1200,9 @@ async function runChat(text) {
|
||||
} else if (eventType === 'estimate') {
|
||||
// Структурированная смета — панель с таблицей (срез 6.1, JS НЕ считает)
|
||||
if (data && data.positions) addEstimatePanel(data);
|
||||
} else if (eventType === 'ka_form') {
|
||||
// Конъюнктурный анализ — панель офферов (срез 7)
|
||||
if (data && data.rows) addKaPanel(data);
|
||||
}
|
||||
eventType = '';
|
||||
}
|
||||
@@ -1303,6 +1308,74 @@ function addEstimatePanel(data) {
|
||||
return panel;
|
||||
}
|
||||
|
||||
// --- Панель конъюнктурного анализа (срез 7): офферы таблицей + принятая цена ---
|
||||
function addKaPanel(form) {
|
||||
const panel = document.createElement('div');
|
||||
panel.className = 'est-panel';
|
||||
panel.setAttribute('role', 'region');
|
||||
panel.setAttribute('aria-label', 'Конъюнктурный анализ');
|
||||
const res = form.resource || {};
|
||||
const head = document.createElement('div');
|
||||
head.className = 'est-head';
|
||||
head.textContent = 'КА: ' + (res.name || form.query || 'материал');
|
||||
panel.appendChild(head);
|
||||
if (res.code_tc) {
|
||||
const sub = document.createElement('div');
|
||||
sub.className = 'ka-sub';
|
||||
sub.textContent = 'Код ТЦ: ' + res.code_tc;
|
||||
panel.appendChild(sub);
|
||||
}
|
||||
const scroll = document.createElement('div');
|
||||
scroll.className = 'est-scroll';
|
||||
const table = document.createElement('table');
|
||||
table.className = 'est-table';
|
||||
const thead = document.createElement('tr');
|
||||
['№', 'Поставщик', 'Цена с НДС', 'Без НДС', 'Перевозка', 'Заготовит.', 'Сметная', 'Регион', 'Год/кв'].forEach(h => {
|
||||
const th = document.createElement('th'); th.textContent = h; thead.appendChild(th);
|
||||
});
|
||||
table.appendChild(thead);
|
||||
(form.rows || []).forEach(r => {
|
||||
const tr = document.createElement('tr');
|
||||
// r — 20 граф по номерам; берём ключевые
|
||||
const cells = [r[1], r[14], fmtMoney(r[5]), fmtMoney(r[6]), fmtMoney(r[7]), fmtMoney(r[8]),
|
||||
fmtMoney(r[9]), r[18], (r[12] || '') + (r[13] ? ' / ' + r[13] : '')];
|
||||
cells.forEach((c, ci) => {
|
||||
const td = document.createElement('td');
|
||||
td.textContent = c == null ? '' : c;
|
||||
if (ci >= 2 && ci <= 6) td.className = 'num';
|
||||
tr.appendChild(td);
|
||||
});
|
||||
if (r.is_winner) tr.classList.add('ka-winner');
|
||||
table.appendChild(tr);
|
||||
});
|
||||
scroll.appendChild(table);
|
||||
panel.appendChild(scroll);
|
||||
|
||||
const a = form.accepted || {};
|
||||
if (a.winner != null || a.median != null) {
|
||||
const tot = document.createElement('div');
|
||||
tot.className = 'est-totals';
|
||||
[['Принятая (мин.)', a.winner], ['Медиана', a.median], ['Макс.', a.max]].filter(x => x[1] != null).forEach(([l, v]) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'est-tot-row' + (l.startsWith('Принятая') ? ' est-tot-strong' : '');
|
||||
const ls = document.createElement('span'); ls.textContent = l;
|
||||
const vs = document.createElement('span'); vs.className = 'num'; vs.textContent = fmtMoney(v) + ' ₽';
|
||||
row.appendChild(ls); row.appendChild(vs); tot.appendChild(row);
|
||||
});
|
||||
panel.appendChild(tot);
|
||||
}
|
||||
if (form.warnings && form.warnings.length) {
|
||||
const warn = document.createElement('div');
|
||||
warn.className = 'est-warn';
|
||||
form.warnings.forEach(w => { const d = document.createElement('div'); d.textContent = w; warn.appendChild(d); });
|
||||
panel.appendChild(warn);
|
||||
}
|
||||
const ob = document.getElementById('onboarding'); if (ob) ob.remove();
|
||||
msgs.appendChild(panel);
|
||||
scrollIfPinned();
|
||||
return panel;
|
||||
}
|
||||
|
||||
// --- Session ---
|
||||
async function newChat() {
|
||||
// New tab = new session, old one stays in DB and in the sidebar
|
||||
@@ -1388,6 +1461,9 @@ async function loadHistory() {
|
||||
else if (m.role === 'estimate') {
|
||||
try { addEstimatePanel(JSON.parse(m.content)); } catch {}
|
||||
}
|
||||
else if (m.role === 'ka_form') {
|
||||
try { addKaPanel(JSON.parse(m.content)); } catch {}
|
||||
}
|
||||
}
|
||||
} catch { if (!msgs.children.length) showOnboarding(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user