From 6ecc0e58e9f79518d1c129ccb982581d3bf4acdb Mon Sep 17 00:00:00 2001 From: caiyiling <1321909229@qq.com> Date: Thu, 16 Jul 2026 15:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E6=A0=87=E8=AE=B0=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=9B=E6=A0=87=E8=AE=B0=E5=AE=9A=E4=BD=8D=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reading/dicoms3D/components/ReadPage.vue | 88 ++++++++++++++----- .../visit-review/components/ReadPage.vue | 2 +- .../visit-review/components/StudyList.vue | 33 +++++-- 3 files changed, 93 insertions(+), 30 deletions(-) diff --git a/src/views/trials/trials-panel/reading/dicoms3D/components/ReadPage.vue b/src/views/trials/trials-panel/reading/dicoms3D/components/ReadPage.vue index a83444fb..a985daeb 100644 --- a/src/views/trials/trials-panel/reading/dicoms3D/components/ReadPage.vue +++ b/src/views/trials/trials-panel/reading/dicoms3D/components/ReadPage.vue @@ -1221,12 +1221,7 @@ export default { this.selectArr.push(item.VisitTaskId) } if (item.IsCurrentTask) { - this.markedSeriesIds = [] - annotations.map(i => { - if (i.MeasureData && i.MeasureData.seriesId) { - this.markedSeriesIds.push(i.MeasureData.seriesId) - } - }) + this.syncMarkedSeriesIds(annotations) } } @@ -2052,7 +2047,7 @@ export default { // this.$refs['ecrf'].setAnnotation({ annotation, toolName: annotation.metadata.toolName }) this.$refs[`ecrf_${this.lastViewportTaskId}`][0].setAnnotation({ annotation, toolName: annotation.metadata.toolName }) - this.markedSeriesIds.push(series.Id) + this.syncMarkedSeriesIdsFromState(series.TaskInfo.VisitTaskId) } this.setToolsPassive() @@ -2087,16 +2082,14 @@ export default { throw errorMsg } if (annotation.visitTaskId === this.taskInfo.VisitTaskId && annotation.seriesId) { - const index = this.markedSeriesIds.indexOf(annotation.seriesId) - if (index !== -1) { - this.markedSeriesIds.splice(index, 1) - } + this.syncMarkedSeriesIdsFromState(annotation.visitTaskId) } else { const errorMsg = { message: 'annotation Not allowed to operate' } throw errorMsg } } catch (e) { cornerstoneTools.annotation.state.addAnnotation(annotation) + this.syncMarkedSeriesIdsFromState(annotation.visitTaskId) const renderingEngine = getRenderingEngine(renderingEngineId) for (let i = 0; i < this.cells.length; i++) { const viewportId = `${this.viewportKey}-${i}` @@ -2133,7 +2126,7 @@ export default { annotation.sliceThickness = series.SliceThickness annotation.numberOfFrames = isNaN(parseInt(params.frame)) ? null : parseInt(params.frame) annotation.markTool = annotation.metadata.toolName - this.markedSeriesIds.push(series.Id) + this.syncMarkedSeriesIdsFromState(series.TaskInfo.VisitTaskId) const operateStateEnum = this.$refs[`ecrf_${this.taskInfo.VisitTaskId}`][0].operateStateEnum const markName = await this.customPrompt(!this.isNumber(operateStateEnum)) @@ -2275,10 +2268,7 @@ export default { if (!res.IsSuccess) throw '' } } - const index = this.markedSeriesIds.indexOf(annotation.seriesId) - if (index !== -1) { - this.markedSeriesIds.splice(index, 1) - } + this.syncMarkedSeriesIdsFromState(annotation.visitTaskId) const renderingEngine = getRenderingEngine(renderingEngineId) for (let i = 0; i < this.cells.length; i++) { const viewportId = `${this.viewportKey}-${i}` @@ -2291,6 +2281,7 @@ export default { } } catch (e) { cornerstoneTools.annotation.state.addAnnotation(annotation) + this.syncMarkedSeriesIdsFromState(annotation.visitTaskId) const renderingEngine = getRenderingEngine(renderingEngineId) for (let i = 0; i < this.cells.length; i++) { const viewportId = `${this.viewportKey}-${i}` @@ -2367,6 +2358,22 @@ export default { this.$set(this.visitTaskList[taskIdx], 'Annotations', annotations) this.$set(this.visitTaskList[taskIdx], 'AnnotationUIDs', annotationUIDs) }, + collectMarkedSeriesIds(list = []) { + return [...new Set( + list + .map(item => item?.MeasureData?.seriesId || item?.seriesId) + .filter(Boolean) + )] + }, + syncMarkedSeriesIds(list = []) { + this.markedSeriesIds = this.collectMarkedSeriesIds(list) + }, + syncMarkedSeriesIdsFromState(visitTaskId = this.taskInfo?.VisitTaskId) { + const annotations = cornerstoneTools.annotation.state.getAllAnnotations().filter(item => { + return item.visitTaskId === visitTaskId && item.seriesId + }) + this.syncMarkedSeriesIds(annotations) + }, async resetAnnotations(visitTaskId) { if (this.readingTaskState === 2) return const taskIdx = this.visitTaskList.findIndex(i => i.VisitTaskId === visitTaskId) @@ -2401,9 +2408,9 @@ export default { if (i.MeasureData) { const annotation = i.MeasureData cornerstoneTools.annotation.state.addAnnotation(annotation) - this.markedSeriesIds.push(annotation.seriesId) } }) + this.syncMarkedSeriesIds(annotations) const renderingEngine = getRenderingEngine(renderingEngineId) for (let i = 0; i < this.cells.length; i++) { const viewportId = `${this.viewportKey}-${i}` @@ -4046,8 +4053,10 @@ export default { } } } - this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].setSeriesInfo(series, true) - this.$refs[series.TaskInfo.VisitTaskId][0].setSeriesActive(series.StudyIndex, series.SeriesIndex) + if (!this.isActiveViewportAtMeasureLocation(obj.annotation)) { + this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].setSeriesInfo(series, true) + this.$refs[series.TaskInfo.VisitTaskId][0].setSeriesActive(series.StudyIndex, series.SeriesIndex) + } setTimeout(async () => { const divForDownloadViewport = document.querySelector( `div[data-viewport-uid="${this.viewportKey}-${this.activeViewportIndex}"]` @@ -4058,9 +4067,48 @@ export default { }, 200) } }, + getMeasureImageLocation(measureData = {}) { + const referencedImageId = measureData?.metadata?.referencedImageId + const referencedImageParams = referencedImageId ? this.getInstanceInfo(referencedImageId) : {} + return { + visitTaskId: measureData.visitTaskId, + studyId: measureData.studyId || measureData.StudyId, + seriesId: measureData.seriesId || measureData.SeriesId, + instanceId: measureData.instanceId || measureData.InstanceId || referencedImageParams.instanceId || null, + frame: measureData.numberOfFrames ?? measureData.NumberOfFrames ?? referencedImageParams.frame + } + }, + getActiveViewportImageLocation() { + const viewportRef = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`]?.[0] + const currentSeries = viewportRef?.series + if (!currentSeries) return null + const renderingEngine = getRenderingEngine(renderingEngineId) + const viewport = renderingEngine?.getViewport(`${this.viewportKey}-${this.activeViewportIndex}`) + const currentImageId = viewport?.getCurrentImageId?.() + const currentImageParams = currentImageId ? this.getInstanceInfo(currentImageId) : {} + return { + visitTaskId: currentSeries.TaskInfo?.VisitTaskId, + studyId: currentSeries.StudyId, + seriesId: currentSeries.Id, + instanceId: currentImageParams.instanceId || null, + frame: currentImageParams.frame + } + }, + isActiveViewportAtMeasureLocation(measureData) { + const targetLocation = this.getMeasureImageLocation(measureData) + const currentLocation = this.getActiveViewportImageLocation() + if (!currentLocation || !targetLocation.seriesId) return false + if (targetLocation.visitTaskId && currentLocation.visitTaskId !== targetLocation.visitTaskId) return false + if (targetLocation.studyId && currentLocation.studyId !== targetLocation.studyId) return false + if (currentLocation.seriesId !== targetLocation.seriesId) return false + if (targetLocation.instanceId && currentLocation.instanceId !== targetLocation.instanceId) return false + return currentLocation.frame === targetLocation.frame + }, async getScreenshots(measureData, callback) { if (measureData) { - await this.imageLocation(measureData) + if (!this.isActiveViewportAtMeasureLocation(measureData.annotation)) { + await this.imageLocation(measureData) + } const divForDownloadViewport = document.querySelector( `div[data-viewport-uid="${this.viewportKey}-${this.activeViewportIndex}"]` ) diff --git a/src/views/trials/trials-panel/reading/visit-review/components/ReadPage.vue b/src/views/trials/trials-panel/reading/visit-review/components/ReadPage.vue index ce8dcec7..1bd430f4 100644 --- a/src/views/trials/trials-panel/reading/visit-review/components/ReadPage.vue +++ b/src/views/trials/trials-panel/reading/visit-review/components/ReadPage.vue @@ -251,7 +251,7 @@ export default { return i }) this.$set(this.visitTaskList[taskIdx], 'Annotations', annotations) - this.$refs[visitTaskId][0].initCurrentMaredFiles() + this.$refs[visitTaskId][0].initCurrentMaredFiles(annotations) this.$refs.fileViewer.resetAnnotations({ annotations, visitTaskId }) }, setReadingTaskState(state) { diff --git a/src/views/trials/trials-panel/reading/visit-review/components/StudyList.vue b/src/views/trials/trials-panel/reading/visit-review/components/StudyList.vue index 6d470878..f6525a95 100644 --- a/src/views/trials/trials-panel/reading/visit-review/components/StudyList.vue +++ b/src/views/trials/trials-panel/reading/visit-review/components/StudyList.vue @@ -97,6 +97,7 @@ export default { this.taskInfo = JSON.parse(localStorage.getItem('taskInfo')) this.BodyPart.Bodypart = await this.$getBodyPart(this.$route.query.trialId) this.studyList = this.decorateStudyList(this.visitTaskInfo.StudyList || []) + this.initCurrentMaredFiles(this.visitTaskInfo.Annotations) if (this.studyList.length === 0) return this.$nextTick(() => { this.activeStudy(this.studyList[0].Id) @@ -110,8 +111,26 @@ export default { }) } }, + 'visitTaskInfo.Annotations': { + handler(annotations) { + this.initCurrentMaredFiles(annotations) + }, + deep: true + } }, methods: { + buildCurrentMarkedFiles(annotations = []) { + return annotations.reduce((result, item) => { + const fileId = item?.NoneDicomFileId + if (!fileId) return result + if (!Object.hasOwn(result, fileId)) { + result[fileId] = { count: 1 } + } else { + result[fileId].count++ + } + return result + }, {}) + }, decorateStudyList(studyList = []) { return studyList.map(study => ({ ...study, @@ -204,6 +223,9 @@ export default { if (type === 'remove') { if (Object.hasOwn(this.currentMarkedFiles, fileId)) { this.currentMarkedFiles[fileId].count-- + if (this.currentMarkedFiles[fileId].count <= 0) { + this.$delete(this.currentMarkedFiles, fileId) + } } } else if (type === 'add') { if (!Object.hasOwn(this.currentMarkedFiles, fileId)) { @@ -214,15 +236,8 @@ export default { } }, - initCurrentMaredFiles() { - this.currentMarkedFiles = {} - this.visitTaskInfo.Annotations.map(i => { - if (!Object.hasOwn(this.currentMarkedFiles, i.NoneDicomFileId)) { - this.$set(this.currentMarkedFiles, i.NoneDicomFileId, { count: 1 }) - } else { - this.currentMarkedFiles[i.NoneDicomFileId].count++ - } - }) + initCurrentMaredFiles(annotations = this.visitTaskInfo.Annotations || []) { + this.currentMarkedFiles = this.buildCurrentMarkedFiles(annotations) }, } }