Browse Source

fix--下载支持world

master
parent
commit
395fc7c4bd
  1. 28
      src/views/work/NegativeTask.vue

28
src/views/work/NegativeTask.vue

@ -110,26 +110,30 @@ 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",
});
.then((response) => response.blob())
.then((blob) => {
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", row.taskName + ".xlsx");
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);
});
}

Loading…
Cancel
Save