feat: allow deleting draft agreements while keeping approved read-only
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<!doctype html><html lang="ru"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>ДС №{{ agreement.number }} — {{ project.name }}</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"><style>.numeric{font-variant-numeric:tabular-nums;white-space:nowrap}.item-name{min-width:16rem}</style></head><body class="bg-light"><main class="container-fluid container-xxl py-4">
|
||||
<nav><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="/projects/{{ project.id }}/agreements">ДС</a></li><li class="breadcrumb-item active">№{{ agreement.number }}</li></ol></nav>
|
||||
{% if error %}<div class="alert alert-danger" role="alert">{{ error }}</div>{% endif %}
|
||||
<header class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4"><div><h1 class="h2 mb-1">ДС №{{ agreement.number }} — {{ agreement.title }}</h1><div class="text-muted">{{ agreement.date.strftime('%d.%m.%Y') }} · {{ scope_label }}</div></div><div class="d-flex gap-2"><a class="btn btn-outline-secondary" href="/projects/{{ project.id }}/agreements">К списку</a>{% if agreement.status == 'approved' %}<span class="badge text-bg-success align-self-center">Утверждено</span>{% else %}<span class="badge text-bg-secondary align-self-center">Черновик</span>{% endif %}</div></header>
|
||||
<header class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4"><div><h1 class="h2 mb-1">ДС №{{ agreement.number }} — {{ agreement.title }}</h1><div class="text-muted">{{ agreement.date.strftime('%d.%m.%Y') }} · {{ scope_label }}</div></div><div class="d-flex gap-2"><a class="btn btn-outline-secondary" href="/projects/{{ project.id }}/agreements">К списку</a>{% if agreement.status == 'approved' %}<span class="badge text-bg-success align-self-center">Утверждено</span>{% else %}<span class="badge text-bg-secondary align-self-center">Черновик</span><button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteAgreementModal">Удалить ДС</button>{% endif %}</div></header>
|
||||
{% if agreement.status == 'draft' %}
|
||||
<section class="card border-0 shadow-sm mb-4"><div class="card-header bg-white"><h2 class="h5 mb-0">Реквизиты ДС</h2></div><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/update"><div class="card-body row g-3">
|
||||
<div class="col-md-3"><label class="form-label">Номер</label><input class="form-control" name="number" value="{{ agreement.number }}" required></div><div class="col-md-3"><label class="form-label">Дата</label><input class="form-control" type="date" name="agreement_date" value="{{ agreement.date.isoformat() }}" required></div><div class="col-md-6"><label class="form-label">Наименование</label><input class="form-control" name="title" value="{{ agreement.title }}" required></div><div class="col-12"><label class="form-label">Описание</label><textarea class="form-control" name="description" rows="2">{{ agreement.description or '' }}</textarea></div>
|
||||
@@ -15,6 +15,7 @@
|
||||
<div class="col-xl-6"><section class="card border-0 shadow-sm h-100"><div class="card-header bg-white"><h2 class="h5 mb-0">Добавить новую позицию</h2></div><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/new" data-new-item-form data-system-url="/projects/{{ project.id }}/agreements/{{ agreement.id }}/systems" data-section-url="/projects/{{ project.id }}/agreements/{{ agreement.id }}/sections"><div class="card-body row g-3"><div class="col-12"><label class="form-label">Ведомость (необязательно)</label><select class="form-select" name="source_boq_document_id"><option value="">Без ведомости</option>{% for doc in boq_documents %}<option value="{{ doc.id }}" {% if agreement.boq_document_id == doc.id %}selected{% endif %}>{{ doc.display_name }}</option>{% endfor %}</select></div><div class="col-md-6"><label class="form-label">Наименование</label><input class="form-control" name="name" required></div><div class="col-md-6"><label class="form-label">Модель / артикул</label><input class="form-control" name="model"></div><div class="col-md-6"><label class="form-label">Производитель</label><input class="form-control" name="manufacturer"></div><div class="col-md-3"><label class="form-label">Единица</label><input class="form-control" name="unit"></div><div class="col-md-3"><label class="form-label">Δ кол-во</label><input class="form-control" type="number" min="0.0001" step="0.0001" name="quantity_delta" required></div><div class="col-md-6"><label class="form-label">Цена за единицу</label><input class="form-control" type="number" min="0" step="0.000000000001" name="unit_price" required></div><div class="col-md-6"><label class="form-label">Система</label><select class="form-select system-select" name="system_id" data-system-select><option value="">Без системы</option>{% for system in systems %}<option value="{{ system.id }}">{{ system.name }}</option>{% endfor %}<option value="__new__">+ Новая система...</option></select><div class="input-group mt-2 d-none" data-new-system-panel><input class="form-control" maxlength="255" placeholder="Название системы"><button type="button" class="btn btn-outline-primary" data-create-system>Создать</button></div></div><div class="col-md-6"><label class="form-label">Раздел</label><select class="form-select section-select" name="section_id" data-section-select><option value="">Без раздела</option>{% for section in sections %}<option value="{{ section.id }}" data-system="{{ section.system_id }}">{{ section.name }}</option>{% endfor %}<option value="__new__">+ Новый раздел...</option></select><div class="input-group mt-2 d-none" data-new-section-panel><input class="form-control" maxlength="255" placeholder="Название раздела"><button type="button" class="btn btn-outline-primary" data-create-section>Создать</button></div></div><div class="col-12 text-danger small" data-association-error role="alert"></div></div><div class="card-footer bg-white"><button class="btn btn-outline-primary">Добавить новую позицию</button></div></form></section></div></div>
|
||||
<section class="d-flex justify-content-end mt-4"><button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#approveModal" {% if not line_rows %}disabled{% endif %}>Утвердить</button></section>
|
||||
<div class="modal fade" id="approveModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Подтвердите утверждение</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><div><strong>ДС №{{ agreement.number }}</strong></div><div>Область: {{ scope_label }}</div><div>Количество позиций: {{ line_rows|length }}</div><p class="text-warning mt-3 mb-0">После утверждения изменения нельзя редактировать.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Отмена</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/approve"><button class="btn btn-success">Утвердить ДС</button></form></div></div></div></div>
|
||||
<div class="modal fade" id="deleteAgreementModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Удалить черновик ДС</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><p>Будет удалён весь документ <strong>ДС №{{ agreement.number }}</strong> и все его позиции ({{ line_rows|length }} шт.).</p><p class="text-danger mb-0">Действие необратимо.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Отмена</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/delete"><button class="btn btn-danger">Удалить ДС</button></form></div></div></div></div>
|
||||
{% else %}<div class="alert alert-info">ДС утверждено. Изменения недоступны.</div>{% endif %}
|
||||
</main><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script><script>
|
||||
document.querySelectorAll('.system-select').forEach(systemSelect=>{const form=systemSelect.closest('form');const section=form.querySelector('.section-select');if(!section)return;const filter=()=>{const value=systemSelect.value;[...section.options].forEach(option=>{if(!option.dataset.system)return;option.hidden=!!value&&value!=='__new__'&&option.dataset.system!==value;});const selected=section.selectedOptions[0];if(selected&&selected.dataset.system&&selected.hidden)section.value='';};systemSelect.addEventListener('change',filter);filter();});
|
||||
|
||||
Reference in New Issue
Block a user