From 9d73a3364e27a52400caaf2bbb3cc08e15ac5f52 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Thu, 12 Mar 2026 10:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A0=94=E5=88=A4=E5=88=86=E6=9E=90=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/work/negative.ts | 7 ++++++ src/views/work/Query.vue | 53 ++++++++++++---------------------------- 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/api/work/negative.ts b/src/api/work/negative.ts index b846567..7e8604d 100644 --- a/src/api/work/negative.ts +++ b/src/api/work/negative.ts @@ -56,6 +56,13 @@ export function negativeExport(query) { }); } +export function createReportTask(data) { + return request.post({ + url: "/negative/export/report", + body: data + }); +} + export function delNegative(id) { return request.del({ url: `/negative/${id}` diff --git a/src/views/work/Query.vue b/src/views/work/Query.vue index 85bf85b..5d146de 100644 --- a/src/views/work/Query.vue +++ b/src/views/work/Query.vue @@ -1080,7 +1080,7 @@ import { negativeExport, delNegative, updateNegative, - transferTodo, generateReport, + transferTodo, createReportTask, } from "@/api/work/negative"; import { getDictLable, formatTimeText, getInvolveProblem ,getYearTime} from "@/utils/util"; import feedback from "@/utils/feedback"; @@ -1223,50 +1223,27 @@ async function handleExport() { router.push("/negative/export"); } -const reportGenerationFun = async ()=>{ - // await feedback.confirm("请确定生成当前页面数据的报告"); - debugger - console.log(userStore.user.userName) +async function reportGenerationFun() { const crtTime = query.value.crtTime; - if (!crtTime){ - feedback.msgError("请选择对应录入时间") - return + if (!crtTime) { + feedback.msgError("请选择对应录入时间"); + return; } + const loading = ElLoading.service({ lock: true, - text: "报告生成中...", + text: "报告任务生成中...", background: "rgba(0, 0, 0, 0.5)", }); - try { - // 发送请求到后端生成报告 - const body = JSON.parse(JSON.stringify(query.value)); - const res = await generateReport(body); - - const blob = res.blob; - - let fileName = "研判分析报告.docx"; - - if (res.disposition) { - const match = res.disposition.match(/filename\*?=.*''(.+)/); - if (match) { - fileName = decodeURIComponent(match[1]); - } - } - const url = window.URL.createObjectURL(blob); - const link = document.createElement("a"); - - link.href = url; - link.download = fileName; - - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - - window.URL.revokeObjectURL(url); - loading.close(); - } catch (error) { - console.log(error) + try { + await createReportTask(query.value); + feedback.msgSuccess("报告任务已生成,请到导出记录页面查看"); + router.push("/negative/export"); + } catch (e) { + console.error(e); + feedback.msgError("报告任务生成失败"); + } finally { loading.close(); } }