diff --git a/src/components/downloadDicomAndNonedicom/index.vue b/src/components/downloadDicomAndNonedicom/index.vue index a0d5fce8..ea96ff37 100644 --- a/src/components/downloadDicomAndNonedicom/index.vue +++ b/src/components/downloadDicomAndNonedicom/index.vue @@ -328,6 +328,7 @@ export default { }/${this.$fd('IsDicom', true)}/${study.StudyCode }/IMAGE/${fileName}`, url: this.OSSclientConfig.basePath + instance.Path, + IsEncapsulated: instance.IsEncapsulated } if (this.IsReadingTaskViewInOrder === 0) { obj = { @@ -336,6 +337,7 @@ export default { true )}/IMAGE/${fileName}`, url: this.OSSclientConfig.basePath + instance.Path, + IsEncapsulated: instance.IsEncapsulated } } files.push(obj) diff --git a/src/utils/stream.js b/src/utils/stream.js index 1b838669..8f1b1d02 100644 --- a/src/utils/stream.js +++ b/src/utils/stream.js @@ -1,6 +1,7 @@ import streamSaver from "streamsaver"; import "streamsaver/examples/zip-stream.js"; import store from '@/store' +import dcmjs from './dcmUpload/dcmjs' streamSaver.mitm = `${window.location.origin}/mitm.html?version=2.0.0` // 下载文件并压缩 function zipFiles(zipName, files) { @@ -19,7 +20,10 @@ function zipFiles(zipName, files) { if (fileInfo.done) {//迭代终止 ctrl.close(); } else { - let { name, url } = fileInfo.value; + let { name, url, IsEncapsulated = false } = fileInfo.value; + if (IsEncapsulated) { + url = await downloadFileToUrl(url) + } // url = decodeUtf8(url); // 待定,可能做过特殊处理 return fetch(url).then(res => { ctrl.enqueue({ @@ -99,6 +103,24 @@ function decodeUtf8(bytes) { str2.pop(); return str2.join("/") + '/' + name; } +// 下载文件进行修改并输出本地url +function downloadFileToUrl(url) { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'arraybuffer'; + xhr.onload = function () { + const arraybuffer = xhr.response; + let dataset = dcmjs.data.DicomMessage.readFile(arraybuffer) + let newDicomFile = dataset.write({ fragmentMultiframe: false }) // fragmentMultiframe 原始数据是否进行分割 + const bufferArray = new Uint8Array(newDicomFile) + const blob = new Blob([bufferArray], { type: 'application/octet-stream' }) + const href = URL.createObjectURL(blob) + resolve(href) + }; + xhr.send(); + }) +} export async function downLoadFile(file, name, type = 'file') { if (type === 'zip') return await zipFiles(name, file); return await updateFile(file, name) diff --git a/src/views/trials/trials-panel/visit/qc-check/components/qualityAssurance.vue b/src/views/trials/trials-panel/visit/qc-check/components/qualityAssurance.vue index b909fc5d..57aa07de 100644 --- a/src/views/trials/trials-panel/visit/qc-check/components/qualityAssurance.vue +++ b/src/views/trials/trials-panel/visit/qc-check/components/qualityAssurance.vue @@ -1201,6 +1201,7 @@ export default { true )}/${study.StudyCode}_${study.StudyTime.split(' ')[0]}/IMAGE/${fileName}`, url: this.OSSclientConfig.basePath + instance.Path, + IsEncapsulated: instance.IsEncapsulated } files.push(obj) })