Files
work-volume-tracker/app/templates/projects/boq_document.html
T
2026-10-01 12:38:01 +03:00

260 lines
15 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<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; 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; }
.boq-table { table-layout: fixed; width: 100%; }
.boq-table td, .boq-table th { overflow-wrap: anywhere; }
.boq-table .money-value { overflow-wrap: normal; }
.boq-table-wrap {
max-height: calc(100vh - 12rem);
overflow: auto;
-webkit-overflow-scrolling: touch;
}
.boq-table thead th {
position: sticky;
top: 0;
z-index: 10;
background-color: #f8f9fa;
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">
<main class="container my-4">
<nav aria-label="Навигация" class="mb-3">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/projects/">Проекты</a></li>
<li class="breadcrumb-item"><a href="/projects/{{ project.id }}">{{ project.name }}</a></li>
<li class="breadcrumb-item"><a href="/boq/{{ project.id }}">Ведомости</a></li>
<li class="breadcrumb-item active" aria-current="page">Ведомость</li>
</ol>
</nav>
<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">
{{ project.name }}{% if document.source_file %} · {{ document.source_file }}{% endif %}
</p>
{% if document.document_number or document.document_date or document.contract %}
<p class="text-muted small mb-0">
{% if document.document_number %}<span>№ {{ document.document_number }}</span>{% endif %}
{% if document.document_date %}<span class="ms-2">от {{ document.document_date.strftime('%d.%m.%Y') }}</span>{% endif %}
{% if document.contract %}<span class="ms-2">Договор: {{ document.contract }}</span>{% endif %}
</p>
{% endif %}
</div>
<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 %}
<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="d-flex justify-content-end align-items-center gap-2 mb-3">
<span class="text-muted small">Финансовые суммы</span>
<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>
<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 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 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"] %}
{% 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 %}
{% 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>
<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 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 state == 'not-started' %}
<div class="progress-bar bg-secondary" style="width: 100%"></div>
{% elif state == 'in-progress' %}
<div class="progress-bar bg-primary" style="width: {{ pct }}%"></div>
{% elif state == 'completed' %}
<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="9" class="text-center text-muted py-4">В документе нет рабочих позиций.</td></tr>
{% endfor %}
<tr class="table-dark fw-bold">
<td colspan="8">Итого по ведомости</td>
<td class="text-end money-value">{{ total|money(project.currency) }}</td>
</tr>
</tbody>
</table>
</div>
{% if unassigned_items %}
<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);
});
});
// --- 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>
</html>