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 || '创建任务失败'); }