自定义标准工具添加

uat
caiyiling 2025-04-25 10:52:37 +08:00
parent e3313edefd
commit 8bf6d5f515
2 changed files with 81 additions and 34 deletions

View File

@ -456,7 +456,7 @@ export default {
deep: true,
immediate: true,
handler(v, oldv) {
console.log(v)
// console.log(v)
}
}
},

View File

@ -209,7 +209,15 @@
>
<svg-icon :icon-class="tool.icon" class="svg-icon" />
</div>
<!-- 清除标注 -->
<div
v-if="criterionType === 0"
:class="['tool-item', activeTool === 'Eraser' ? 'tool-item-active' : '']"
:title="$t('trials:dicom-show:Eraser')"
@click.prevent="setToolActive('Eraser')"
>
<svg-icon icon-class="clear" class="svg-icon" />
</div>
<div class="tool-frame">
<!-- 第一帧 -->
<div :title="$t('trials:dicom-show:firstframe')" class="icon" @click.prevent="scrollPage(0)">
@ -356,7 +364,7 @@
<customize-question-list
v-else-if="lastViewportTaskId && criterionType === 0 && lastViewportTaskIds.includes(s.VisitTaskId)"
:ref="`ecrf_${s.VisitTaskId}`"
:reading-task-state="currentVisitInfo.VisitTaskId === taskInfo.VisitTaskId ? readingTaskState : 2"
:reading-task-state="taskInfo && currentVisitInfo.VisitTaskId === taskInfo.VisitTaskId ? readingTaskState : 2"
:last-viewport-task-id="lastViewportTaskId"
:visit-info="s"
@resetAnnotations="resetAnnotations"
@ -454,7 +462,7 @@
</div>
</template>
<script>
import { getRelatedVisitTask, getReadingVisitStudyList, getTableAnswerRowInfoList } from '@/api/trials'
import { getRelatedVisitTask, getReadingVisitStudyList, getTableAnswerRowInfoList, deleteCustomTag } from '@/api/trials'
import { getDoctorShortcutKey, getUserWLTemplateList } from '@/api/user'
import { getCustomTag, submitCustomTag } from '@/api/reading'
import {
@ -977,27 +985,15 @@ export default {
toolGroup.addTool(WindowLevelTool.toolName)
toolGroup.addTool(WindowLevelRegionTool.toolName)
toolGroup.addTool(PlanarRotateTool.toolName)
if (this.criterionType === 0) {
toolGroup.addTool(ArrowAnnotateTool.toolName, {
arrowHeadStyle: 'standard',
changeTextCallback: async(data, eventData, doneChangingTextCallback) => {
return doneChangingTextCallback(await this.customPrompt())
},
getTextCallback: async(doneChangingTextCallback) => {
return doneChangingTextCallback(await this.customPrompt())
}
})
} else {
toolGroup.addTool(ArrowAnnotateTool.toolName, {
arrowHeadStyle: 'standard',
changeTextCallback: async(data, eventData, doneChangingTextCallback) => {
return doneChangingTextCallback(data.text)
},
getTextCallback: async(doneChangingTextCallback) => {
return doneChangingTextCallback('_')
}
})
}
toolGroup.addTool(ArrowAnnotateTool.toolName, {
arrowHeadStyle: 'standard',
changeTextCallback: async(data, eventData, doneChangingTextCallback) => {
return doneChangingTextCallback(data.text)
},
getTextCallback: async(doneChangingTextCallback) => {
return doneChangingTextCallback('_')
}
})
toolGroup.addTool(RectangleROITool.toolName, {
cachedStats: false,
getTextLines: this.getRectangleROIToolTextLines
@ -1045,7 +1041,7 @@ export default {
})
eventTarget.addEventListener('cornerstoneimageloadprogress', this.imageLoadProgress)
console.log(Events)
console.log(Events, toolsEvents)
},
//
imageLoadProgress(e) {
@ -1106,7 +1102,6 @@ export default {
// })
},
renderAnnotations(series) {
console.log('renderAnnotations')
const taskId = series.TaskInfo.VisitTaskId
if (!taskId || this.renderedTaskIds.includes(taskId)) return
this.renderedTaskIds.push(taskId)
@ -1228,8 +1223,12 @@ export default {
annotation.markTool = annotation.metadata.toolName
this.markedSeriesIds.push(series.Id)
const markName = await this.customPrompt()
if (markName) {
annotation.data.label = markName
if (annotation.metadata.toolName === 'ArrowAnnotate') {
annotation.data.text = markName
}
this.saveCustomAnnotation(annotation)
} else {
this.removeAnnotation(annotation)
@ -1238,6 +1237,11 @@ export default {
this.setToolsPassive()
},
validMarkName(markName) {
const annotations = cornerstoneTools.annotation.state.getAllAnnotations()
const i = annotations.findIndex(i => i.visitTaskId === this.taskInfo.VisitTaskId && i.data.label === markName)
return i > -1
},
async saveCustomAnnotation(annotation) {
try {
const measureData = Object.assign({}, annotation)
@ -1251,7 +1255,6 @@ export default {
params.NumberOfFrames = annotation.numberOfFrames
const res = await submitCustomTag(params)
annotation.id = res.Result
console.log(res)
} catch (e) {
console.log(e)
}
@ -1269,14 +1272,41 @@ export default {
}
this.setToolsPassive()
},
customAnnotationRemovedListener(e) {
async customAnnotationRemovedListener(e) {
if (this.readingTaskState === 2) return
const { annotation } = e.detail
if (!annotation) return
if (annotation.visitTaskId === this.taskInfo.VisitTaskId && annotation.seriesId) {
const index = this.markedSeriesIds.indexOf(annotation.seriesId)
if (index !== -1) {
this.markedSeriesIds.splice(index, 1)
try {
if (this.activeTool === 'Eraser') {
await this.$confirm(
this.$t('trials:trials-list:table:isDeleted') +
annotation.data.label +
'?'
)
if (annotation.id) {
deleteCustomTag(annotation.id)
}
}
const index = this.markedSeriesIds.indexOf(annotation.seriesId)
if (index !== -1) {
this.markedSeriesIds.splice(index, 1)
}
const renderingEngine = getRenderingEngine(renderingEngineId)
for (let i = 0; i < this.cells.length; i++) {
const viewportId = `viewport-${i}`
const viewport = renderingEngine.getViewport(viewportId)
viewport.render()
}
} catch (e) {
cornerstoneTools.annotation.state.addAnnotation(annotation)
const renderingEngine = getRenderingEngine(renderingEngineId)
for (let i = 0; i < this.cells.length; i++) {
const viewportId = `viewport-${i}`
const viewport = renderingEngine.getViewport(viewportId)
viewport.render()
}
console.log(e)
}
}
},
@ -2291,11 +2321,28 @@ export default {
}
return params
},
//
//
async customPrompt() {
try {
const that = this
//
const { value } = await this.$prompt(this.$t('trials:noneDicom:message:msg1'))
const { value } = await this.$prompt(this.$t('trials:noneDicom:message:msg1'), '', {
showClose: false,
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
const value = instance.inputValue
if (!value) {
that.$message.error(this.$t('trials:customReading:error:validMarkName1'))
} else if (this.validMarkName(value)) {
that.$message.error(this.$t('trials:customReading:error:validMarkName'))
} else {
done()
}
} else {
done()
}
}
})
return value
} catch {
return null