指控下载提示修改
parent
b786c5e656
commit
94ca89db27
|
@ -9,6 +9,9 @@ const getDefaultState = () => {
|
||||||
studyListQuery: null,
|
studyListQuery: null,
|
||||||
unlock: false,
|
unlock: false,
|
||||||
config: {},
|
config: {},
|
||||||
|
uploadTip: null,
|
||||||
|
timer: null,
|
||||||
|
whiteList: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
import JSZip from "jszip";
|
|
||||||
import { saveAs } from "file-saver";
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import {
|
import {
|
||||||
requestPackageAndAnonymizImage,
|
requestPackageAndAnonymizImage,
|
||||||
} from "@/api/load.js";
|
} from "@/api/load.js";
|
||||||
import streamSaver from "streamsaver";
|
import streamSaver from "streamsaver";
|
||||||
import "streamsaver/examples/zip-stream.js"
|
import "streamsaver/examples/zip-stream.js"
|
||||||
|
import store from '@/store';
|
||||||
let flag = {};
|
let flag = {};
|
||||||
export const resetFlag = () => {
|
export const resetFlag = () => {
|
||||||
flag = {}
|
flag = {};
|
||||||
|
if (store.state.trials.timer) {
|
||||||
|
clearInterval(store.state.trials.timer);
|
||||||
|
store.state.trials.timer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export const downloadImage = async (id, id2, IsDicom = true) => {
|
export const downloadImage = async (id, id2, IsDicom = true) => {
|
||||||
if (flag[`${id2}_${IsDicom}`]) return Vue.prototype.$message.warning(Vue.prototype.$t('trials:upload:tip:uploading'));
|
// if (flag[`${id2}_${IsDicom}`]) return Vue.prototype.$message.warning(Vue.prototype.$t('trials:upload:tip:uploading'));
|
||||||
|
if (flag[`${id2}_${IsDicom}`]) return false;
|
||||||
flag[`${id2}_${IsDicom}`] = true
|
flag[`${id2}_${IsDicom}`] = true
|
||||||
try {
|
try {
|
||||||
let params = {
|
let params = {
|
||||||
|
@ -23,26 +27,42 @@ export const downloadImage = async (id, id2, IsDicom = true) => {
|
||||||
if (res.IsSuccess) {
|
if (res.IsSuccess) {
|
||||||
if (!res.Result) {
|
if (!res.Result) {
|
||||||
flag[`${id2}_${IsDicom}`] = false;
|
flag[`${id2}_${IsDicom}`] = false;
|
||||||
Vue.prototype.$message.warning(Vue.prototype.$t("trials:upload:message:not"))
|
// Vue.prototype.$message.warning(Vue.prototype.$t("trials:upload:message:not"))
|
||||||
return 1;
|
let message = Vue.prototype.$t('trials:upload:tip:uploading').replace("xxx", res.OtherInfo.FileName);
|
||||||
|
store.state.trials.uploadTip = message;
|
||||||
|
console.log(store.state.trials.timer)
|
||||||
|
if (!store.state.trials.timer) {
|
||||||
|
store.state.trials.timer = setInterval(() => {
|
||||||
|
downloadImage(id, id2, IsDicom);
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Vue.prototype.$message.success(Vue.prototype.$t("trials:upload:message:startUpload"));
|
if (store.state.trials.timer) {
|
||||||
|
clearInterval(store.state.trials.timer);
|
||||||
|
store.state.trials.timer = null;
|
||||||
|
}
|
||||||
|
let fileName = res.Result.split("/").pop();
|
||||||
let href = Vue.prototype.OSSclientConfig.basePath + res.Result;
|
let href = Vue.prototype.OSSclientConfig.basePath + res.Result;
|
||||||
download(href, res.OtherInfo.FileName, { id2, IsDicom })
|
if (fileName !== res.OtherInfo.FileName) {
|
||||||
return 2;
|
let message = Vue.prototype.$t('trials:upload:tip:uploading').replace("xxx", res.OtherInfo.FileName);
|
||||||
// let a = document.createElement("a");
|
store.state.trials.uploadTip = message;
|
||||||
// // let fileName =
|
// Vue.prototype.$message.success(Vue.prototype.$t("trials:upload:message:startUpload"));
|
||||||
// // res.Result.split("/")[res.Result.split("/").length - 1];
|
return download(href, res.OtherInfo.FileName, { id2, IsDicom });
|
||||||
// a.download = res.OtherInfo.FileName;
|
|
||||||
// a.href = href;
|
}
|
||||||
// a.click();
|
let a = document.createElement("a");
|
||||||
// URL.revokeObjectURL(href);
|
a.download = res.OtherInfo.FileName;
|
||||||
// let timer = setTimeout(() => {
|
a.href = href;
|
||||||
// a = null;
|
a.click();
|
||||||
// href = null;
|
URL.revokeObjectURL(href);
|
||||||
// timer = null;
|
let timer = setTimeout(() => {
|
||||||
// }, 500)
|
a = null;
|
||||||
// return 2;
|
href = null;
|
||||||
|
timer = null;
|
||||||
|
}, 500)
|
||||||
|
store.state.trials.uploadTip = null;
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
flag[`${id2}_${IsDicom}`] = false;
|
flag[`${id2}_${IsDicom}`] = false;
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,118 +72,6 @@ export const downloadImage = async (id, id2, IsDicom = true) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const setfolder = async (item) => {
|
|
||||||
const zip = new JSZip(); // 创建实例对象
|
|
||||||
let patientIds = item.PatientList.map(i => i.PatientIdStr);
|
|
||||||
let zipName = `${item.SubjectCode}_${patientIds.join(',')}`;
|
|
||||||
let zipObj = {};
|
|
||||||
const promises = [];
|
|
||||||
for (let visit of item.VisitList) {
|
|
||||||
if (!zipObj[`${visit.VisitName}`]) {
|
|
||||||
zipObj[`${visit.VisitName}`] = zip.folder(visit.VisitName);
|
|
||||||
}
|
|
||||||
for (let study of visit.StudyList) {
|
|
||||||
let date = study.StudyTime.split(" ")[0];
|
|
||||||
for (let series of study.SeriesList) {
|
|
||||||
if (
|
|
||||||
!zipObj[
|
|
||||||
`${visit.VisitName}${series.Modality}`
|
|
||||||
]
|
|
||||||
) {
|
|
||||||
zipObj[
|
|
||||||
`${visit.VisitName}${series.Modality}`
|
|
||||||
] = zipObj[`${visit.VisitName}`].folder(
|
|
||||||
`${date}_${series.Modality}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
for (let instance of series.InstancePathList) {
|
|
||||||
let obj = {
|
|
||||||
subjectCode: item.SubjectCode,
|
|
||||||
visitName: visit.VisitName,
|
|
||||||
date: study.StudyTime.split(" ")[0],
|
|
||||||
modality: series.Modality,
|
|
||||||
instancePath: instance.Path,
|
|
||||||
dicomName: instance.Path.split("/Dicom/")[1],
|
|
||||||
};
|
|
||||||
const promise = handleBatchDown(
|
|
||||||
obj,
|
|
||||||
zipObj[
|
|
||||||
`${visit.VisitName}${series.Modality}`
|
|
||||||
],
|
|
||||||
);
|
|
||||||
promises.push(promise);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 生成 zip 文件
|
|
||||||
Promise.all(promises)
|
|
||||||
.then(() => {
|
|
||||||
// 生成zip 文件
|
|
||||||
zip
|
|
||||||
.generateAsync({
|
|
||||||
type: "blob",
|
|
||||||
compression: "DEFLATE", // STORE: 默认不压缩, DEFLATE:需要压缩
|
|
||||||
compressionOptions: {
|
|
||||||
level: 9, // 压缩等级 1~9 1 压缩速度最快, 9 最优压缩方式
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
saveAs(res, zipName + ".zip"); // 使用FileSaver.saveAs保存文件,文件名可自定义
|
|
||||||
flag[`${id2}_${IsDicom}`] = false;
|
|
||||||
zipObj = null;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((reason) => { flag[`${id2}_${IsDicom}`] = false; });
|
|
||||||
};
|
|
||||||
const handleBatchDown = async (item, zip) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
console.log("同步下载打包开始时间:" + new Date());
|
|
||||||
// 创建压缩文件输出流
|
|
||||||
const zipFileOutputStream = streamSaver.createWriteStream(zipName);
|
|
||||||
// 创建下载文件流
|
|
||||||
const fileIterator = files.values();
|
|
||||||
const readableZipStream = new window.ZIP({
|
|
||||||
async pull(ctrl) {
|
|
||||||
const fileInfo = fileIterator.next();
|
|
||||||
if (fileInfo.done) {//迭代终止
|
|
||||||
ctrl.close();
|
|
||||||
} else {
|
|
||||||
const { name, url } = fileInfo.value;
|
|
||||||
return fetch(url).then(res => {
|
|
||||||
ctrl.enqueue({
|
|
||||||
name,
|
|
||||||
stream: () => res.body
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (window.WritableStream && readableZipStream.pipeTo) {
|
|
||||||
// 开始下载
|
|
||||||
readableZipStream
|
|
||||||
.pipeTo(zipFileOutputStream)
|
|
||||||
.then(() => { console.log("同步下载打包结束时间:" + new Date()); resolve(true) })
|
|
||||||
} else {
|
|
||||||
resolve(false);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
};
|
|
||||||
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) => {
|
export const fileDownload = (content, filename) => {
|
||||||
const eleLink = document.createElement("a");
|
const eleLink = document.createElement("a");
|
||||||
eleLink.download = filename;
|
eleLink.download = filename;
|
||||||
|
@ -177,7 +85,9 @@ export const fileDownload = (content, filename) => {
|
||||||
let download = async (downloadUrl, downloadFileName, res) => {
|
let download = async (downloadUrl, downloadFileName, res) => {
|
||||||
const blob = await getBlob(downloadUrl);
|
const blob = await getBlob(downloadUrl);
|
||||||
flag[`${res.id2}_${res.IsDicom}`] = false;
|
flag[`${res.id2}_${res.IsDicom}`] = false;
|
||||||
|
store.state.trials.uploadTip = null;
|
||||||
saveAsB(blob, downloadFileName);
|
saveAsB(blob, downloadFileName);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let getBlob = (url) => {
|
let getBlob = (url) => {
|
||||||
|
@ -217,3 +127,39 @@ let saveAsB = (blob, filename) => {
|
||||||
|
|
||||||
window.URL.revokeObjectURL(link.href);
|
window.URL.revokeObjectURL(link.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 前端流式打包下载
|
||||||
|
const handleBatchDown = async (item, zip) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
console.log("同步下载打包开始时间:" + new Date());
|
||||||
|
// 创建压缩文件输出流
|
||||||
|
const zipFileOutputStream = streamSaver.createWriteStream(zipName);
|
||||||
|
// 创建下载文件流
|
||||||
|
const fileIterator = files.values();
|
||||||
|
const readableZipStream = new window.ZIP({
|
||||||
|
async pull(ctrl) {
|
||||||
|
const fileInfo = fileIterator.next();
|
||||||
|
if (fileInfo.done) {//迭代终止
|
||||||
|
ctrl.close();
|
||||||
|
} else {
|
||||||
|
const { name, url } = fileInfo.value;
|
||||||
|
return fetch(url).then(res => {
|
||||||
|
ctrl.enqueue({
|
||||||
|
name,
|
||||||
|
stream: () => res.body
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (window.WritableStream && readableZipStream.pipeTo) {
|
||||||
|
// 开始下载
|
||||||
|
readableZipStream
|
||||||
|
.pipeTo(zipFileOutputStream)
|
||||||
|
.then(() => { console.log("同步下载打包结束时间:" + new Date()); resolve(true) })
|
||||||
|
} else {
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -42,7 +42,13 @@
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right; position: relative">
|
||||||
|
<div
|
||||||
|
class="uploadTip"
|
||||||
|
style="position: absolute; top: 0; left: 0"
|
||||||
|
>
|
||||||
|
{{ $store.state.trials.uploadTip }}
|
||||||
|
</div>
|
||||||
<!-- 下载所有影像 -->
|
<!-- 下载所有影像 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="$store.state.trials.config.IsSupportQCDownloadImage"
|
v-if="$store.state.trials.config.IsSupportQCDownloadImage"
|
||||||
|
@ -294,7 +300,13 @@
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div style="text-align: right">
|
<div style="text-align: right; position: relative">
|
||||||
|
<div
|
||||||
|
class="uploadTip"
|
||||||
|
style="position: absolute; top: 0; left: 0"
|
||||||
|
>
|
||||||
|
{{ $store.state.trials.uploadTip }}
|
||||||
|
</div>
|
||||||
<!-- 下载所有影像 -->
|
<!-- 下载所有影像 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="$store.state.trials.config.IsSupportQCDownloadImage"
|
v-if="$store.state.trials.config.IsSupportQCDownloadImage"
|
||||||
|
@ -366,7 +378,10 @@
|
||||||
<!-- 预览 -->
|
<!-- 预览 -->
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
:disabled="files.row.FileType && files.row.FileType.indexOf('zip') >= 0"
|
:disabled="
|
||||||
|
files.row.FileType &&
|
||||||
|
files.row.FileType.indexOf('zip') >= 0
|
||||||
|
"
|
||||||
@click.native.prevent="previewFile(files.row)"
|
@click.native.prevent="previewFile(files.row)"
|
||||||
>
|
>
|
||||||
{{ $t("trials:audit:button:nonDicomsPreview") }}
|
{{ $t("trials:audit:button:nonDicomsPreview") }}
|
||||||
|
@ -1218,7 +1233,7 @@ import SignForm from "@/views/trials/components/newSignForm";
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import const_ from "@/const/sign-code";
|
import const_ from "@/const/sign-code";
|
||||||
import uploadPetClinicalData from "@/views/trials/trials-panel/visit/crc-upload/components/uploadPetClinicalData.vue";
|
import uploadPetClinicalData from "@/views/trials/trials-panel/visit/crc-upload/components/uploadPetClinicalData.vue";
|
||||||
import { downloadImage , resetFlag } from "@/utils/uploadZip.js";
|
import { downloadImage, resetFlag } from "@/utils/uploadZip.js";
|
||||||
export default {
|
export default {
|
||||||
name: "QualityAssurance",
|
name: "QualityAssurance",
|
||||||
components: {
|
components: {
|
||||||
|
@ -1331,9 +1346,6 @@ export default {
|
||||||
BodyPart: {},
|
BodyPart: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeDestroy(){
|
|
||||||
resetFlag();
|
|
||||||
},
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.BodyPart.Bodypart = await this.$getBodyPart(this.$route.query.trialId);
|
this.BodyPart.Bodypart = await this.$getBodyPart(this.$route.query.trialId);
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
|
@ -1354,16 +1366,13 @@ export default {
|
||||||
if (this.open) {
|
if (this.open) {
|
||||||
this.open.close();
|
this.open.close();
|
||||||
}
|
}
|
||||||
|
resetFlag();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 打包下载
|
// 打包下载
|
||||||
async downloadImage(IsDicom) {
|
async downloadImage(IsDicom) {
|
||||||
try {
|
try {
|
||||||
await downloadImage(
|
await downloadImage(this.$route.query.trialId, this.data.Id, IsDicom);
|
||||||
this.$route.query.trialId,
|
|
||||||
this.data.Id,
|
|
||||||
IsDicom
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
@ -2229,7 +2238,7 @@ export default {
|
||||||
this.open.close();
|
this.open.close();
|
||||||
}
|
}
|
||||||
// this.previewAllNoneDicomVisible = true
|
// this.previewAllNoneDicomVisible = true
|
||||||
let trialId = this.$route.query.trialId
|
let trialId = this.$route.query.trialId;
|
||||||
var token = getToken();
|
var token = getToken();
|
||||||
const routeData = this.$router.resolve({
|
const routeData = this.$router.resolve({
|
||||||
path: `/showNoneDicoms?trialId=${trialId}&subjectVisitId=${this.data.Id}&TokenKey=${token}`,
|
path: `/showNoneDicoms?trialId=${trialId}&subjectVisitId=${this.data.Id}&TokenKey=${token}`,
|
||||||
|
@ -2241,7 +2250,7 @@ export default {
|
||||||
if (this.open) {
|
if (this.open) {
|
||||||
this.open.close();
|
this.open.close();
|
||||||
}
|
}
|
||||||
let trialId = this.$route.query.trialId
|
let trialId = this.$route.query.trialId;
|
||||||
var token = getToken();
|
var token = getToken();
|
||||||
const routeData = this.$router.resolve({
|
const routeData = this.$router.resolve({
|
||||||
path: `/showNoneDicoms?trialId=${trialId}&subjectVisitId=${this.data.Id}&studyId=${row.Id}&TokenKey=${token}`,
|
path: `/showNoneDicoms?trialId=${trialId}&subjectVisitId=${this.data.Id}&studyId=${row.Id}&TokenKey=${token}`,
|
||||||
|
|
Loading…
Reference in New Issue