自定义标准工具添加

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, deep: true,
immediate: true, immediate: true,
handler(v, oldv) { handler(v, oldv) {
console.log(v) // console.log(v)
} }
} }
}, },

View File

@ -209,7 +209,15 @@
> >
<svg-icon :icon-class="tool.icon" class="svg-icon" /> <svg-icon :icon-class="tool.icon" class="svg-icon" />
</div> </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 class="tool-frame">
<!-- 第一帧 --> <!-- 第一帧 -->
<div :title="$t('trials:dicom-show:firstframe')" class="icon" @click.prevent="scrollPage(0)"> <div :title="$t('trials:dicom-show:firstframe')" class="icon" @click.prevent="scrollPage(0)">
@ -356,7 +364,7 @@
<customize-question-list <customize-question-list
v-else-if="lastViewportTaskId && criterionType === 0 && lastViewportTaskIds.includes(s.VisitTaskId)" v-else-if="lastViewportTaskId && criterionType === 0 && lastViewportTaskIds.includes(s.VisitTaskId)"
:ref="`ecrf_${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" :last-viewport-task-id="lastViewportTaskId"
:visit-info="s" :visit-info="s"
@resetAnnotations="resetAnnotations" @resetAnnotations="resetAnnotations"
@ -454,7 +462,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getRelatedVisitTask, getReadingVisitStudyList, getTableAnswerRowInfoList } from '@/api/trials' import { getRelatedVisitTask, getReadingVisitStudyList, getTableAnswerRowInfoList, deleteCustomTag } from '@/api/trials'
import { getDoctorShortcutKey, getUserWLTemplateList } from '@/api/user' import { getDoctorShortcutKey, getUserWLTemplateList } from '@/api/user'
import { getCustomTag, submitCustomTag } from '@/api/reading' import { getCustomTag, submitCustomTag } from '@/api/reading'
import { import {
@ -977,27 +985,15 @@ export default {
toolGroup.addTool(WindowLevelTool.toolName) toolGroup.addTool(WindowLevelTool.toolName)
toolGroup.addTool(WindowLevelRegionTool.toolName) toolGroup.addTool(WindowLevelRegionTool.toolName)
toolGroup.addTool(PlanarRotateTool.toolName) toolGroup.addTool(PlanarRotateTool.toolName)
if (this.criterionType === 0) { toolGroup.addTool(ArrowAnnotateTool.toolName, {
toolGroup.addTool(ArrowAnnotateTool.toolName, { arrowHeadStyle: 'standard',
arrowHeadStyle: 'standard', changeTextCallback: async(data, eventData, doneChangingTextCallback) => {
changeTextCallback: async(data, eventData, doneChangingTextCallback) => { return doneChangingTextCallback(data.text)
return doneChangingTextCallback(await this.customPrompt()) },
}, getTextCallback: async(doneChangingTextCallback) => {
getTextCallback: async(doneChangingTextCallback) => { return 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(RectangleROITool.toolName, { toolGroup.addTool(RectangleROITool.toolName, {
cachedStats: false, cachedStats: false,
getTextLines: this.getRectangleROIToolTextLines getTextLines: this.getRectangleROIToolTextLines
@ -1045,7 +1041,7 @@ export default {
}) })
eventTarget.addEventListener('cornerstoneimageloadprogress', this.imageLoadProgress) eventTarget.addEventListener('cornerstoneimageloadprogress', this.imageLoadProgress)
console.log(Events) console.log(Events, toolsEvents)
}, },
// //
imageLoadProgress(e) { imageLoadProgress(e) {
@ -1106,7 +1102,6 @@ export default {
// }) // })
}, },
renderAnnotations(series) { renderAnnotations(series) {
console.log('renderAnnotations')
const taskId = series.TaskInfo.VisitTaskId const taskId = series.TaskInfo.VisitTaskId
if (!taskId || this.renderedTaskIds.includes(taskId)) return if (!taskId || this.renderedTaskIds.includes(taskId)) return
this.renderedTaskIds.push(taskId) this.renderedTaskIds.push(taskId)
@ -1228,8 +1223,12 @@ export default {
annotation.markTool = annotation.metadata.toolName annotation.markTool = annotation.metadata.toolName
this.markedSeriesIds.push(series.Id) this.markedSeriesIds.push(series.Id)
const markName = await this.customPrompt() const markName = await this.customPrompt()
if (markName) { if (markName) {
annotation.data.label = markName annotation.data.label = markName
if (annotation.metadata.toolName === 'ArrowAnnotate') {
annotation.data.text = markName
}
this.saveCustomAnnotation(annotation) this.saveCustomAnnotation(annotation)
} else { } else {
this.removeAnnotation(annotation) this.removeAnnotation(annotation)
@ -1238,6 +1237,11 @@ export default {
this.setToolsPassive() 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) { async saveCustomAnnotation(annotation) {
try { try {
const measureData = Object.assign({}, annotation) const measureData = Object.assign({}, annotation)
@ -1251,7 +1255,6 @@ export default {
params.NumberOfFrames = annotation.numberOfFrames params.NumberOfFrames = annotation.numberOfFrames
const res = await submitCustomTag(params) const res = await submitCustomTag(params)
annotation.id = res.Result annotation.id = res.Result
console.log(res)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
@ -1269,14 +1272,41 @@ export default {
} }
this.setToolsPassive() this.setToolsPassive()
}, },
customAnnotationRemovedListener(e) { async customAnnotationRemovedListener(e) {
if (this.readingTaskState === 2) return if (this.readingTaskState === 2) return
const { annotation } = e.detail const { annotation } = e.detail
if (!annotation) return if (!annotation) return
if (annotation.visitTaskId === this.taskInfo.VisitTaskId && annotation.seriesId) { if (annotation.visitTaskId === this.taskInfo.VisitTaskId && annotation.seriesId) {
const index = this.markedSeriesIds.indexOf(annotation.seriesId) try {
if (index !== -1) { if (this.activeTool === 'Eraser') {
this.markedSeriesIds.splice(index, 1) 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 return params
}, },
// //
async customPrompt() { async customPrompt() {
try { 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 return value
} catch { } catch {
return null return null