diff --git a/src/store/modules/reading.js b/src/store/modules/reading.js index cfaa2f99..c6491f63 100644 --- a/src/store/modules/reading.js +++ b/src/store/modules/reading.js @@ -814,6 +814,7 @@ const actions = { // 设置当前序列状态为已下载完成 studyList[i].SeriesList[j].loadStatus = true } + break } } } @@ -827,6 +828,24 @@ const actions = { resolve() }) }, + updateSeriesList({ state }, obj) { + return new Promise(resolve => { + if (obj.visitTaskindex > -1 && obj.studyIndex > -1 && obj.seriesIndex > -1) { + var studyList = state.visitTaskList[obj.visitTaskindex].StudyList || [] + if (studyList[obj.studyIndex].SeriesList[obj.seriesIndex].imageloadedArr.indexOf(obj.imageId) < 0) { + studyList[obj.studyIndex].SeriesList[obj.seriesIndex].imageloadedArr.push(obj.imageId) + ++studyList[obj.studyIndex].SeriesList[obj.seriesIndex].prefetchInstanceCount + } else { + studyList[obj.studyIndex].SeriesList[obj.seriesIndex].prefetchInstanceCount = studyList[obj.studyIndex].SeriesList[obj.seriesIndex].instanceCount + // 设置当前序列状态为已下载完成 + studyList[obj.studyIndex].SeriesList[obj.seriesIndex].loadStatus = true + } + state.visitTaskList[obj.visitTaskindex].StudyList = studyList + sessionStorage.setItem('visitTaskList', state.visitTaskList.length > 0 ? JSON.stringify(state.visitTaskList) : '') + } + resolve() + }) + }, setStatus({ state }, obj) { var index = state.visitTaskList.findIndex(i => i.VisitTaskId === obj.visitTaskId) state.visitTaskList[index].IsInit = true diff --git a/src/utils/request-pool.js b/src/utils/request-pool.js index 5253c633..3c1595f5 100644 --- a/src/utils/request-pool.js +++ b/src/utils/request-pool.js @@ -10,7 +10,7 @@ let startExecuteTask = null let endExecuteTask = performance.now() // 执行下载 async function executeTask() { - console.log(taskPool) + // console.log(taskPool) endExecuteTask = performance.now() i++ stopTaskTimer() diff --git a/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue b/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue index 833696ac..c0713dc6 100644 --- a/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue +++ b/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue @@ -184,7 +184,8 @@ export default { isSrFullscreen: false, srDialogVisible: false, srInfo: {}, - digitPlaces: 2 + digitPlaces: 2, + visitTaskIdx: -1 } }, @@ -199,6 +200,14 @@ export default { if (idx === -1) return this.measureData = this.visitTaskList[idx].MeasureData } + }, + visitTaskId: { + immediate: true, + handler(val) { + var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId) + if (idx === -1) return + this.visitTaskIdx = idx + } } // activeSeries: { // immediate: true, @@ -259,13 +268,13 @@ export default { // study.SeriesList.map((series, seriesIndex) => { // if (series.modality !== 'SR') { // series.imageIds.map(image => { - // let priority = 0 + // var p = null // if (series.seriesId === res[i].seriesId) { - // priority = parseInt(new Date().getTime()) * 10 + // p = priority // } else { - // priority = --p + // p = priority - seriesIndex // } - // this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) + // this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority: p }) // }) // } // }) @@ -330,7 +339,7 @@ export default { var p = parseInt(new Date().getTime()) var imageId = seriesInfo.imageIds[seriesInfo.imageIdIndex] requestPoolManager.loadAndCacheImagePlus(imageId, seriesInfo.seriesId, p * 100).then(res => { - this.imageLoaded(seriesInfo, res.data.string('x0020000e')) + this.imageLoaded({ studyIndex: seriesInfo.studyIndex, seriesIndex: seriesInfo.seriesIndex, imageId: res.imageId }) }) }, getStudyList() { @@ -682,13 +691,11 @@ export default { // if (isCurrentTask || isBaseLineTask) { // // 当前任务/基线任务下载所有影像 // series.imageIds.map(image => { - // priority = priority - 1 // this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) // }) // } else if (!isBaseLineTask && !isCurrentTask && study.IsCriticalSequence) { // // 非当前随访任务下载关键影像 // series.imageIds.map(image => { - // priority = priority - 1 // this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) // }) // } @@ -710,7 +717,7 @@ export default { // requestPoolManager.startTaskTimer() this.imageList.map(image => { requestPoolManager.loadAndCacheImagePlus(image.imageId, image.seriesId, image.priority).then(res => { - this.imageLoaded({ visitTaskId: this.visitTaskId, imageId: image.imageId }, res.data.string('x0020000e')) + this.imageLoaded(image) }) }) requestPoolManager.sortTaskPool() @@ -751,17 +758,28 @@ export default { requestPoolManager.removeTask(series.seriesId) this.$set(this.studyList[studyIndex].SeriesList[seriesIndex], 'isLoading', false) }, - async imageLoaded(image, seriesUid) { - await store.dispatch('reading/updateStudyList', { visitTaskId: image.visitTaskId, imageId: image.imageId, seriesUid }) + async imageLoaded(image) { + // await store.dispatch('reading/updateStudyList', { visitTaskId: image.visitTaskId, imageId: image.imageId, seriesUid }) + // console.log(this.studyList[image.studyIndex].SeriesList[image.seriesIndex]) + if (this.studyList[image.studyIndex].SeriesList[image.seriesIndex].imageloadedArr.indexOf(image.imageId) < 0) { + this.studyList[image.studyIndex].SeriesList[image.seriesIndex].imageloadedArr.push(image.imageId) + var count = this.studyList[image.studyIndex].SeriesList[image.seriesIndex].prefetchInstanceCount + this.studyList[image.studyIndex].SeriesList[image.seriesIndex].prefetchInstanceCount = count + 1 + } else { + this.studyList[image.studyIndex].SeriesList[image.seriesIndex].prefetchInstanceCount = this.studyList[image.studyIndex].SeriesList[image.seriesIndex].instanceCount + // 设置当前序列状态为已下载完成 + this.studyList[image.studyIndex].SeriesList[image.seriesIndex].loadStatus = true + } + // store.dispatch('reading/updateSeriesList', { visitTaskindex: this.visitTaskIdx, studyIndex: image.studyIndex, seriesIndex: image.seriesIndex, imageId: image.imageId }) }, // instance下载成功回调 async cornerstoneImageLoaded(e) { - var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId) - if (idx === -1) return - this.studyList = this.visitTaskList[idx].StudyList - if (!this.studyList || this.studyList.length === 0) { - return - } + // var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId) + // if (idx === -1) return + // this.studyList = this.visitTaskList[idx].StudyList + // if (!this.studyList || this.studyList.length === 0) { + // return + // } // if (!this.visitTaskList[idx].IsInit) { // const loading = this.$loading({ fullscreen: true }) // await store.dispatch('reading/getMeasuredData', this.visitTaskList[idx].VisitTaskId) @@ -771,38 +789,38 @@ export default { // await store.dispatch('reading/setStatus', { visitTaskId: this.visitTaskList[idx].VisitTaskId }) // loading.close() // } - await store.dispatch('reading/updateStudyList', { visitTaskId: this.visitTaskId, imageId: e.detail.image.imageId, seriesUid: e.detail.image.data.string('x0020000e') }) - const uri = e.detail.image.sharedCacheKey - const index = this.cachedImages.findIndex(item => item.uri === uri) - if (index === -1) { - this.cachedImages.push({ uri: uri, timestamp: new Date().getTime() }) - } else { - this.cachedImages[index].timestamp = new Date().getTime() - } - var imageId = e.detail.image.imageId - var seriesUid = e.detail.image.data.string('x0020000e') - var studyIndex = -1 - var seriesIndex = -1 - for (let i = 0; i < this.studyList.length; ++i) { - for (let j = 0; j < this.studyList[i].SeriesList.length; ++j) { - if (this.studyList[i].SeriesList[j].seriesUid === seriesUid) { - studyIndex = i - seriesIndex = j - break - } - } - if (studyIndex > 0) break - } - if (seriesIndex < 0) return + // await store.dispatch('reading/updateStudyList', { visitTaskId: this.visitTaskId, imageId: e.detail.image.imageId, seriesUid: e.detail.image.data.string('x0020000e') }) + // const uri = e.detail.image.sharedCacheKey + // const index = this.cachedImages.findIndex(item => item.uri === uri) + // if (index === -1) { + // this.cachedImages.push({ uri: uri, timestamp: new Date().getTime() }) + // } else { + // this.cachedImages[index].timestamp = new Date().getTime() + // } + // var imageId = e.detail.image.imageId + // var seriesUid = e.detail.image.data.string('x0020000e') + // var studyIndex = -1 + // var seriesIndex = -1 + // for (let i = 0; i < this.studyList.length; ++i) { + // for (let j = 0; j < this.studyList[i].SeriesList.length; ++j) { + // if (this.studyList[i].SeriesList[j].seriesUid === seriesUid) { + // studyIndex = i + // seriesIndex = j + // break + // } + // } + // if (studyIndex > 0) break + // } + // if (seriesIndex < 0) return - const imageIdIndex = this.studyList[studyIndex].SeriesList[seriesIndex].imageIds.indexOf(imageId) - if (imageIdIndex < 0) return - if (this.studyList[studyIndex].SeriesList[seriesIndex].imageloadedArr.indexOf(imageId) < 0) { - if (this.studyList[studyIndex].SeriesList[seriesIndex].prefetchInstanceCount >= this.studyList[studyIndex].SeriesList[seriesIndex].instanceCount) { - // 设置当前序列状态为已下载完成 - this.studyList[studyIndex].SeriesList[seriesIndex].loadStatus = true - } - } + // const imageIdIndex = this.studyList[studyIndex].SeriesList[seriesIndex].imageIds.indexOf(imageId) + // if (imageIdIndex < 0) return + // if (this.studyList[studyIndex].SeriesList[seriesIndex].imageloadedArr.indexOf(imageId) < 0) { + // if (this.studyList[studyIndex].SeriesList[seriesIndex].prefetchInstanceCount >= this.studyList[studyIndex].SeriesList[seriesIndex].instanceCount) { + // // 设置当前序列状态为已下载完成 + // this.studyList[studyIndex].SeriesList[seriesIndex].loadStatus = true + // } + // } }, cornerstoneimagecachechanged(e) { const cacheInfo = cornerstone.imageCache.getCacheInfo()