From 5c2a822f2dce96dd6cf2fc8759ba234dc18500a4 Mon Sep 17 00:00:00 2001 From: Dauren777 Date: Wed, 24 Jun 2026 05:41:04 +0000 Subject: [PATCH] =?UTF-8?q?v3:=20=D0=B0=D0=B2=D1=82=D0=BE-=D1=80=D0=B5?= =?UTF-8?q?=D0=B6=D0=B8=D0=BC=20=E2=80=94=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE?= =?UTF-8?q?=D0=BD=20=D0=BE=D1=82=D0=BC=D0=B5=D1=82=D0=BE=D0=BA=20+=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20+=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index f92bb96..c3abea7 100644 --- a/index.html +++ b/index.html @@ -123,6 +123,16 @@ tbody tr.marked:hover{background:var(--green-bg)} +
+ + + + + +
+
@@ -349,6 +359,48 @@ function toggleGroup(groupName) { renderTable(); } +const TEMPLATE_KEY = 'snp_marked_template'; + +function saveTemplate() { + if (markedIds.size === 0) { alert('Нет отмеченных пунктов. Сначала отметьте.'); return; } + const arr = [...markedIds].filter(id => !id.startsWith('row_')); + if (arr.length === 0) { alert('Не найдены КАТО-коды. Отметка работает только если в файле есть колонка КАТО.'); return; } + localStorage.setItem(TEMPLATE_KEY, JSON.stringify(arr)); + document.getElementById('templateStatus').textContent = `✅ Шаблон сохранён (${arr.length} кодов)`; + setTimeout(() => document.getElementById('templateStatus').textContent = '', 3000); +} + +function loadTemplate() { + const raw = localStorage.getItem(TEMPLATE_KEY); + if (!raw) { alert('Нет сохранённого шаблона. Сначала отметьте пункты и сохраните.'); return; } + const saved = JSON.parse(raw); + let found = 0; + allData.forEach(r => { + if (saved.includes(r._id)) { markedIds.add(r._id); found++; } + }); + renderTable(); + document.getElementById('templateStatus').textContent = `📂 Применено: ${found} совпадений`; + setTimeout(() => document.getElementById('templateStatus').textContent = '', 3000); +} + +function autoProcess() { + const raw = localStorage.getItem(TEMPLATE_KEY); + if (!raw) return; + const saved = JSON.parse(raw); + let found = 0; + allData.forEach(r => { + if (saved.includes(r._id)) { markedIds.add(r._id); found++; } + }); + renderTable(); + if (found > 0) { + setTimeout(() => { + document.getElementById('exportBtn').click(); + document.getElementById('templateStatus').textContent = `🤖 Авто: отмечено ${found}, файл скачан`; + setTimeout(() => document.getElementById('templateStatus').textContent = '', 4000); + }, 500); + } +} + function handleFile(file) { const reader = new FileReader(); reader.onload = function(e) { @@ -370,8 +422,8 @@ function handleFile(file) { }); allData.columns = headers; - // init marked from localStorage markedIds = new Set(); + updateTemplateStatus(); const zone = document.getElementById('dropZone'); zone.classList.add('has-file'); @@ -381,6 +433,10 @@ function handleFile(file) { renderFilters(); applyFilter(); document.getElementById('resultArea').classList.remove('hidden'); + + if (document.getElementById('autoMode').checked) { + autoProcess(); + } } catch(err) { alert('Ошибка: ' + err.message); } @@ -388,6 +444,17 @@ function handleFile(file) { reader.readAsArrayBuffer(file); } +function updateTemplateStatus() { + const raw = localStorage.getItem(TEMPLATE_KEY); + const el = document.getElementById('templateStatus'); + if (raw) { + const saved = JSON.parse(raw); + el.textContent = `📁 Шаблон: ${saved.length} кодов`; + } else { + el.textContent = ''; + } +} + document.getElementById('fileInput').onchange = e => { if (e.target.files[0]) handleFile(e.target.files[0]); }; const dz = document.getElementById('dropZone'); dz.onclick = () => document.getElementById('fileInput').click(); @@ -395,6 +462,10 @@ dz.ondragover = e => { e.preventDefault(); dz.classList.add('dragover'); }; dz.ondragleave = () => dz.classList.remove('dragover'); dz.ondrop = e => { e.preventDefault(); dz.classList.remove('dragover'); if (e.dataTransfer.files[0]) handleFile(e.dataTransfer.files[0]); }; +document.getElementById('saveTemplateBtn').onclick = saveTemplate; +document.getElementById('loadTemplateBtn').onclick = loadTemplate; +updateTemplateStatus(); + document.getElementById('markAllBtn').onclick = () => { const btn = document.getElementById('markAllBtn'); const allMarked = filteredData.length > 0 && filteredData.every(r => markedIds.has(r._id));