下载文件
parent
763e00a6ca
commit
85b88d4564
|
|
@ -4466,4 +4466,11 @@ export function updateReadModuleClinicalData(data) {
|
|||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getTrialUnreadVisitList(trialId) {
|
||||
return request({
|
||||
url: `/DownloadAndUpload/getTrialUnreadVisitList?trialId=${trialId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
@ -50,11 +50,11 @@ export const constantRoutes = [
|
|||
component: () => import('@/views/login/index'),
|
||||
hidden: true
|
||||
},
|
||||
// {
|
||||
// path: '/test',
|
||||
// component: () => import('@/views/test/index'),
|
||||
// hidden: true
|
||||
// },
|
||||
{
|
||||
path: '/test',
|
||||
component: () => import('@/views/test/index'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/resetpassword',
|
||||
component: () => import('@/views/forgetpassword/index'),
|
||||
|
|
|
|||
|
|
@ -1,25 +1,138 @@
|
|||
<template>
|
||||
<div>
|
||||
<!-- <label>行数: </label>
|
||||
<input v-model.number="rows" type="number" min="1" max="3" />
|
||||
<label>列数: </label>
|
||||
<input v-model.number="cols" type="number" min="1" max="3" /> -->
|
||||
<GridLayout :rows="rows" :cols="cols" />
|
||||
<el-input v-model="input" placeholder="" clearable></el-input>
|
||||
<el-button type="primary" size="small" :disabled="!input" @click.stop="getTrialUnreadVisitList">下载</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GridLayout from './GridLayout.vue';
|
||||
|
||||
import { downLoadFile } from '@/utils/stream.js'
|
||||
import { getTrialUnreadVisitList, getExportSubjectVisitImageList } from '@/api/trials'
|
||||
export default {
|
||||
components: {
|
||||
GridLayout,
|
||||
},
|
||||
// components: {
|
||||
// GridLayout,
|
||||
// },
|
||||
data() {
|
||||
return {
|
||||
rows: 2,
|
||||
cols: 2,
|
||||
input: '08deab4a-f842-a7a4-0242-0a0001000000'
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async getTrialUnreadVisitList() {
|
||||
let res = await getTrialUnreadVisitList(this.input)
|
||||
if (res.IsSuccess) {
|
||||
let arr = res.Result
|
||||
this.LoopDownload(arr, 0)
|
||||
}
|
||||
},
|
||||
async LoopDownload(arr, index) {
|
||||
if (index >= arr.length) return false
|
||||
let res = await this.handleExportImage(false, true, arr[index])
|
||||
console.log(res, 'res')
|
||||
if (res) {
|
||||
index++
|
||||
this.LoopDownload(arr, index)
|
||||
}
|
||||
},
|
||||
async handleExportImage(IsKeyImage = false, IsExportReading = false, SubjectVisitId) {
|
||||
try {
|
||||
let data = {
|
||||
TrialId: this.input,
|
||||
IsKeyImage,
|
||||
IsExportReading
|
||||
}
|
||||
data.SubjectVisitIdList = [SubjectVisitId]
|
||||
// if (!IsKeyImage) {
|
||||
// let confirm = await this.$confirm(this.$t('trials:imageSummary:confirm:space').replace('xxx', this.image_size.CheckImageSize))
|
||||
// if (!confirm) return false
|
||||
// }
|
||||
let res = await getExportSubjectVisitImageList(data)
|
||||
if (res.IsSuccess) {
|
||||
return this.downLoad(IsKeyImage, res.Result, IsExportReading)
|
||||
}
|
||||
return false
|
||||
} catch (err) {
|
||||
return false
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
// 下载
|
||||
async downLoad(IsKeyImage = false, row, IsExportReading = false) {
|
||||
try {
|
||||
let { files, name } = this.formatDownloadFile(IsKeyImage, row, IsExportReading)
|
||||
return await downLoadFile(files, name, 'zip')
|
||||
// }
|
||||
} catch (err) {
|
||||
return false
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
// 格式化下载文件路径
|
||||
formatDownloadFile(IsKeyImage = false, row, IsExportReading = false) {
|
||||
let files = [],
|
||||
name = `${this.$route.query.researchProgramNo}_${this.$t('trials:imageSummary:downloadname:dicom')}_${Date.now()}.zip`;
|
||||
if (IsExportReading) {
|
||||
name = `${row.VisitList[0].SubjectCode}_${row.VisitList[0].VisitName}.zip`;
|
||||
}
|
||||
if (!IsKeyImage) {
|
||||
//中心ID/受试者ID/访视名/Study ID_Study Date_Modality/文件
|
||||
row.VisitList.forEach(visit => {
|
||||
if (visit.StudyList && visit.StudyList.length > 0) {
|
||||
visit.StudyList.forEach(study => {
|
||||
let arr = []
|
||||
study.SeriesList.forEach(item => {
|
||||
if (!arr.includes(item.Modality)) {
|
||||
arr.push(item.Modality)
|
||||
}
|
||||
})
|
||||
let str = arr.join('_')
|
||||
let time = study.StudyTime.split(' ')[0]
|
||||
if (study.StudyDIRPath && !study.dirHas) {
|
||||
study.dirHas = true
|
||||
let obj = {
|
||||
name: `${study.StudyCode}_${time}_${str}/DICOMDIR`,
|
||||
url: this.OSSclientConfig.basePath + study.StudyDIRPath,
|
||||
}
|
||||
files.push(obj)
|
||||
}
|
||||
if (study.SeriesList && study.SeriesList.length > 0) {
|
||||
study.SeriesList.forEach(serie => {
|
||||
|
||||
if (serie.InstanceList && serie.InstanceList.length > 0) {
|
||||
serie.InstanceList.forEach(instance => {
|
||||
let instanceArr = instance.Path.split("/")
|
||||
let fileName = instance.FileName || instanceArr[instanceArr.length - 1]
|
||||
let obj = {
|
||||
name: `${study.StudyCode}_${time}_${str}/IMAGE/${fileName}`,
|
||||
url: this.OSSclientConfig.basePath + instance.Path,
|
||||
IsEncapsulated: instance.IsEncapsulated
|
||||
}
|
||||
files.push(obj)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
if (visit.NoneDicomStudyList && visit.NoneDicomStudyList.length > 0) {
|
||||
visit.NoneDicomStudyList.forEach(noneDicomStudy => {
|
||||
if (noneDicomStudy.FileList && noneDicomStudy.FileList.length > 0) {
|
||||
noneDicomStudy.FileList.forEach(file => {
|
||||
let time = noneDicomStudy.ImageDate.split(' ')[0]
|
||||
let obj = {
|
||||
name: `${visit.TrialSiteCode}/${visit.SubjectCode}/${visit.VisitName}/${noneDicomStudy.StudyCode}_${time}_${noneDicomStudy.Modality}/${file.FileName}`,
|
||||
url: this.OSSclientConfig.basePath + file.Path,
|
||||
}
|
||||
files.push(obj)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { files, name }
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Loading…
Reference in New Issue