v3.3.0: чат с договором — задать вопрос по spec_rows
This commit is contained in:
@@ -104,6 +104,21 @@
|
||||
</div>
|
||||
<div class="card-body" id="diffBody"></div>
|
||||
</div>
|
||||
|
||||
<!-- Чат с договором -->
|
||||
<div class="card" id="chatCard" style="display:none;margin-top:16px;">
|
||||
<div class="card-header">
|
||||
<i data-lucide="message-circle" style="width:18px;height:18px;"></i>
|
||||
Задать вопрос по договору
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="chatMessages" style="margin-bottom:8px;font-size:13px;"></div>
|
||||
<div style="display:flex;gap:8px;">
|
||||
<input type="text" id="chatInput" placeholder="Какая общая сумма? Что изменилось? ..." style="flex:1;height:32px;border:1px solid var(--brand-gray);border-radius:6px;padding:0 8px;font-size:13px;">
|
||||
<button class="btn btn-primary" id="chatSend" style="height:32px;font-size:13px;">→</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="modalOverlay" onclick="closeModal(event)">
|
||||
@@ -485,6 +500,10 @@
|
||||
lucide.createIcons();
|
||||
diffStatus.textContent = '✓ ' + d.total_time_s + 'с';
|
||||
|
||||
// Показать чат
|
||||
document.getElementById('chatCard').style.display = 'block';
|
||||
lucide.createIcons();
|
||||
|
||||
var all = d.all_changes || [];
|
||||
if (all.length === 0) {
|
||||
diffBody.innerHTML += '<div style="color:var(--muted);margin-top:8px;">Нет допников для сравнения.</div>';
|
||||
@@ -530,6 +549,43 @@
|
||||
return v != null ? v : '—';
|
||||
}
|
||||
|
||||
// ── Чат ──────────────────────────────────────────────────────
|
||||
|
||||
document.getElementById('chatSend').addEventListener('click', function() {
|
||||
var input = document.getElementById('chatInput');
|
||||
var q = input.value.trim();
|
||||
if (!q || !contractId) return;
|
||||
|
||||
var msgs = document.getElementById('chatMessages');
|
||||
msgs.innerHTML += '<div style="color:var(--brand-primary);margin-top:4px;"><strong>Вы:</strong> ' + q + '</div>';
|
||||
input.value = '';
|
||||
input.disabled = true;
|
||||
document.getElementById('chatSend').disabled = true;
|
||||
msgs.innerHTML += '<div style="color:var(--muted);margin-top:2px;">⏳ Думаю...</div>';
|
||||
|
||||
fetch('/llm/chat/' + contractId, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({question: q})
|
||||
}).then(function(r) { return r.json(); })
|
||||
.then(function(d) {
|
||||
msgs.lastChild.remove(); // убрать "Думаю..."
|
||||
msgs.innerHTML += '<div style="margin-top:2px;"><strong>Ответ:</strong> ' + (d.answer || d.error || '—') + '</div>';
|
||||
input.disabled = false;
|
||||
document.getElementById('chatSend').disabled = false;
|
||||
input.focus();
|
||||
}).catch(function() {
|
||||
msgs.lastChild.remove();
|
||||
msgs.innerHTML += '<div style="color:var(--destructive);margin-top:2px;">Ошибка сети</div>';
|
||||
input.disabled = false;
|
||||
document.getElementById('chatSend').disabled = false;
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('chatInput').addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') document.getElementById('chatSend').click();
|
||||
});
|
||||
|
||||
var style = document.createElement('style');
|
||||
style.textContent = '@keyframes spin { to { transform: rotate(360deg); } }';
|
||||
document.head.appendChild(style);
|
||||
|
||||
Reference in New Issue
Block a user