下载优化
continuous-integration/drone/push Build is passing Details

main
wangxiaoshuang 2025-12-17 15:25:00 +08:00
parent ca12b70f41
commit c9d930ce74
3 changed files with 73 additions and 11 deletions

View File

@ -1,5 +1,6 @@
// 检查管理 // 检查管理
import request from '@/utils/request' import request from '@/utils/request'
import requestDownload from '@/utils/request-download'
// 检查->患者列表 // 检查->患者列表
export function getPatientList(data) { export function getPatientList(data) {
@ -203,4 +204,13 @@ export function getDownloadPatientStudyInfo(data) {
method: 'post', method: 'post',
data data
}) })
}
// 获取影像下载数据(接口二)
export function PatientStudyBatchDownload(data) {
return requestDownload({
url: '/download/PatientStudyBatchDownload',
method: 'post',
responseType: 'blob',
data
})
} }

View File

@ -45,13 +45,17 @@ service.interceptors.response.use(
let contentDisposition = response.headers['content-disposition'] let contentDisposition = response.headers['content-disposition']
let fileName = '' let fileName = ''
if (contentDisposition) { if (contentDisposition) {
fileName = contentDisposition.split('; ')[2].split('=')[1].split("\'")[2] if (contentDisposition.includes('zip')) {
fileName = contentDisposition.split('; ')[1].split('=')[1]
} else {
fileName = contentDisposition.split('; ')[2].split('=')[1].split("\'")[2]
}
fileName = decodeURI(fileName) fileName = decodeURI(fileName)
} }
const a = document.createElement('a') const a = document.createElement('a')
// xls类型: application/vnd.ms-excel // xls类型: application/vnd.ms-excel
// xlsx类型application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8 // xlsx类型application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
const href = URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' })) const href = URL.createObjectURL(new Blob([res], { type: response.headers['content-type'] }))
a.download = fileName a.download = fileName
a.href = href a.href = href
a.click() a.click()

View File

@ -234,9 +234,11 @@ import addTrialsList from './components/add-trials-list'
import viewStudyList from './components/view-study-list' import viewStudyList from './components/view-study-list'
import pushRecordList from './components/push-record-list' import pushRecordList from './components/push-record-list'
import pullImage from './components/pullImage/index.vue' import pullImage from './components/pullImage/index.vue'
import { getPatientList, deletePatientStudyAllData, getDownloadPatientStudyInfo } from '@/api/inspection.js' import { getPatientList, deletePatientStudyAllData, getDownloadPatientStudyInfo, PatientStudyBatchDownload } from '@/api/inspection.js'
import { getDicomCalledAEList, getDicomCallingAEList } from '@/api/dicomAE.js' import { getDicomCalledAEList, getDicomCallingAEList } from '@/api/dicomAE.js'
import downloadRecord from "@/views/trials/trials-panel/trial-summary/download-record" import downloadRecord from "@/views/trials/trials-panel/trial-summary/download-record"
import { getToken } from '@/utils/auth'
import * as signalR from '@microsoft/signalr'
import { import {
downloadImageSuccess, downloadImageSuccess,
} from '@/api/trials.js' } from '@/api/trials.js'
@ -319,12 +321,21 @@ export default {
this.downloadVisible = false this.downloadVisible = false
done() done()
}, },
generate() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
},
async getDownloadPatientStudyInfo(arr) { async getDownloadPatientStudyInfo(arr) {
try { try {
let data = { let data = {
PatientIdList: [], PatientIdList: [],
ScpStudyIdList: [] ScpStudyIdList: []
} }
this.downloadId = this.generate()
data.CurrentNoticeId = this.downloadId
arr.forEach(item => { arr.forEach(item => {
data.PatientIdList.push(item.PatientId) data.PatientIdList.push(item.PatientId)
if (item.SCPStudyId) { if (item.SCPStudyId) {
@ -332,14 +343,16 @@ export default {
} }
}) })
let res = await getDownloadPatientStudyInfo(data) // return this.downloadZipDirect(data)
if (res.IsSuccess) { this.onUploadProgress(this.downloadId)
let confirm = await this.$confirm(this.$t('trials:imageSummary:confirm:space').replace('xxx', this.formatSize(res.OtherInfo.ImageSize))) await PatientStudyBatchDownload(data)
if (!confirm) return false // if (res.IsSuccess) {
this.downloadId = res.OtherInfo.downloadId // // let confirm = await this.$confirm(this.$t('trials:imageSummary:confirm:space').replace('xxx', this.formatSize(res.OtherInfo.ImageSize)))
this.downloadImage(res.Result, res.OtherInfo) // // if (!confirm) return false
this.downloadVisible = true // // this.downloadId = res.OtherInfo.downloadId
} // // this.downloadImage(res.Result, res.OtherInfo)
// // this.downloadVisible = true
// }
} catch (err) { } catch (err) {
console.log(err) console.log(err)
} }
@ -570,11 +583,46 @@ export default {
this[`${key}TrialsVisible`] = true this[`${key}TrialsVisible`] = true
this.selectPatient = item this.selectPatient = item
}, },
async onUploadProgress(id, num, type = 'start') {
if (id !== this.downloadId) return false
this.downloadType = type
if (type === 'start') {
this.downloadVisible = true
}
if (type === 'downLoad') {
this.percentage = num
// if (this.downLoadImageCount >= OtherInfo.ImageCount) {
// this.downLoadImageCount = OtherInfo.ImageCount
// this.percentage = 100
// } else {
// this.percentage = (((this.downLoadImageCount / OtherInfo.ImageCount).toFixed(2)) * 100).toFixed(0)
// }
}
// if (type === 'downLoaded') {
// }
// if (type === 'error') {
// let confirm = await this.$confirm(this.$t('trials:imageSummary:confirm:downloadError'))
// this.downLoadType = 'start'
// this.percentage = 0
// this.downLoadImageCount = 0
// this.downloadVisible = false
// }
}
}, },
mounted() { mounted() {
this.$EventBus.$on("reload", (data) => { this.$EventBus.$on("reload", (data) => {
window.location.reload() window.location.reload()
}); });
let connection = new signalR.HubConnectionBuilder()
.withUrl("/DownloadHub", { accessTokenFactory: () => getToken() })
.configureLogging(signalR.LogLevel.Information)
.withAutomaticReconnect()
.build()
connection.start()
connection.on("ReceivProgressAsync", (id, num) => {
this.onUploadProgress2(id, num, 'downLoad')
});
} }
} }
</script> </script>