diff --git a/docs/cabinet.html b/docs/cabinet.html index 3111c13..0515f2a 100644 --- a/docs/cabinet.html +++ b/docs/cabinet.html @@ -207,7 +207,15 @@ body{font-family:'Inter',sans-serif;background:var(--bg);color:var(--text);displ
📁
Этап 3 из 5
Документы
Загрузите материалы — Елена учтёт их в анализе
-
📎
Перетащите документы сюда
Прайс, оргструктура, отчёты — что есть
+
+
+
📎
+
Нажмите или перетащите документы
+
PDF, Word, Excel, txt · прайс, оргструктура, отчёты
+ +
+
+
@@ -244,6 +252,7 @@ function go(n){ document.querySelectorAll('.si').forEach(s=>s.classList.remove('active')); document.getElementById('si'+n).classList.add('active'); if(PCTS[n]!=null){document.getElementById('pbPct').textContent=PCTS[n]+'%';document.getElementById('pbFill').style.width=PCTS[n]+'%';} + if(n===3)renderDocs(); if(n===4)renderAnalysis(); if(n===5)renderSpecPane(); } @@ -298,6 +307,27 @@ function fillProfile(){ if(state.niche)document.getElementById("pfNiche").value=state.niche; if(state.description)document.getElementById("pfDesc").value=state.description; } + +/* ── Документы (Этап 3) ── */ +function renderDocs(){ + const dl=document.getElementById("docList");if(!dl)return; + const docs=state.documents||[]; + dl.innerHTML=docs.length?docs.map(d=>`
📄
${esc(d.filename)}
${(d.size/1024).toFixed(0)} КБ · учтён в анализе
`).join(""):'
Документов пока нет
'; +} +async function handleFiles(files){ + const dl=document.getElementById("docList"); + for(const f of files){ + const tmp=document.createElement("div");tmp.style.cssText="background:var(--white);border:1px solid var(--border);border-radius:10px;padding:11px 14px;margin-bottom:8px;font-size:13px";tmp.innerHTML=` ${esc(f.name)} — загрузка...`;dl.prepend(tmp); + try{ + const b64=await new Promise((res,rej)=>{const r=new FileReader();r.onload=()=>res(r.result);r.onerror=rej;r.readAsDataURL(f)}); + const r=await fetch(`${API}/api/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token,filename:f.name,content:b64})}); + const d=await r.json(); + if(d.error){tmp.innerHTML=`❌ ${esc(f.name)}: ${d.error}`;continue} + state.documents=state.documents||[];state.documents.push({filename:d.filename,size:d.size}); + }catch(e){tmp.innerHTML=`❌ ${esc(f.name)}: ${e.message}`;continue} + } + renderDocs(); +} function renderAll(){ if(state.client_name)document.getElementById("hdrClient").textContent="· "+state.client_name; chat.innerHTML="";