uat_us
caiyiling 2024-07-18 11:14:36 +08:00
commit 5e14615176
6 changed files with 148 additions and 69 deletions

View File

@ -44,7 +44,6 @@ Viewer.setDefaults({
'rotatable': true,
'scalable': true,
'transition': true,
'fullscreen': true,
'keyboard': true,
'url': 'data-source'
}

View File

@ -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);
}

View File

@ -203,6 +203,7 @@
>
<i slot="default" class="el-icon-plus" />
<div slot="file" slot-scope="{file}">
<viewer :images="images" :ref="file.url">
<img
class="el-upload-list__item-thumbnail"
:src="OSSclientConfig.basePath + file.url"
@ -225,6 +226,7 @@
<i class="el-icon-delete" />
</span>
</span>
</viewer>
</div>
</el-upload>
@ -303,9 +305,6 @@
</div>
<SignForm ref="signForm" :sign-code-enum="signCode" @closeDialog="closeSignDialog" />
</el-dialog>
<viewer v-if="imgVisible" :images="[imageUrl]" ref="viewer">
<img :src="imageUrl" crossorigin="anonymous" alt="">
</viewer>
</div>
</template>
<script>
@ -388,7 +387,8 @@ export default {
judgeResultArmEnum: '',
criterionType: null,
openWindow: null,
isFixed: false
isFixed: false,
images: []
}
},
// watch: {
@ -707,9 +707,9 @@ export default {
},
//
handlePictureCardPreview(file) {
this.imageUrl = this.OSSclientConfig.basePath + file.url
this.imgVisible = true
this.$refs.viewer.$viewer.show()
this.images = this.fileList.map(f => this.OSSclientConfig.basePath + f.url)
// this.imageUrl = this.OSSclientConfig.basePath + file.url
this.$refs[file.url].$viewer.show()
},
//
handleRemove(file, fileList) {

View File

@ -92,6 +92,7 @@
>
<i slot="default" class="el-icon-plus" />
<div slot="file" slot-scope="{file}">
<viewer :images="images" :ref="file.url">
<img
class="el-upload-list__item-thumbnail"
:src="OSSclientConfig.basePath + file.url"
@ -114,6 +115,7 @@
<i class="el-icon-delete" />
</span>
</span>
</viewer>
</div>
</el-upload>
<!-- <el-dialog
@ -130,9 +132,9 @@
</el-form-item>
</el-form>
<viewer v-if="imgVisible" :images="[imageUrl]" ref="viewer">
<!-- <viewer v-if="imgVisible" :images="[imageUrl]" ref="viewer">
<img :src="imageUrl" crossorigin="anonymous" alt="">
</viewer>
</viewer> -->
<el-dialog
v-if="chatVisible"
:visible.sync="chatVisible"
@ -222,7 +224,8 @@ export default {
userTypeEnumInt: zzSessionStorage.getItem('userTypeEnumInt') * 1,
isClosedDialog: false,
isSendMessage: false,
closeQuestionVisible: false
closeQuestionVisible: false,
images:[]
}
},
mounted() {
@ -382,9 +385,9 @@ export default {
},
//
handlePictureCardPreview(file) {
this.imageUrl = this.OSSclientConfig.basePath + file.url
this.imgVisible = true
this.$refs.viewer.$viewer.show()
this.images = this.fileList.map(f => this.OSSclientConfig.basePath + f.url)
// this.imageUrl = this.OSSclientConfig.basePath + file.url
this.$refs[file.url].$viewer.show()
},
//
handleRemove(file, fileList) {
@ -394,7 +397,7 @@ export default {
},
initializeViewer() {
Viewer.setDefaults({
toolbar: { zoomIn: true, zoomOut: true, rotateLeft: true, rotateRight: true, flipHorizontal: true, flipVertical: true }
toolbar: { zoomIn: true, zoomOut: true, rotateLeft: true, rotateRight: true, flipHorizontal: true, flipVertical: true}
})
}
}

View File

@ -1045,7 +1045,7 @@ export default {
formRow: {},
searchData: searchDataDefault(),
loading: false,
uploadVisible: true,
uploadVisible: false,
qcVisible: false,
list: [],
total: 0,

View File

@ -1218,7 +1218,7 @@ import SignForm from "@/views/trials/components/newSignForm";
import { getToken } from "@/utils/auth";
import const_ from "@/const/sign-code";
import uploadPetClinicalData from "@/views/trials/trials-panel/visit/crc-upload/components/uploadPetClinicalData.vue";
import { downloadImage } from "@/utils/uploadZip.js";
import { downloadImage , resetFlag } from "@/utils/uploadZip.js";
export default {
name: "QualityAssurance",
components: {
@ -1331,6 +1331,9 @@ export default {
BodyPart: {},
};
},
beforeDestroy(){
resetFlag();
},
async mounted() {
this.BodyPart.Bodypart = await this.$getBodyPart(this.$route.query.trialId);
if (this.disabled) {