Browse Source

fix--下载支持world

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

46
src/views/work/NegativeTask.vue

@ -110,28 +110,32 @@ onMounted(() => {
}); });
function handleDownload(row) { function handleDownload(row) {
if (row.status !== '1') {
} fetch(`${BASE_PATH}/file/stream${row.filePath}`)
fetch(`${BASE_PATH}/file/stream${row.filePath}`) .then((response) => response.blob())
.then((response) => { .then((blob) => {
console.log(response);
return response.blob(); const url = window.URL.createObjectURL(blob);
})
.then((res) => { const link = document.createElement("a");
console.log(res); link.href = url;
const blob = new Blob([res], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", let fileName = row.taskName;
});
const url = window.URL.createObjectURL(blob); if (row.filePath.endsWith(".docx")) {
const link = document.createElement("a"); fileName += ".docx";
link.href = url; } else {
link.setAttribute("download", row.taskName + ".xlsx"); fileName += ".xlsx";
document.body.appendChild(link); }
link.click();
document.body.removeChild(link); link.download = fileName;
window.URL.revokeObjectURL(url);
}); document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
});
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Loading…
Cancel
Save