feat: add BOQ progress filter and fix horizontal table overflow

This commit is contained in:
Арсентьев Александр
2026-10-01 12:38:01 +03:00
parent bc69e52174
commit 79c7d4f335
8 changed files with 1355 additions and 18 deletions
+75 -18
View File
@@ -6,19 +6,13 @@
<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-value { transition: filter 0.15s; white-space: nowrap; }
.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; }
.microstat-label { font-size: 0.75rem; }
.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; }
/*
* Sticky header requires its own scrollport. Bootstrap .table-responsive
* (overflow-x: auto) forces overflow-y to auto and creates a container
* that does not scroll vertically, so position:sticky never sticks to the page.
* This wrapper scrolls both axes; thead th sticks to its top.
*/
.boq-table .money-value { overflow-wrap: normal; }
.boq-table-wrap {
max-height: calc(100vh - 12rem);
overflow: auto;
@@ -29,12 +23,23 @@
top: 0;
z-index: 10;
background-color: #f8f9fa;
/* border-collapse: drop sticky borders — restore with box-shadow */
box-shadow: inset 0 -1px 0 #dee2e6;
}
.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); }
.progress-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.progress-legend .dot { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 50%; }
.progress-legend .dot-not-started { background: #6c757d; }
.progress-legend .dot-in-progress { background: #0d6efd; }
.progress-legend .dot-completed { background: #198754; }
.progress-legend .dot-overspend { background: #dc3545; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.filter-btn { cursor: pointer; }
.filtered-out { display: none !important; }
.group-hidden { display: none !important; }
</style>
</head>
<body class="money-hidden">
@@ -47,7 +52,7 @@
<li class="breadcrumb-item active" aria-current="page">Ведомость</li>
</ol>
</nav>
<div class="d-flex justify-content-between align-items-start mb-2">
<div class="d-flex flex-wrap justify-content-between align-items-start gap-2 mb-2">
<div>
<h1>{{ document_title }}</h1>
<p class="text-muted mb-0">
@@ -61,7 +66,7 @@
</p>
{% endif %}
</div>
<div class="d-flex gap-2">
<div class="d-flex flex-wrap 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>
{% if not has_history %}
@@ -81,6 +86,23 @@
<button type="button" class="btn btn-outline-secondary btn-sm" id="toggleMoney" title="Показать/скрыть финансовые суммы" aria-label="Показать или скрыть финансовые суммы">👁</button>
</div>
<div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3">
<div class="progress-legend">
<span class="text-muted small">Выполнение:</span>
<span class="small"><span class="dot dot-not-started"></span> Не начато</span>
<span class="small"><span class="dot dot-in-progress"></span> В работе</span>
<span class="small"><span class="dot dot-completed"></span> Выполнено</span>
<span class="small"><span class="dot dot-overspend"></span> Перерасход</span>
</div>
<div class="filter-bar" id="progressFilter">
<button type="button" class="btn btn-sm btn-primary filter-btn active" data-filter="all">Все</button>
<button type="button" class="btn btn-sm btn-outline-secondary filter-btn" data-filter="not-started">Не начато</button>
<button type="button" class="btn btn-sm btn-outline-secondary filter-btn" data-filter="in-progress">В работе</button>
<button type="button" class="btn btn-sm btn-outline-secondary filter-btn" data-filter="completed">Выполнено</button>
<button type="button" class="btn btn-sm btn-outline-secondary filter-btn" data-filter="overspend">Перерасход</button>
</div>
</div>
<div class="boq-table-wrap">
<table class="table table-bordered table-sm align-middle boq-table">
<colgroup>
@@ -116,7 +138,8 @@
{% 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 }}">
{% if pct == 0 %}{% set state = 'not-started' %}{% elif pct < 100 %}{% set state = 'in-progress' %}{% elif pct == 100 %}{% set state = 'completed' %}{% else %}{% set state = 'overspend' %}{% endif %}
<tr data-parent="section-{{ section_node.section.id }}" data-progress-state="{{ state }}">
<td>{{ item.source_number or '' }}</td>
<td>{{ item.name }}</td>
<td>{{ item.model or '' }}</td>
@@ -129,13 +152,11 @@
{% if planned %}
<div class="microstat-label text-muted mb-1">Выполнено: {{ done|round(2) }} / {{ planned }}</div>
<div class="progress microstat-bar">
{% if pct == 0 %}
{% if state == 'not-started' %}
<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 %}
{% elif state == 'in-progress' %}
<div class="progress-bar bg-primary" style="width: {{ pct }}%"></div>
{% elif pct == 100 %}
{% elif state == 'completed' %}
<div class="progress-bar bg-success" style="width: 100%"></div>
{% else %}
<div class="progress-bar bg-danger" style="width: 100%"></div>
@@ -196,6 +217,42 @@
if (row.dataset.toggle) toggleGroup(row.dataset.toggle, true);
});
});
// --- Progress filter (CSS classes, independent of collapse inline display) ---
function applyFilter(state) {
// 1. Tag items
document.querySelectorAll('tr[data-progress-state]').forEach(function(row) {
row.classList.toggle('filtered-out', state !== 'all' && row.dataset.progressState !== state);
});
// 2. Hide sections with no matching items
document.querySelectorAll('[data-toggle^="section-"]').forEach(function(secHeader) {
var secId = secHeader.dataset.toggle;
var items = document.querySelectorAll('tr[data-parent="' + secId + '"][data-progress-state]');
var hasMatch = false;
items.forEach(function(el) { if (!el.classList.contains('filtered-out')) hasMatch = true; });
secHeader.classList.toggle('group-hidden', !hasMatch);
});
// 3. Hide systems with no visible sections
document.querySelectorAll('[data-toggle^="system-"]').forEach(function(sysHeader) {
var sysId = sysHeader.dataset.toggle;
var sections = document.querySelectorAll('tr[data-parent="' + sysId + '"][data-toggle^="section-"]');
var hasVisible = false;
sections.forEach(function(el) { if (!el.classList.contains('group-hidden')) hasVisible = true; });
sysHeader.classList.toggle('group-hidden', !hasVisible);
});
}
document.querySelectorAll('#progressFilter .filter-btn').forEach(function(btn) {
btn.addEventListener('click', function() {
document.querySelectorAll('#progressFilter .filter-btn').forEach(function(b) {
b.classList.remove('active', 'btn-primary');
b.classList.add('btn-outline-secondary');
});
btn.classList.add('active', 'btn-primary');
btn.classList.remove('btn-outline-secondary');
applyFilter(btn.dataset.filter);
});
});
})();
</script>
</body>