diff --git a/src/main.js b/src/main.js index 276927e4..1c7574dc 100644 --- a/src/main.js +++ b/src/main.js @@ -44,7 +44,6 @@ Viewer.setDefaults({ 'rotatable': true, 'scalable': true, 'transition': true, - 'fullscreen': true, 'keyboard': true, 'url': 'data-source' } diff --git a/src/utils/uploadZip.js b/src/utils/uploadZip.js index 81401568..fdb48835 100644 --- a/src/utils/uploadZip.js +++ b/src/utils/uploadZip.js @@ -7,8 +7,11 @@ import { import streamSaver from "streamsaver"; import "streamsaver/examples/zip-stream.js" let flag = {}; +export const resetFlag = () => { + flag = {} +} export const downloadImage = async (id, id2, IsDicom = true) => { - if (flag[`${id2}_${IsDicom}`]) return + if (flag[`${id2}_${IsDicom}`]) return Vue.prototype.$message.warning(Vue.prototype.$t('trials:upload:tip:uploading')); flag[`${id2}_${IsDicom}`] = true try { let params = { @@ -17,27 +20,31 @@ export const downloadImage = async (id, id2, IsDicom = true) => { IsDicom: IsDicom } let res = await requestPackageAndAnonymizImage(params); - flag[`${id2}_${IsDicom}`] = false; if (res.IsSuccess) { if (!res.Result) { + flag[`${id2}_${IsDicom}`] = false; Vue.prototype.$message.warning(Vue.prototype.$t("trials:upload:message:not")) return 1; } - let a = document.createElement("a"); + Vue.prototype.$message.success(Vue.prototype.$t("trials:upload:message:startUpload")); let href = Vue.prototype.OSSclientConfig.basePath + res.Result; - // let fileName = - // res.Result.split("/")[res.Result.split("/").length - 1]; - a.download = res.OtherInfo.fileName; - a.href = href; - a.click(); - URL.revokeObjectURL(href); - let timer = setTimeout(() => { - a = null; - href = null; - timer = null; - }, 500) + download(href, res.OtherInfo.FileName, { id2, IsDicom }) return 2; + // let a = document.createElement("a"); + // // let fileName = + // // res.Result.split("/")[res.Result.split("/").length - 1]; + // a.download = res.OtherInfo.FileName; + // a.href = href; + // a.click(); + // URL.revokeObjectURL(href); + // let timer = setTimeout(() => { + // a = null; + // href = null; + // timer = null; + // }, 500) + // return 2; } else { + flag[`${id2}_${IsDicom}`] = false; return false; } } catch (err) { @@ -143,3 +150,70 @@ const handleBatchDown = async (item, zip) => { }) }; +const getFileData = (fileUrl) => { + return new Promise((resolve, reject) => { + axios(fileUrl, { + method: "GET", + responseType: "blob", // 返回的数据会被强制转为blob类型 ,转换成arraybuffer 也行 + }) + .then((res) => { + resolve(res); + }) + .catch((error) => { + reject(error); + }); + }); +}; +export const fileDownload = (content, filename) => { + const eleLink = document.createElement("a"); + eleLink.download = filename; + eleLink.style.display = "none"; + const blob = new Blob([content]); + eleLink.href = URL.createObjectURL(blob); + document.body.appendChild(eleLink); + eleLink.click(); + document.body.removeChild(eleLink); +}; +let download = async (downloadUrl, downloadFileName, res) => { + const blob = await getBlob(downloadUrl); + flag[`${res.id2}_${res.IsDicom}`] = false; + saveAsB(blob, downloadFileName); +} + +let getBlob = (url) => { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + + xhr.open('GET', url, true); + xhr.responseType = 'blob'; + xhr.onload = () => { + if (xhr.status === 200) { + resolve(xhr.response); + } else { + reject(new Error(`Request failed with status ${xhr.status}`)); + } + }; + xhr.onerror = () => { + reject(new Error('Request failed')); + }; + + xhr.send(); + }); +} + +let saveAsB = (blob, filename) => { + const link = document.createElement('a'); + const body = document.body; + + link.href = window.URL.createObjectURL(blob); + link.download = filename; + + // hide the link + link.style.display = 'none'; + body.appendChild(link); + + link.click(); + body.removeChild(link); + + window.URL.revokeObjectURL(link.href); +} diff --git a/src/views/trials/trials-panel/reading/ad-review/index.vue b/src/views/trials/trials-panel/reading/ad-review/index.vue index ae540920..435edc96 100644 --- a/src/views/trials/trials-panel/reading/ad-review/index.vue +++ b/src/views/trials/trials-panel/reading/ad-review/index.vue @@ -203,28 +203,30 @@ >
- - - + - - + + + + - - + + + - +
@@ -303,9 +305,6 @@ - - -