radio для выбора базового договора + api set_initial (v1.0.57)
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
<body>
|
||||
<div class="topbar">
|
||||
<img src="/nubes-logo.svg" alt="Nubes">
|
||||
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.56 — Lucee</span></span>
|
||||
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.57 — Lucee</span></span>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
@@ -76,7 +76,7 @@
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Имя</th><th style="width:130px;">Изменён</th><th style="width:90px;">Размер</th><th style="width:115px;">Статус</th><th style="width:30px;"></th><th style="width:30px;"></th></tr>
|
||||
<tr><th>Имя</th><th style="width:130px;">Изменён</th><th style="width:90px;">Размер</th><th style="width:115px;">Статус</th><th style="width:30px;">Базовый</th><th style="width:30px;"></th><th style="width:30px;"></th></tr>
|
||||
</thead>
|
||||
<tbody id="fileTable"></tbody>
|
||||
</table>
|
||||
@@ -164,15 +164,20 @@ function formatDate(ts) {
|
||||
|
||||
function renderTable() {
|
||||
if (fileQueue.length === 0) {
|
||||
fileTable.innerHTML = '<tr class="empty-row"><td colspan="6">Нет файлов — выберите .docx / .pdf / .zip</td></tr>';
|
||||
fileTable.innerHTML = '<tr class="empty-row"><td colspan="7">Нет файлов — выберите .docx / .pdf / .zip</td></tr>';
|
||||
parseBtn.disabled = true;
|
||||
} else {
|
||||
fileTable.innerHTML = fileQueue.map(function(f, i) {
|
||||
var radio = '';
|
||||
if (f.supp_id) {
|
||||
radio = '<input type="radio" name="base_doc" value="' + f.supp_id + '"' + (f.supp_type === 'initial' ? ' checked' : '') + ' onchange="setInitial(\'' + f.supp_id + '\')" title="Выбрать как базовый договор">';
|
||||
}
|
||||
return '<tr id="row_' + i + '">' +
|
||||
'<td class="name-cell">' + f.name + '</td>' +
|
||||
'<td style="font-size:12px;color:var(--muted);">' + formatDate(f.lastModified) + '</td>' +
|
||||
'<td class="num-cell" style="font-size:12px;color:var(--muted);">' + formatSize(f.size) + '</td>' +
|
||||
'<td class="status-cell">' + (f.status || '') + '</td>' +
|
||||
'<td style="text-align:center;">' + radio + '</td>' +
|
||||
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" id="info_' + i + '" onclick="showInfo(' + i + ')" title="Инфо"><i data-lucide="info" style="width:16px;height:16px;"></i></button></td>' +
|
||||
'<td><button class="remove-btn" onclick="removeFile(' + i + ')" title="Удалить"><i data-lucide="trash-2" style="width:16px;height:16px;"></i></button></td>' +
|
||||
'</tr>';
|
||||
@@ -219,6 +224,8 @@ fileInput.addEventListener('change', async function() {
|
||||
renderTable();
|
||||
}
|
||||
|
||||
await refreshSupps();
|
||||
|
||||
fileInput.value = '';
|
||||
fileInput.disabled = false;
|
||||
parseBtn.disabled = (contractId === null);
|
||||
@@ -304,6 +311,9 @@ parseBtn.addEventListener('click', async function() {
|
||||
renderTable();
|
||||
}
|
||||
|
||||
// Обновить информацию о supplement_id/type для radio
|
||||
await refreshSupps();
|
||||
|
||||
parseBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px;"></i> ✓ Готово';
|
||||
var llmBtn = document.getElementById('llmBtn');
|
||||
llmBtn.style.display = 'flex';
|
||||
@@ -311,6 +321,34 @@ parseBtn.addEventListener('click', async function() {
|
||||
lucide.createIcons();
|
||||
});
|
||||
|
||||
// ── Обновить supplement_id/type для radio ──────────────────
|
||||
async function refreshSupps() {
|
||||
if (!contractId) return;
|
||||
try {
|
||||
var resp = await fetch('/api.cfm?action=query&sql=' + encodeURIComponent("SELECT s.id, s.type, s.document_id FROM supplements s WHERE s.contract_id='" + contractId + "'"));
|
||||
var data = await resp.json();
|
||||
if (data.OK && data.ROWS) {
|
||||
data.ROWS.forEach(function(r) {
|
||||
var supp = {};
|
||||
data.COLUMNS.forEach(function(c, ci) { supp[c] = r[ci]; });
|
||||
for (var i = 0; i < fileQueue.length; i++) {
|
||||
if (fileQueue[i].doc_id === supp.document_id) {
|
||||
fileQueue[i].supp_id = supp.id;
|
||||
fileQueue[i].supp_type = supp.type;
|
||||
}
|
||||
}
|
||||
});
|
||||
renderTable();
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function setInitial(suppId) {
|
||||
fetch('/api.cfm?action=set_initial&supplement_id=' + suppId)
|
||||
.then(function() { refreshSupps(); });
|
||||
}
|
||||
window.setInitial = setInitial;
|
||||
|
||||
// ── LLM: Сравнить ────────────────────────────────────────────
|
||||
document.getElementById('llmBtn').addEventListener('click', async function() {
|
||||
if (!contractId) return;
|
||||
|
||||
Reference in New Issue
Block a user