Files
MES_Core/shiftflow/templates/shiftflow/item_detail.html
ackFromRedmi 191d06d7d3
Some checks failed
Deploy MES Core / deploy (push) Failing after 1s
Поменял структуру моделей
2026-03-29 16:04:02 +03:00

126 lines
7.0 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.

{% extends 'base.html' %}
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-10 col-xl-8">
<div class="card shadow-sm border-secondary mb-4">
<div class="card-header border-secondary d-flex justify-content-between align-items-center py-3">
<h3 class="text-accent mb-0"><i class="bi bi-info-circle me-2"></i>{{ item.task.drawing_name|default:"Без названия" }}</h3>
<span class="badge bg-secondary">Сделка № {{ item.task.deal.number }}</span>
</div>
<form method="post" id="mainForm" class="card-body p-4">
{% csrf_token %}
<div class="row g-3 mb-4 border-bottom border-secondary pb-3 text-body">
<div class="col-md-4">
<small class="text-muted d-block">Станок</small>
<strong>{{ item.machine.name }}</strong>
</div>
<div class="col-md-4">
<small class="text-muted d-block">Материал</small>
<strong>{{ item.task.material.name }}</strong>
</div>
<div class="col-md-4">
<small class="text-muted d-block">План</small>
<strong class="text-info fs-5">{{ item.quantity_plan }} шт.</strong>
</div>
</div>
<div class="mb-4 d-flex gap-2">
{% if item.task.drawing_file %}<a href="{{ item.task.drawing_file.url }}" target="_blank" class="btn btn-outline-info btn-sm">DXF</a>{% endif %}
{% if item.task.extra_drawing %}<a href="{{ item.task.extra_drawing.url }}" target="_blank" class="btn btn-outline-danger btn-sm">PDF</a>{% endif %}
</div>
<input type="hidden" name="status" id="id_status" value="{{ item.status }}">
{% if user_role in 'operator,master' %}
{% if item.status == 'work' %}
<div class="bg-body-tertiary p-3 rounded border mb-4 text-center">
<h5 class="mb-3">Закрыть задание:</h5>
<div class="btn-group btn-group-lg w-100">
<button type="button" class="btn btn-success" onclick="closeTask('done')">
<i class="bi bi-check-all"></i> Выполнено
</button>
<button type="button" class="btn btn-outline-warning" onclick="showPartial()">
Частично
</button>
</div>
<div id="partialInput" class="mt-3 d-none">
<label class="small text-muted">Сколько сделано?</label>
<input type="number" name="quantity_fact" id="id_quantity_fact" class="form-control form-control-lg text-center mx-auto" style="max-width: 200px;" value="{{ item.quantity_fact }}" max="{{ item.quantity_plan }}">
</div>
</div>
{% else %}
<div class="alert alert-success">Статус: {{ item.get_status_display }}. Сделано: {{ item.quantity_fact }} шт.</div>
<input type="hidden" name="quantity_fact" value="{{ item.quantity_fact }}">
{% endif %}
{% endif %}
{% if user_role == 'admin' %}
<div class="row g-3 mb-4">
<div class="col-md-6">
<label class="small text-muted">Статус задания (Админ)</label>
<select name="status" class="form-select border-secondary">
{% for val, name in form.fields.status.choices %}
<option value="{{ val }}" {% if item.status == val %}selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6">
<label class="small text-muted">Факт (шт)</label>
<input type="number" name="quantity_fact" class="form-control border-secondary" value="{{ item.quantity_fact }}">
</div>
</div>
{% endif %}
{% if user_role in 'admin,clerk' %}
{% if item.status == 'done' or item.quantity_fact > 0 %}
<div class="form-check form-switch p-3 rounded border border-warning mb-4 bg-body-tertiary d-flex justify-content-between align-items-center">
<label class="form-check-label fw-bold ms-2" for="sync1c">Списано в 1С</label>
<input class="form-check-input ms-0" style="width: 3em; height: 1.5em;" type="checkbox" name="is_synced_1c" id="sync1c" {% if item.is_synced_1c %}checked{% endif %}>
</div>
{% else %}
<div class="text-muted small mb-4"><i class="bi bi-info-circle me-1"></i>Списание будет доступно после выполнения.</div>
{% endif %}
{% if user_role == 'clerk' %}<input type="hidden" name="quantity_fact" value="{{ item.quantity_fact }}">{% endif %}
{% endif %}
<div class="d-flex justify-content-between mt-4">
<a href="{% url 'registry' %}" class="btn btn-outline-secondary">Назад</a>
<button type="submit" class="btn btn-outline-accent px-5 fw-bold">
<i class="bi bi-save me-2"></i>
{% if user_role in 'operator,master' %}Закрыть задание{% else %}Сохранить{% endif %}
</button>
</div>
</form>
</div>
</div>
</div>
<script>
function closeTask(status) {
document.getElementById('id_status').value = status;
// Если "Выполнено", автоматом ставим факт = плану
if(status === 'done') {
const factInput = document.getElementById('id_quantity_fact');
if(factInput) factInput.value = "{{ item.quantity_plan }}";
else {
let hiddenFact = document.createElement('input');
hiddenFact.type = 'hidden';
hiddenFact.name = 'quantity_fact';
hiddenFact.value = "{{ item.quantity_plan }}";
document.getElementById('mainForm').appendChild(hiddenFact);
}
}
document.getElementById('mainForm').submit();
}
function showPartial() {
document.getElementById('partialInput').classList.remove('d-none');
document.getElementById('id_status').value = 'part'; // Статус Частично
}
</script>
{% endblock %}