From 395fc7c4bdc245e1d46cd74e8d83e10f9f489121 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Thu, 12 Mar 2026 10:33:29 +0800 Subject: [PATCH] =?UTF-8?q?fix--=E4=B8=8B=E8=BD=BD=E6=94=AF=E6=8C=81world?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/work/NegativeTask.vue | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/views/work/NegativeTask.vue b/src/views/work/NegativeTask.vue index 00c5da9..6bb1abb 100644 --- a/src/views/work/NegativeTask.vue +++ b/src/views/work/NegativeTask.vue @@ -110,28 +110,32 @@ onMounted(() => { }); function handleDownload(row) { - if (row.status !== '1') { - } - fetch(`${BASE_PATH}/file/stream${row.filePath}`) - .then((response) => { - console.log(response); - return response.blob(); - }) - .then((res) => { - console.log(res); - const blob = new Blob([res], { - type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - }); - const url = window.URL.createObjectURL(blob); - const link = document.createElement("a"); - link.href = url; - link.setAttribute("download", row.taskName + ".xlsx"); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - window.URL.revokeObjectURL(url); - }); + fetch(`${BASE_PATH}/file/stream${row.filePath}`) + .then((response) => response.blob()) + .then((blob) => { + + const url = window.URL.createObjectURL(blob); + + const link = document.createElement("a"); + link.href = url; + + let fileName = row.taskName; + + if (row.filePath.endsWith(".docx")) { + fileName += ".docx"; + } else { + fileName += ".xlsx"; + } + + link.download = fileName; + + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + window.URL.revokeObjectURL(url); + }); }