feat(ui): срез 6.1 — панель сметы (просмотр): событие estimate → таблица + итоги
addEstimatePanel рендерит структурированную смету (событие estimate стрима, как files): таблица позиций, итоги СТРОГО из data.totals (JS не считает), нерассчитанные позиции подсвечены, warnings/missing показаны честно, XSS-safe (textContent), таблица со своим горизонт-скроллом. Инфраструктура для панели — инертна пока бэкенд не эмитит estimate. APP_VERSION 2026-07-17m. Браузер-verified.
This commit is contained in:
@@ -51,12 +51,23 @@ function _json(o, status=200){ return new Response(JSON.stringify(o),{status,hea
|
||||
window.fetch = async (url, opts={}) => {
|
||||
url = String(url); opts = opts || {};
|
||||
if (url.includes('/api/chat')) {
|
||||
const msg = (()=>{ try { return JSON.parse(opts.body||'{}').message||''; } catch(e){ return ''; } })();
|
||||
const evs = [
|
||||
'event: tool\ndata: {"tool":"mcp__smeta__verify_estimate_file"}\n\n',
|
||||
'event: text\ndata: {"text":"Считаю смету"}\n\n',
|
||||
'event: text\ndata: {"text":" — готово."}\n\n',
|
||||
'event: done\ndata: {"result":"ok"}\n\n',
|
||||
];
|
||||
if (/смет|estimate/i.test(msg)) {
|
||||
const est = {title:'Смета №1', ok:false,
|
||||
positions:[
|
||||
{code:'01-01-001-01', name:'Разработка грунта', unit:'м3', qty:100, unit_cost:150.5, total:15050},
|
||||
{code:'06-01-001-02', name:'Бетон', unit:'м3', qty:20, unit_cost:5000, total:100000, unresolved:true}],
|
||||
totals:{grand_pz:115050, grand_nr:10000, grand_sp:5000, grand_total:130050, vat:28611, total_with_vat:158661},
|
||||
warnings:['Проверьте объёмы по ведомости'],
|
||||
missing:[{code:'06-01-001-02', reason:'цена материала не найдена'}]};
|
||||
evs.push('event: estimate\ndata: ' + JSON.stringify(est) + '\n\n');
|
||||
}
|
||||
evs.push('event: done\ndata: {"result":"ok"}\n\n');
|
||||
return new Response(_sse(evs, opts.signal), {status:200, headers:{'Content-Type':'text/event-stream'}});
|
||||
}
|
||||
if (url.includes('/api/feedback')) { window._fb++; return _json({}); }
|
||||
|
||||
Reference in New Issue
Block a user