Новые страницы: - /wizard — агрегатор xlsx (7-шаговый мастер) - /generate — генерация сметы из описания работ (4 шага → Excel) - /reference — справочники НР/СП/ГЭСН - /check — проверка YAML-конфига сметы Используют smeta-railway как библиотеку (wizard_api, generator_api, chat_api, checker). Кнопки добавлены в header чата. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
138 lines
6.2 KiB
HTML
138 lines
6.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Проверка сметы</title>
|
|
<style>
|
|
:root {
|
|
--bg: #f5f0eb; --bg-card: #ffffff;
|
|
--text: #3a3a3a; --text-muted: #6b6b6b;
|
|
--border: #d4c5b2; --border-light: #ede5db;
|
|
--accent: #c4463a; --accent-hover: #a83830;
|
|
--success: #2b8a3e; --warn: #e8590c; --danger: #e03131; --info: #1971c2;
|
|
--shadow-md: 0 4px 16px rgba(0,0,0,.07);
|
|
--radius: 10px; --radius-lg: 16px;
|
|
}
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); }
|
|
.container { max-width: 860px; margin: 24px auto; padding: 0 16px; }
|
|
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
|
|
.header h1 { font-size: 1.2rem; font-weight: 700; }
|
|
.header a { color: var(--accent); text-decoration: none; font-size: .85rem; font-weight: 500; }
|
|
.card { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 24px; margin-bottom: 16px; }
|
|
label { display: block; font-size: .85rem; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
|
|
textarea { width: 100%; padding: .6rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .82rem; font-family: 'SF Mono', Menlo, monospace; background: var(--bg); outline: none; resize: vertical; min-height: 200px; }
|
|
textarea:focus { border-color: var(--accent); background: var(--bg-card); }
|
|
.btn { padding: .55rem 1.2rem; border: none; border-radius: var(--radius); font-size: .85rem; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff; }
|
|
.btn:hover { background: var(--accent-hover); }
|
|
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
|
|
.result-item { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 6px; font-size: .88rem; display: flex; align-items: flex-start; gap: 8px; }
|
|
.result-item.error { background: #fff1f2; border-left: 3px solid var(--danger); }
|
|
.result-item.warning { background: #fff9db; border-left: 3px solid var(--warn); }
|
|
.result-item.info { background: #e7f5ff; border-left: 3px solid var(--info); }
|
|
.icon { font-size: 1rem; flex-shrink: 0; }
|
|
.summary { display: flex; gap: 12px; margin-bottom: 16px; }
|
|
.badge { padding: 4px 12px; border-radius: 10px; font-size: .8rem; font-weight: 600; }
|
|
.badge-err { background: #ffe3e3; color: var(--danger); }
|
|
.badge-warn { background: #fff3bf; color: var(--warn); }
|
|
.badge-info { background: #dbeafe; color: var(--info); }
|
|
.mt-2 { margin-top: 8px; }
|
|
.mt-3 { margin-top: 12px; }
|
|
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
.d-none { display: none !important; }
|
|
.or { text-align: center; color: var(--text-muted); font-size: .85rem; margin: 8px 0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>Проверка сметы</h1>
|
|
<a href="/">← Назад к чату</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<label>Загрузите YAML-файл проекта:</label>
|
|
<input type="file" id="yamlFile" accept=".yaml,.yml" style="padding:.4rem;border:1.5px solid var(--border);border-radius:var(--radius);width:100%;font-size:.9rem;background:var(--bg)">
|
|
<div class="or">или вставьте YAML вручную:</div>
|
|
<textarea id="yamlInput" placeholder="sections:
|
|
- name: Глава 1
|
|
subsections:
|
|
- items:
|
|
- code: 28-01-037-02
|
|
name: Замена шпал
|
|
unit: шт
|
|
qty: 100
|
|
coefficients:
|
|
definitions:
|
|
- key: dvizhenie
|
|
value: 1.40"></textarea>
|
|
<button class="btn mt-2" onclick="check()" id="checkBtn">
|
|
<span id="checkSpin" class="spinner d-none"></span> Проверить
|
|
</button>
|
|
</div>
|
|
|
|
<div id="reportCard" class="card d-none">
|
|
<div class="summary" id="summary"></div>
|
|
<div id="report"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function $(id){return document.getElementById(id);}
|
|
|
|
$('yamlFile').addEventListener('change', function(e) {
|
|
const file = e.target.files[0];
|
|
if (file) {
|
|
const reader = new FileReader();
|
|
reader.onload = (ev) => $('yamlInput').value = ev.target.result;
|
|
reader.readAsText(file);
|
|
}
|
|
});
|
|
|
|
async function check() {
|
|
const yaml = $('yamlInput').value.trim();
|
|
if (!yaml) return;
|
|
$('checkSpin').classList.remove('d-none'); $('checkBtn').disabled = true;
|
|
$('reportCard').classList.add('d-none');
|
|
|
|
try {
|
|
const r = await fetch('/api/check/yaml', {
|
|
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({yaml})
|
|
});
|
|
const d = await r.json();
|
|
|
|
if (d.error) {
|
|
$('summary').innerHTML = `<span class="badge badge-err">Ошибка парсинга</span>`;
|
|
$('report').innerHTML = `<div class="result-item error"><span class="icon">❌</span>${esc(d.error)}</div>`;
|
|
} else {
|
|
let sum = '';
|
|
if (d.errors) sum += `<span class="badge badge-err">${d.errors} ошибок</span>`;
|
|
if (d.warnings) sum += `<span class="badge badge-warn">${d.warnings} предупреждений</span>`;
|
|
if (!d.errors && !d.warnings) sum += `<span class="badge badge-info">Всё в порядке</span>`;
|
|
$('summary').innerHTML = sum;
|
|
|
|
let h = '';
|
|
for (const r of d.results) {
|
|
const cls = r.level;
|
|
const icon = r.level === 'error' ? '❌' : r.level === 'warning' ? '⚠️' : 'ℹ️';
|
|
const pos = r.position ? ` <span style="color:var(--text-muted)">[${esc(r.position)}]</span>` : '';
|
|
h += `<div class="result-item ${cls}"><span class="icon">${icon}</span><span>${esc(r.message)}${pos}</span></div>`;
|
|
}
|
|
$('report').innerHTML = h;
|
|
}
|
|
$('reportCard').classList.remove('d-none');
|
|
} catch(e) {
|
|
alert(e.message);
|
|
} finally {
|
|
$('checkSpin').classList.add('d-none'); $('checkBtn').disabled = false;
|
|
}
|
|
}
|
|
|
|
function esc(s) { return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
|
</script>
|
|
</body>
|
|
</html>
|