fix(ui): обычный form submit без JS submit()
Форма теперь в DOM, кнопка type=submit. JS только переносит файлы в скрытый input перед отправкой. Браузер сам делает POST и следует редиректу.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
"""app.py — Точка входа и сборка слоёв."""
|
"""app.py — Точка входа и сборка слоёв."""
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from flask import Flask, render_template, request, redirect
|
from flask import Flask, render_template, request, redirect, url_for
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import schema
|
import schema
|
||||||
|
|||||||
+11
-17
@@ -84,21 +84,17 @@
|
|||||||
Загрузка договоров / допников
|
Загрузка договоров / допников
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<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;">
|
<input type="file" id="visibleFileInput" accept=".docx,.doc,.pdf,.zip" multiple style="margin-bottom:8px;">
|
||||||
|
|
||||||
<!-- Очередь файлов -->
|
<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" id="queue"></div>
|
||||||
<div class="queue-empty" id="queueEmpty">Нет файлов — выберите file.docx / file.pdf / file.zip</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>
|
<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> Обработать
|
<i data-lucide="play" style="width:16px;height:16px;"></i> Загрузить
|
||||||
</button>
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<div class="error-box" style="margin-top:12px;">❌ {{ error }}</div>
|
<div class="error-box" style="margin-top:12px;">❌ {{ error }}</div>
|
||||||
@@ -292,16 +288,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processBtn.addEventListener('click', () => {
|
processBtn.addEventListener('click', (e) => {
|
||||||
if (fileQueue.length === 0) return;
|
if (fileQueue.length === 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const dt = new DataTransfer();
|
const dt = new DataTransfer();
|
||||||
fileQueue.forEach(item => {
|
fileQueue.forEach(item => { if (item.file) dt.items.add(item.file); });
|
||||||
if (item.file) dt.items.add(item.file);
|
|
||||||
});
|
|
||||||
hiddenInput.files = dt.files;
|
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');
|
const style = document.createElement('style');
|
||||||
|
|||||||
Reference in New Issue
Block a user