From 03f6e1456adcfdc206d66e8f7bbc76244933784b Mon Sep 17 00:00:00 2001 From: Dauren777 Date: Wed, 24 Jun 2026 07:46:12 +0000 Subject: [PATCH] =?UTF-8?q?v7:=20saveTemplate=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D0=B1=D0=B5=D1=80=D1=91=D1=82=20=D0=9A=D0=90?= =?UTF-8?q?=D0=A2=D0=9E=20=D0=BD=D0=B0=D0=BF=D1=80=D1=8F=D0=BC=D1=83=D1=8E?= =?UTF-8?q?=20=D0=B8=D0=B7=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA=D0=B8,?= =?UTF-8?q?=20loadTemplate/autoProcess=20=D0=B8=D1=89=D1=83=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8E=20?= =?UTF-8?q?=D0=9A=D0=90=D0=A2=D0=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index b24580d..c023036 100644 --- a/index.html +++ b/index.html @@ -374,24 +374,45 @@ 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); + + // build list of КАТО codes directly from the data + const katoIx = dataColumns.indexOf('kato'); + if (katoIx === -1) { alert('Колонка КАТО не найдена. Проверьте название колонки.'); return; } + + const katoHeader = allData.columns[katoIx]; + const katoCodes = []; + allData.forEach(row => { + if (markedIds.has(row._id)) { + const code = String(row[katoHeader] || '').trim(); + if (code) katoCodes.push(code); + } + }); + + if (katoCodes.length === 0) { + alert('Отмеченные строки не содержат КАТО-коды. Проверьте колонку "' + katoHeader + '".'); + return; + } + + localStorage.setItem(TEMPLATE_KEY, JSON.stringify(katoCodes)); + document.getElementById('templateStatus').textContent = `✅ Шаблон сохранён (${katoCodes.length} кодов)`; + setTimeout(() => document.getElementById('templateStatus').textContent = '', 5000); } function loadTemplate() { const raw = localStorage.getItem(TEMPLATE_KEY); if (!raw) { alert('Нет сохранённого шаблона. Сначала отметьте пункты и сохраните.'); return; } const saved = JSON.parse(raw); + const katoIx = dataColumns.indexOf('kato'); + if (katoIx === -1) { alert('Колонка КАТО не найдена'); return; } + const katoHeader = allData.columns[katoIx]; let found = 0; allData.forEach(r => { - if (saved.includes(r._id)) { markedIds.add(r._id); found++; } + const code = String(r[katoHeader] || '').trim(); + if (code && saved.includes(code)) { markedIds.add(r._id); found++; } }); renderTable(); document.getElementById('templateStatus').textContent = `📂 Применено: ${found} совпадений`; - setTimeout(() => document.getElementById('templateStatus').textContent = '', 3000); + setTimeout(() => document.getElementById('templateStatus').textContent = '', 4000); } const KATO_REGIONS = { @@ -440,9 +461,13 @@ function autoProcess() { const raw = localStorage.getItem(TEMPLATE_KEY); if (!raw) return; const saved = JSON.parse(raw); + const katoIx = dataColumns.indexOf('kato'); + if (katoIx === -1) return; + const katoHeader = allData.columns[katoIx]; let found = 0; allData.forEach(r => { - if (saved.includes(r._id)) { markedIds.add(r._id); found++; } + const code = String(r[katoHeader] || '').trim(); + if (code && saved.includes(code)) { markedIds.add(r._id); found++; } }); renderTable(); if (found > 0) {