feat: batch V2 — показываем паттерны вместо скрипта + ссылка с главной
- Claude генерирует batch_summary.json с найденными паттернами - UI показывает сметчику: лист, шифр, паттерны итогов, маппинг столбцов - Скрипт скрыт в <details> для разработчиков - Кнопка «Пакетная V2» на главной странице чата Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+52
-4
@@ -64,11 +64,14 @@ pre { background: #2c2c2c; color: #f5f0eb; padding: .8rem; border-radius: 6px; o
|
||||
<div class="log" id="analyze-log"></div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Confirm script -->
|
||||
<!-- Step 3: Confirm -->
|
||||
<div class="card hidden" id="step-confirm">
|
||||
<label>3. Сгенерированный скрипт</label>
|
||||
<p class="hint">Проверьте скрипт и нажмите «Запустить»</p>
|
||||
<pre id="script-code"></pre>
|
||||
<label>3. Проверьте найденные параметры</label>
|
||||
<div id="summary-view" style="font-size:.9rem;line-height:1.6"></div>
|
||||
<details style="margin-top:.8rem">
|
||||
<summary style="cursor:pointer;color:var(--muted);font-size:.8rem">Показать скрипт (для разработчиков)</summary>
|
||||
<pre id="script-code"></pre>
|
||||
</details>
|
||||
<div style="display:flex;gap:.5rem;margin-top:.8rem">
|
||||
<button onclick="runScript()">Запустить обработку</button>
|
||||
<button onclick="reanalyze()" style="background:var(--border);color:var(--text)">Переанализировать</button>
|
||||
@@ -163,6 +166,7 @@ async function startAnalysis() {
|
||||
if (d.script) {
|
||||
document.getElementById('analyze-status').textContent = 'Анализ завершён';
|
||||
document.getElementById('script-code').textContent = d.script;
|
||||
renderSummary(d.summary);
|
||||
show('step-confirm');
|
||||
} else {
|
||||
document.getElementById('analyze-status').textContent = 'Claude не сгенерировал скрипт';
|
||||
@@ -221,6 +225,50 @@ async function pollStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
function renderSummary(s) {
|
||||
const el = document.getElementById('summary-view');
|
||||
if (!s || !s.source_patterns) {
|
||||
el.innerHTML = '<p style="color:var(--muted)">Параметры не распознаны — проверьте скрипт вручную</p>';
|
||||
return;
|
||||
}
|
||||
const src = s.source_patterns || {};
|
||||
const tgt = s.target_mapping || {};
|
||||
let html = '';
|
||||
if (s.description) html += `<p><b>${s.description}</b></p>`;
|
||||
|
||||
html += '<table style="width:100%;border-collapse:collapse;margin:.5rem 0;font-size:.85rem">';
|
||||
html += '<tr style="background:#ede5db"><td colspan="2" style="padding:6px;font-weight:600">Исходные файлы</td></tr>';
|
||||
if (src.sheet) html += row('Лист', src.sheet);
|
||||
if (src.id_field) html += row('Шифр/название', src.id_field);
|
||||
if (src.value_column) html += row('Столбец значений', src.value_column);
|
||||
if (src.units) html += row('Единицы', src.units);
|
||||
|
||||
if (src.totals) {
|
||||
html += '<tr style="background:#ede5db"><td colspan="2" style="padding:6px;font-weight:600">Паттерны поиска итогов</td></tr>';
|
||||
for (const [k, v] of Object.entries(src.totals)) {
|
||||
html += row(k, '<code>' + v + '</code>');
|
||||
}
|
||||
}
|
||||
|
||||
html += '<tr style="background:#ede5db"><td colspan="2" style="padding:6px;font-weight:600">Сводный файл</td></tr>';
|
||||
if (tgt.sheet) html += row('Лист', tgt.sheet);
|
||||
if (tgt.match_column) html += row('Столбец сопоставления', tgt.match_column);
|
||||
if (tgt.value_columns) {
|
||||
for (const [k, v] of Object.entries(tgt.value_columns)) {
|
||||
html += row(k + ' →', 'столбец ' + v);
|
||||
}
|
||||
}
|
||||
if (tgt.units) html += row('Единицы', tgt.units);
|
||||
if (s.conversion) html += row('Конвертация', s.conversion);
|
||||
|
||||
html += '</table>';
|
||||
el.innerHTML = html;
|
||||
|
||||
function row(label, value) {
|
||||
return `<tr><td style="padding:4px 6px;border-bottom:1px solid #eee;color:var(--muted);width:40%">${label}</td><td style="padding:4px 6px;border-bottom:1px solid #eee">${value}</td></tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
function downloadResult() {
|
||||
fetch('/api/batch-v2/download/' + jobId, {headers: H})
|
||||
.then(r => r.blob())
|
||||
|
||||
Reference in New Issue
Block a user