下载文件转换
continuous-integration/drone/push Build is passing Details

uat
wangxiaoshuang 2025-08-11 16:06:48 +08:00
parent dde53103f9
commit 2ed051e25b
3 changed files with 26 additions and 1 deletions

View File

@ -328,6 +328,7 @@ export default {
}/${this.$fd('IsDicom', true)}/${study.StudyCode }/${this.$fd('IsDicom', true)}/${study.StudyCode
}/IMAGE/${fileName}`, }/IMAGE/${fileName}`,
url: this.OSSclientConfig.basePath + instance.Path, url: this.OSSclientConfig.basePath + instance.Path,
IsEncapsulated: instance.IsEncapsulated
} }
if (this.IsReadingTaskViewInOrder === 0) { if (this.IsReadingTaskViewInOrder === 0) {
obj = { obj = {
@ -336,6 +337,7 @@ export default {
true true
)}/IMAGE/${fileName}`, )}/IMAGE/${fileName}`,
url: this.OSSclientConfig.basePath + instance.Path, url: this.OSSclientConfig.basePath + instance.Path,
IsEncapsulated: instance.IsEncapsulated
} }
} }
files.push(obj) files.push(obj)

View File

@ -1,6 +1,7 @@
import streamSaver from "streamsaver"; import streamSaver from "streamsaver";
import "streamsaver/examples/zip-stream.js"; import "streamsaver/examples/zip-stream.js";
import store from '@/store' import store from '@/store'
import dcmjs from './dcmUpload/dcmjs'
streamSaver.mitm = `${window.location.origin}/mitm.html?version=2.0.0` streamSaver.mitm = `${window.location.origin}/mitm.html?version=2.0.0`
// 下载文件并压缩 // 下载文件并压缩
function zipFiles(zipName, files) { function zipFiles(zipName, files) {
@ -19,7 +20,10 @@ function zipFiles(zipName, files) {
if (fileInfo.done) {//迭代终止 if (fileInfo.done) {//迭代终止
ctrl.close(); ctrl.close();
} else { } else {
let { name, url } = fileInfo.value; let { name, url, IsEncapsulated = false } = fileInfo.value;
if (IsEncapsulated) {
url = await downloadFileToUrl(url)
}
// url = decodeUtf8(url); // 待定,可能做过特殊处理 // url = decodeUtf8(url); // 待定,可能做过特殊处理
return fetch(url).then(res => { return fetch(url).then(res => {
ctrl.enqueue({ ctrl.enqueue({
@ -99,6 +103,24 @@ function decodeUtf8(bytes) {
str2.pop(); str2.pop();
return str2.join("/") + '/' + name; 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') { export async function downLoadFile(file, name, type = 'file') {
if (type === 'zip') return await zipFiles(name, file); if (type === 'zip') return await zipFiles(name, file);
return await updateFile(file, name) return await updateFile(file, name)

View File

@ -1201,6 +1201,7 @@ export default {
true true
)}/${study.StudyCode}_${study.StudyTime.split(' ')[0]}/IMAGE/${fileName}`, )}/${study.StudyCode}_${study.StudyTime.split(' ')[0]}/IMAGE/${fileName}`,
url: this.OSSclientConfig.basePath + instance.Path, url: this.OSSclientConfig.basePath + instance.Path,
IsEncapsulated: instance.IsEncapsulated
} }
files.push(obj) files.push(obj)
}) })