diff --git a/app.py b/app.py
index 4258d7d..6dc8c76 100644
--- a/app.py
+++ b/app.py
@@ -650,8 +650,6 @@ def delete_entry(doc_id):
if success:
return redirect(url_for(redirect_url))
- if delete_by_id(doc_id):
- return redirect(url_for('show_all'))
else:
return "删除失败", 500
diff --git a/templates/all.html b/templates/all.html
index 514e9b5..0154911 100644
--- a/templates/all.html
+++ b/templates/all.html
@@ -224,6 +224,7 @@
@@ -342,12 +343,72 @@ function batchDelete() {
document.body.appendChild(form);
form.submit();
+
+ // 提交后自动刷新页面
+ form.addEventListener('submit', function() {
+ setTimeout(function() {
+ window.location.reload();
+ }, 1000); // 1秒后刷新页面,给服务器处理时间
+ });
}
// 页面加载时初始化
document.addEventListener('DOMContentLoaded', function() {
updateSelectedCount();
});
+
+// 单个删除功能
+function deleteRecord(docId) {
+ // 显示删除确认模态框
+ showDeleteModal(docId);
+}
+
+// 显示删除确认模态框
+function showDeleteModal(docId) {
+ // 创建模态框HTML
+ const modalHtml = `
+
+
+
确认删除
+
您确定要删除这条数据吗?此操作不可撤销。
+
+
+
+
+
+
+ `;
+
+ // 添加模态框到页面
+ document.body.insertAdjacentHTML('beforeend', modalHtml);
+}
+
+// 关闭删除确认模态框
+function closeDeleteModal() {
+ const modal = document.getElementById('deleteModal');
+ if (modal) {
+ modal.remove();
+ }
+}
+
+// 确认删除记录
+function confirmDeleteRecord(docId) {
+ // 关闭模态框
+ closeDeleteModal();
+
+ // 创建表单并提交
+ const form = document.createElement('form');
+ form.method = 'POST';
+ form.action = '/delete/' + docId;
+
+ document.body.appendChild(form);
+ form.submit();
+
+ // 提交后自动刷新页面
+ setTimeout(function() {
+ window.location.reload();
+ }, 1000); // 1秒后刷新页面,给服务器处理时间
+}
{% endblock %}
\ No newline at end of file
diff --git a/templates/my_data.html b/templates/my_data.html
index c546f0a..8aa56e2 100644
--- a/templates/my_data.html
+++ b/templates/my_data.html
@@ -99,7 +99,7 @@
您确定要删除这条数据吗?此操作不可撤销。
-
@@ -470,6 +470,23 @@ function closeDeleteModal() {
document.getElementById('deleteModal').style.display = 'none';
}
+// 处理删除表单提交
+function handleDeleteSubmit(event) {
+ // 关闭模态框
+ closeDeleteModal();
+
+ // 显示删除中的提示
+ const submitButton = event.target.querySelector('button[type="submit"]');
+ const originalText = submitButton.textContent;
+ submitButton.textContent = '删除中...';
+ submitButton.disabled = true;
+
+ // 提交表单后自动刷新页面
+ setTimeout(function() {
+ window.location.reload();
+ }, 1000); // 1秒后刷新页面,给服务器处理时间
+}
+
// 点击模态框外部关闭
window.onclick = function(event) {
const imageModal = document.getElementById('imageModal');