feat: add KS-3/payments, tech debt fixes, UI polish, and KS-2 Excel/Word export

Tasks 008-016: KS-6a journal, KS-3 documents, payments with allocations,
tech debt cleanup, financial privacy, document tree, storno mechanism,
row-click UI, BOQ collapse/sticky header, and KS-2 export to Excel/Word
via shared DTO architecture.
This commit is contained in:
Арсентьев Александр
2026-09-27 13:38:45 +03:00
parent 6c608a8779
commit 9cfb341774
57 changed files with 7163 additions and 50 deletions
+112 -15
View File
@@ -5,8 +5,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ document_title }} — {{ project.name }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.money-value { transition: filter 0.15s; }
.money-hidden .money-value { filter: blur(6px); user-select: none; pointer-events: none; }
.microstat-bar { min-width: 6rem; height: 0.5rem; }
.microstat-label { font-size: 0.75rem; white-space: nowrap; }
.boq-table { table-layout: fixed; width: 100%; }
.boq-table td, .boq-table th { overflow-wrap: anywhere; }
.boq-table .money-value { white-space: nowrap; overflow-wrap: normal; }
.boq-table thead th { position: sticky; top: 0; z-index: 10; background: #f8f9fa; }
.toggle-row { cursor: pointer; user-select: none; }
.toggle-row .toggle-icon { display: inline-block; width: 1.2em; transition: transform 0.15s; }
.toggle-row.collapsed .toggle-icon { transform: rotate(-90deg); }
</style>
</head>
<body>
<body class="money-hidden">
<main class="container my-4">
<nav aria-label="Навигация" class="mb-3">
<ol class="breadcrumb">
@@ -21,47 +34,94 @@
<h1>{{ document_title }}</h1>
<p class="text-muted mb-0">{{ project.name }}{% if document.source_file %} · {{ document.source_file }}{% endif %}</p>
</div>
<a class="btn btn-outline-secondary" href="/projects/{{ project.id }}">К проекту</a>
<div class="d-flex gap-2">
<button type="button" class="btn btn-outline-secondary btn-sm" id="expandAll">Развернуть всё</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="collapseAll">Свернуть всё</button>
<button type="button" class="btn btn-outline-secondary" id="toggleMoney" title="Показать/скрыть финансовые суммы" aria-label="Показать или скрыть финансовые суммы">👁</button>
{% if not has_history %}
<form method="post" action="/boq/{{ project.id }}/documents/{{ document.id }}/delete" class="d-inline">
<button type="submit" class="btn btn-outline-danger" onclick="return confirm('Удалить ведомость и все её позиции? Это действие необратимо.')">Удалить ведомость</button>
</form>
{% else %}
<form method="post" action="/boq/{{ project.id }}/documents/{{ document.id }}/archive" class="d-inline">
<button type="submit" class="btn btn-outline-warning" onclick="return confirm('Архивировать ведомость? Данные будут сохранены.')">Архивировать</button>
</form>
{% endif %}
<a class="btn btn-outline-secondary" href="/projects/{{ project.id }}">К проекту</a>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-sm align-middle">
<table class="table table-bordered table-sm align-middle boq-table">
<colgroup>
<col style="width: 3.5rem">
<col>
<col style="width: 9rem">
<col style="width: 9rem">
<col style="width: 4.5rem">
<col style="width: 5.5rem">
<col style="width: 7.5rem">
<col style="width: 8.5rem">
<col style="width: 11rem">
</colgroup>
<thead class="table-light">
<tr>
<th>№</th><th>Наименование</th><th>Модель / артикул</th><th>Производитель</th>
<th>Ед. изм.</th><th class="text-end">Кол-во</th><th class="text-end">Цена за ед.</th><th class="text-end">Сумма</th>
<th>Выполнение</th>
</tr>
</thead>
<tbody>
{% for system_node in systems %}
<tr class="table-primary">
<th colspan="7">Система: {{ system_node.system.name }}</th>
<th class="text-end">{{ system_node.total|money(project.currency) }}</th>
<tr class="table-primary toggle-row" data-toggle="system-{{ system_node.system.id }}">
<th colspan="8"><span class="toggle-icon">▼</span> Система: {{ system_node.system.name }}</th>
<th class="text-end money-value">{{ system_node.total|money(project.currency) }}</th>
</tr>
{% for section_node in system_node.sections %}
<tr class="table-success">
<th colspan="7">Раздел: {{ section_node.section.name }}</th>
<th class="text-end">{{ section_node.total|money(project.currency) }}</th>
<tr class="table-success toggle-row" data-toggle="section-{{ section_node.section.id }}" data-parent="system-{{ system_node.system.id }}">
<th colspan="8"><span class="toggle-icon">▼</span> Раздел: {{ section_node.section.name }}</th>
<th class="text-end money-value">{{ section_node.total|money(project.currency) }}</th>
</tr>
{% for item in section_node["items"] %}
<tr>
{% set done = completed_by_item.get(item.id, 0) %}
{% set planned = item.quantity if item.quantity is not none else 0 %}
{% set pct = (done / planned * 100) if planned else 0 %}
<tr data-parent="section-{{ section_node.section.id }}">
<td>{{ item.source_number or '' }}</td>
<td>{{ item.name }}</td>
<td>{{ item.model or '' }}</td>
<td>{{ item.manufacturer or '' }}</td>
<td>{{ item.unit or '' }}</td>
<td class="text-end">{{ item.quantity if item.quantity is not none else '' }}</td>
<td class="text-end">{{ item.unit_price|money(project.currency) if item.unit_price is not none else '' }}</td>
<td class="text-end">{{ item.amount|money(project.currency) if item.amount is not none else '' }}</td>
<td class="text-end money-value">{{ item.unit_price|money(project.currency) if item.unit_price is not none else '' }}</td>
<td class="text-end money-value">{{ item.amount|money(project.currency) if item.amount is not none else '' }}</td>
<td>
{% if planned %}
<div class="microstat-label text-muted mb-1">Выполнено: {{ done|round(2) }} / {{ planned }}</div>
<div class="progress microstat-bar">
{% if pct == 0 %}
<div class="progress-bar bg-secondary" style="width: 100%"></div>
{% elif pct < 50 %}
<div class="progress-bar bg-warning" style="width: {{ pct }}%"></div>
{% elif pct < 100 %}
<div class="progress-bar bg-primary" style="width: {{ pct }}%"></div>
{% elif pct == 100 %}
<div class="progress-bar bg-success" style="width: 100%"></div>
{% else %}
<div class="progress-bar bg-danger" style="width: 100%"></div>
{% endif %}
</div>
{% endif %}
</td>
</tr>
{% endfor %}
{% endfor %}
{% else %}
<tr><td colspan="8" class="text-center text-muted py-4">В документе нет рабочих позиций.</td></tr>
<tr><td colspan="9" class="text-center text-muted py-4">В документе нет рабочих позиций.</td></tr>
{% endfor %}
<tr class="table-dark fw-bold">
<td colspan="7">Итого по ведомости</td>
<td class="text-end">{{ total|money(project.currency) }}</td>
<td colspan="8">Итого по ведомости</td>
<td class="text-end money-value">{{ total|money(project.currency) }}</td>
</tr>
</tbody>
</table>
@@ -71,5 +131,42 @@
<div class="alert alert-warning mt-3">В документе есть {{ unassigned_items|length }} позиций без полной привязки к системе и разделу.</div>
{% endif %}
</main>
<script>
(function() {
var moneyBtn = document.getElementById('toggleMoney');
if (moneyBtn) moneyBtn.addEventListener('click', function() {
document.body.classList.toggle('money-hidden');
});
function toggleGroup(id, collapsed) {
document.querySelectorAll('[data-parent="' + id + '"]').forEach(function(el) {
el.style.display = collapsed ? 'none' : '';
if (el.dataset.toggle) toggleGroup(el.dataset.toggle, collapsed);
});
var header = document.querySelector('[data-toggle="' + id + '"]');
if (header) header.classList.toggle('collapsed', collapsed);
}
document.querySelectorAll('.toggle-row').forEach(function(row) {
row.addEventListener('click', function() {
var id = row.dataset.toggle;
if (!id) return;
var isCollapsed = row.classList.contains('collapsed');
toggleGroup(id, !isCollapsed);
});
});
document.getElementById('expandAll').addEventListener('click', function() {
document.querySelectorAll('.toggle-row').forEach(function(row) {
if (row.dataset.toggle) toggleGroup(row.dataset.toggle, false);
});
});
document.getElementById('collapseAll').addEventListener('click', function() {
document.querySelectorAll('.toggle-row').forEach(function(row) {
if (row.dataset.toggle) toggleGroup(row.dataset.toggle, true);
});
});
})();
</script>
</body>
</html>