203 lines
11 KiB
HTML
203 lines
11 KiB
HTML
<!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; }
|
||
.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; }
|
||
/*
|
||
* 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-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;
|
||
/* 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); }
|
||
</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 justify-content-between align-items-start 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 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="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 %}
|
||
<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 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="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);
|
||
});
|
||
});
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|