diff --git a/api.cfm b/api.cfm index 610ff18..c9320b9 100644 --- a/api.cfm +++ b/api.cfm @@ -117,6 +117,31 @@ #preserveSingleQuotes(body.sql)# + + + + + + + + SELECT contract_id FROM supplements WHERE id= + + + + + + + UPDATE supplements SET type='additional' + WHERE contract_id= + + + UPDATE supplements SET type='initial' + WHERE id= + + + + + diff --git a/index.cfm b/index.cfm index 6135e47..73dc218 100644 --- a/index.cfm +++ b/index.cfm @@ -61,7 +61,7 @@
Nubes - Сверка договоров — LLM v1.0.56 — Lucee + Сверка договоров — LLM v1.0.57 — Lucee
@@ -76,7 +76,7 @@
- +
ИмяИзменёнРазмерСтатус
ИмяИзменёнРазмерСтатусБазовый
@@ -164,15 +164,20 @@ function formatDate(ts) { function renderTable() { if (fileQueue.length === 0) { - fileTable.innerHTML = 'Нет файлов — выберите .docx / .pdf / .zip'; + fileTable.innerHTML = 'Нет файлов — выберите .docx / .pdf / .zip'; parseBtn.disabled = true; } else { fileTable.innerHTML = fileQueue.map(function(f, i) { + var radio = ''; + if (f.supp_id) { + radio = ''; + } return '' + '' + f.name + '' + '' + formatDate(f.lastModified) + '' + '' + formatSize(f.size) + '' + '' + (f.status || '') + '' + + '' + radio + '' + '' + '' + ''; @@ -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 = ' ✓ Готово'; 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;