fix(ui): обычный form submit без JS submit()

Форма теперь в DOM, кнопка type=submit.
JS только переносит файлы в скрытый input перед отправкой.
Браузер сам делает POST и следует редиректу.
This commit is contained in:
2026-06-15 07:51:14 +04:00
parent 87114d701c
commit 07344482cd
2 changed files with 15 additions and 21 deletions
+14 -20
View File
@@ -84,21 +84,17 @@
Загрузка договоров / допников
</div>
<div class="card-body">
<!-- Скрытая форма — отправляется только по кнопке -->
<form id="uploadForm" method="POST" enctype="multipart/form-data" style="display:none;">
<input type="file" name="files" id="hiddenFileInput" multiple>
</form>
<!-- Видимый интерфейс -->
<input type="file" id="visibleFileInput" accept=".docx,.doc,.pdf,.zip" multiple style="margin-bottom:8px;">
<!-- Очередь файлов -->
<div class="queue" id="queue"></div>
<div class="queue-empty" id="queueEmpty">Нет файлов — выберите file.docx / file.pdf / file.zip</div>
<form id="uploadForm" method="POST" enctype="multipart/form-data">
<input type="file" name="files" id="hiddenFileInput" multiple style="display:none;">
<div class="queue" id="queue"></div>
<div class="queue-empty" id="queueEmpty">Нет файлов — выберите file.docx / file.pdf / file.zip</div>
<button class="btn btn-primary" id="processBtn" style="width:100%;justify-content:center;margin-top:8px;" disabled>
<i data-lucide="play" style="width:16px;height:16px;"></i> Обработать
</button>
<button type="submit" class="btn btn-primary" id="processBtn" style="width:100%;justify-content:center;margin-top:8px;" disabled>
<i data-lucide="play" style="width:16px;height:16px;"></i> Загрузить
</button>
</form>
{% if error %}
<div class="error-box" style="margin-top:12px;">❌ {{ error }}</div>
@@ -292,16 +288,14 @@
}
}
processBtn.addEventListener('click', () => {
if (fileQueue.length === 0) return;
processBtn.addEventListener('click', (e) => {
if (fileQueue.length === 0) {
e.preventDefault();
return;
}
const dt = new DataTransfer();
fileQueue.forEach(item => {
if (item.file) dt.items.add(item.file);
});
fileQueue.forEach(item => { if (item.file) dt.items.add(item.file); });
hiddenInput.files = dt.files;
processBtn.disabled = true;
processBtn.innerHTML = '<span style="display:inline-block;width:16px;height:16px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .6s linear infinite;"></span> Обработка...';
document.getElementById('uploadForm').submit();
});
const style = document.createElement('style');