From 16a9c6a060ccdc6513d109d5ebc2f6c4c31b951e Mon Sep 17 00:00:00 2001 From: leiyun Date: Fri, 10 Apr 2026 10:43:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=8F=AA=E5=85=81=E8=AE=B8=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=89=93=E5=8C=85=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/admin/export_task.js | 13 ++++--------- view/admin/patient_index.html | 9 +++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/controller/admin/export_task.js b/src/controller/admin/export_task.js index be09d60..0ce0d66 100644 --- a/src/controller/admin/export_task.js +++ b/src/controller/admin/export_task.js @@ -69,18 +69,13 @@ module.exports = class extends Base { return this.fail('请选择要导出的附件类型'); } - // 防重复:同一用户5分钟内不允许创建相同条件的任务 - const fiveMinAgo = think.datetime(new Date(Date.now() - 5 * 60 * 1000)); - const duplicate = await this.model('export_task').where({ - create_by: this.adminUser?.id || 0, - file_types: JSON.stringify(file_types), - filter_params: JSON.stringify(filter_params || {}), - create_time: ['>', fiveMinAgo], + // 全局只允许一个打包中的任务 + const processing = await this.model('export_task').where({ is_deleted: 0, status: ['in', [0, 1]] }).find(); - if (!think.isEmpty(duplicate)) { - return this.fail('您有相同条件的任务正在处理中,请勿重复提交'); + if (!think.isEmpty(processing)) { + return this.json({ code: 1001, msg: '有任务正在打包中,请稍后再试' }); } const model = this.model('export_task'); diff --git a/view/admin/patient_index.html b/view/admin/patient_index.html index 2a59ba4..ff4f9ba 100644 --- a/view/admin/patient_index.html +++ b/view/admin/patient_index.html @@ -667,6 +667,15 @@ const app = createApp({ if (res.code === 0) { exportFilesVisible.value = false; exportSuccessVisible.value = true; + } else if (res.code === 1001) { + exportFilesVisible.value = false; + ElementPlus.ElMessageBox.confirm( + res.msg || '有任务正在打包中,请稍后再试', + '提示', + { confirmButtonText: '去查看', cancelButtonText: '关闭', type: 'warning' } + ).then(function() { + goExportTask(); + }).catch(function() {}); } else { ElementPlus.ElMessage.error(res.msg || '创建任务失败'); }