自定义阅片更改

main
caiyiling 2025-06-13 16:06:54 +08:00
parent 657010202c
commit f60d845725
4 changed files with 541 additions and 293 deletions

View File

@ -1,6 +1,6 @@
const getDefaultState = () => { const getDefaultState = () => {
return { return {
operateInfo: {}, operateInfo: [],
deleteAnnotationIds: [] deleteAnnotationIds: []
} }
} }
@ -11,11 +11,11 @@ const mutations = {
} }
const actions = { const actions = {
setOperateInfo({ state }, obj) { setOperateInfo({ state }, arr) {
state.operateInfo = Object.assign({}, obj) state.operateInfo = arr
}, },
setDeleteAnnotationIds({ state }, arr) { setDeleteAnnotationIds({ state }, arr) {
state.deleteAnnotationIds = Object.assign({}, obj) state.deleteAnnotationIds = arr
}, },
} }

View File

@ -580,22 +580,26 @@ export default {
immediate: true, immediate: true,
handler(v) { handler(v) {
let i = v.findIndex(i=>i.QuestionId === this.question.Id)
const { parentQsId, rowId } = v if (i === -1) return
if (this.question.Id !== parentQsId) return // const { parentQsId, rowId } = v
// if (this.question.Id !== parentQsId) return
if (this.addOrEdit.visible) { if (this.addOrEdit.visible) {
// //
this.setAnswerToQuestion(v) this.setAnswerToQuestion(v)
} else { } else {
// if (v.length === 1) {
// const { parentQsId, rowId } = v const { parentQsId, rowId } = v[0]
if (!parentQsId && !rowId) return if (!parentQsId && !rowId) return
let arr = this.questionForm[parentQsId] let arr = this.questionForm[parentQsId]
if (!arr || !Array.isArray(arr)) return if (!arr || !Array.isArray(arr)) return
let i = arr.findIndex(i=>i.RowId === rowId) let i = arr.findIndex(i=>i.RowId === rowId)
if (i === -1) return if (i === -1) return
this.openAddTableCol(this.question, i) this.openAddTableCol(this.question, i)
}
} }
} }
} }
@ -1096,7 +1100,9 @@ export default {
this.AnswersList = row.TableQuestions.Answers this.AnswersList = row.TableQuestions.Answers
if (!index && index !== 0) { if (!index && index !== 0) {
this.addOrEdit.type = 'add' this.addOrEdit.type = 'add'
this.QuestionsForm = {RowIndex: this.questionForm[this.question.Id].length + 1} this.QuestionsForm = {}
this.$set(this.QuestionsForm, 'RowIndex', this.questionForm[this.question.Id].length + 1)
this.$set(this.QuestionsForm, 'RowId', '')
} else { } else {
this.addOrEdit.type = 'edit' this.addOrEdit.type = 'edit'
this.QuestionsForm = Object.assign({}, this.questionForm[row.Id][index]) this.QuestionsForm = Object.assign({}, this.questionForm[row.Id][index])
@ -1204,31 +1210,35 @@ export default {
unBindAnnotationToQuestion(obj) { unBindAnnotationToQuestion(obj) {
this.$emit('unBindAnnotationToQuestion', obj) this.$emit('unBindAnnotationToQuestion', obj)
}, },
setAnswerToQuestion(obj) { setAnswerToQuestion(arr) {
console.log('setAnswerToQuestion') if (!Array.isArray(arr)) return
let val = null const tableQuestions = this.question.TableQuestions.Questions || []
const {questionId, annotation} = obj
if (!questionId || !annotation) return
const referencedImageId = annotation.metadata.referencedImageId
if (annotation.metadata.toolName === 'Length') {
let length = annotation.data.cachedStats[`imageId:${referencedImageId}`].length
val = length ? parseFloat(length).toFixed(this.digitPlaces) : length
} else if (annotation.metadata.toolName === 'Bidirectional') { arr.forEach(item => {
if (obj.imageToolAttribute === 'length') { if (!item.TableQuestionId || !item.MeasureData) return
let length = annotation.data.cachedStats[`imageId:${referencedImageId}`].length if (!item.ImageToolAttribute) {
val = length ? parseFloat(length).toFixed(this.digitPlaces) : length const targetQuestion = tableQuestions.find(q => q.Id === item.TableQuestionId)
this.$set(this.QuestionsForm, questionId, length) if (targetQuestion) {
} else if (obj.imageToolAttribute === 'width') { item.ImageToolAttribute = targetQuestion.ImageToolAttribute
let short = annotation.data.cachedStats[`imageId:${referencedImageId}`].width }
val = short ? parseFloat(short).toFixed(this.digitPlaces) : short
} }
} const val = this.getAnnotationProp(item.MeasureData, item.ImageToolAttribute)
this.$set(this.QuestionsForm, questionId, val) this.$set(this.QuestionsForm, item.TableQuestionId, val)
})
// this.AnswersList.push(this.QuestionsForm) },
// this.$emit('setFormItemData', {key: this.question.Id, val: this.AnswersList, question: this.question}) getAnnotationProp(annotation, prop) {
// this.formItemNumberChange(this.question.Id, true) if (!annotation) return
const referencedImageId = annotation?.metadata?.referencedImageId
if (!referencedImageId) return null
const cacheKey = `imageId:${referencedImageId}`
const cachedStats = annotation.data?.cachedStats?.[cacheKey]
const hasProp = cachedStats
&& Object.prototype.hasOwnProperty.call(cachedStats, prop)
if (!hasProp) return null
const value = cachedStats[prop]
return value !== null
? parseFloat(value).toFixed(this.digitPlaces)
: value
}, },
async beforeClose(done) { async beforeClose(done) {
try { try {

View File

@ -363,213 +363,385 @@ export default {
const i = this.questionMarkInfoList.findIndex(i => i.MeasureData && i.MeasureData.annotationUID === annotation.annotationUID) const i = this.questionMarkInfoList.findIndex(i => i.MeasureData && i.MeasureData.annotationUID === annotation.annotationUID)
return i > -1 return i > -1
}, },
async operateImageMarker(obj) { // async operateImageMarker(obj) {
this.operateStateEnum = obj.operateStateEnum // this.operateStateEnum = obj.operateStateEnum
this.isTableQuestion = obj.question.IsTableQuestion ? true : false // this.isTableQuestion = obj.question.IsTableQuestion ? true : false
this.imageTool = obj.question.ImageTool // this.imageTool = obj.question.ImageTool
this.imageToolAttribute = obj.question.ImageToolAttribute // this.imageToolAttribute = obj.question.ImageToolAttribute
this.operateQuestionId = obj.question.Id // this.operateQuestionId = obj.question.Id
this.operateRowId = obj.question.RowId // this.operateRowId = obj.question.RowId
this.operateParentQsId = obj.question.ParentQsId // this.operateParentQsId = obj.question.ParentQsId
if (obj.operateStateEnum === 0) { // if (obj.operateStateEnum === 0) {
// // //
this.$emit('setReadingToolPassive') // this.$emit('setReadingToolPassive')
} else if (obj.operateStateEnum === 1) { // } else if (obj.operateStateEnum === 1) {
// // //
this.$emit('setReadingToolActive', obj.question.ImageTool) // this.$emit('setReadingToolActive', obj.question.ImageTool)
} else if (obj.operateStateEnum === 2) { // } else if (obj.operateStateEnum === 2) {
// // //
let i = -1 // let i = -1
if (this.isTableQuestion) { // if (this.isTableQuestion) {
if (this.operateRowId) { // if (this.operateRowId) {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && i.RowId === this.operateRowId) // i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && i.RowId === this.operateRowId)
} else { // } else {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && !i.RowId) // i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && !i.RowId)
} // }
} else { // } else {
i = this.questionMarkInfoList.findIndex(i => i.QuestionId === obj.question.Id) // i = this.questionMarkInfoList.findIndex(i => i.QuestionId === obj.question.Id)
} // }
if (i > -1) { // if (i > -1) {
const annotation = this.questionMarkInfoList[i].MeasureData // const annotation = this.questionMarkInfoList[i].MeasureData
this.$emit('viewCustomAnnotationSeries', { visitTaskId: this.visitTaskId, annotation }) // this.$emit('viewCustomAnnotationSeries', { visitTaskId: this.visitTaskId, annotation })
} // }
} else if (obj.operateStateEnum === 3) { // } else if (obj.operateStateEnum === 3) {
// // //
this.$emit('setReadingToolPassive') // this.$emit('setReadingToolPassive')
} else if (obj.operateStateEnum === 4) { // } else if (obj.operateStateEnum === 4) {
this.$emit('setReadingToolPassive') // this.$emit('setReadingToolPassive')
// // //
let i = -1 // let i = -1
let questionMarkInfo = {} // let questionMarkInfo = {}
if (this.isTableQuestion) { // if (this.isTableQuestion) {
if (this.operateRowId) { // if (this.operateRowId) {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && i.RowId === this.operateRowId) // i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && i.RowId === this.operateRowId)
} else { // } else {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && !i.RowId) // i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === obj.question.Id && !i.RowId)
} // }
} else { // } else {
this.$set(this.questionForm, obj.question.Id, '') // this.$set(this.questionForm, obj.question.Id, '')
i = this.questionMarkInfoList.findIndex(i => i.QuestionId === obj.question.Id) // i = this.questionMarkInfoList.findIndex(i => i.QuestionId === obj.question.Id)
} // }
if (i === -1) return // if (i === -1) return
this.questionMarkInfoList[i].MeasureData = '' // this.questionMarkInfoList[i].MeasureData = ''
this.questionMarkInfoList[i].StudyId = '' // this.questionMarkInfoList[i].StudyId = ''
this.questionMarkInfoList[i].SeriesId = '' // this.questionMarkInfoList[i].SeriesId = ''
this.questionMarkInfoList[i].InstanceId = '' // this.questionMarkInfoList[i].InstanceId = ''
questionMarkInfo = this.questionMarkInfoList[i] // questionMarkInfo = this.questionMarkInfoList[i]
questionMarkInfo.isMarked = false // questionMarkInfo.isMarked = false
questionMarkInfo.isSaved = false // questionMarkInfo.isSaved = false
this.$set(this.questionsMarkStatus, this.operateRowId ? `${this.operateRowId}_${obj.question.Id}` : obj.question.Id, questionMarkInfo) // this.$set(this.questionsMarkStatus, this.operateRowId ? `${this.operateRowId}_${obj.question.Id}` : obj.question.Id, questionMarkInfo)
} else if (obj.operateStateEnum === 5) { // } else if (obj.operateStateEnum === 5) {
// // //
this.loading = true // this.loading = true
try { // try {
const answers = [] // const answers = []
answers.push({ id: obj.question.Id, answer: this.questionForm[obj.question.Id] }) // answers.push({ id: obj.question.Id, answer: this.questionForm[obj.question.Id] })
const markInfo = [] // const markInfo = []
const i = this.questionMarkInfoList.findIndex(i => i.QuestionId === this.operateQuestionId) // const i = this.questionMarkInfoList.findIndex(i => i.QuestionId === this.operateQuestionId)
if (i > -1) { // if (i > -1) {
const obj = Object.assign({}, this.questionMarkInfoList[i]) // const obj = Object.assign({}, this.questionMarkInfoList[i])
obj.MeasureData = obj.MeasureData ? JSON.stringify(obj.MeasureData) : '' // obj.MeasureData = obj.MeasureData ? JSON.stringify(obj.MeasureData) : ''
markInfo.push(obj) // markInfo.push(obj)
} // }
// // //
const params = { // const params = {
visitTaskId: this.visitTaskId, // visitTaskId: this.visitTaskId,
answers: answers, // answers: answers,
questionMarkInfoList: markInfo // questionMarkInfoList: markInfo
} // }
await saveTaskQuestion(-10, params) // await saveTaskQuestion(-10, params)
this.$set(this.questionsMarkStatus, obj.question.Id, {isMarked: this.questionMarkInfoList[i].MeasureData ? true : false, isSaved: true}) // this.$set(this.questionsMarkStatus, obj.question.Id, {isMarked: this.questionMarkInfoList[i].MeasureData ? true : false, isSaved: true})
this.loading = false // this.loading = false
} catch (e) { // } catch (e) {
console.log(e) // console.log(e)
this.loading = false // this.loading = false
} // }
} else if (obj.operateStateEnum === 6) { // } else if (obj.operateStateEnum === 6) {
// // //
let questionMarkInfo = {} // let questionMarkInfo = {}
if (this.isTableQuestion) { // if (this.isTableQuestion) {
questionMarkInfo.isMarked = false // questionMarkInfo.isMarked = false
questionMarkInfo.isSaved = false // questionMarkInfo.isSaved = false
} else { // } else {
questionMarkInfo.isMarked = false // questionMarkInfo.isMarked = false
questionMarkInfo.isSaved = false // questionMarkInfo.isSaved = false
} // }
this.$set(this.questionsMarkStatus, this.operateRowId ? `${this.operateRowId}_obj.question.Id` : obj.question.Id, questionMarkInfo) // this.$set(this.questionsMarkStatus, this.operateRowId ? `${this.operateRowId}_obj.question.Id` : obj.question.Id, questionMarkInfo)
} else if (obj.operateStateEnum === 7) { // } else if (obj.operateStateEnum === 7) {
// // //
const loading = this.$loading({ fullscreen: true }) // const loading = this.$loading({ fullscreen: true })
try { // try {
let annotation = null // let annotation = null
if (!this.operateRowId && this.operateQuestionId && obj.rowId) { // if (!this.operateRowId && obj.rowId && obj.question.ParentQsId) {
const i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === this.operateQuestionId && !i.RowId) // this.operateRowId = obj.rowId
if (i === -1) return // this.questionMarkInfoList.forEach(item => {
this.questionMarkInfoList[i].RowId = obj.rowId // if (item.QuestionId === obj.question.ParentQsId && !item.RowId) {
this.operateRowId = obj.rowId // item.RowId = obj.rowId
annotation = this.questionMarkInfoList[i].MeasureData // let questionMarkStatus = Object.assign({}, this.questionsMarkStatus[item.TableQuestionId])
let questionMarkStatus = Object.assign({}, this.questionsMarkStatus[this.operateQuestionId]) // delete this.questionsMarkStatus[item.TableQuestionId]
delete this.questionsMarkStatus[this.operateQuestionId] // if (item.TableQuestionId === this.operateQuestionId) {
this.$set(this.questionsMarkStatus, `${obj.rowId}_${this.operateQuestionId}`, questionMarkStatus) // annotation = item.MeasureData
} else if (this.operateRowId && this.operateQuestionId) { // this.$set(this.questionsMarkStatus, `${obj.rowId}_${item.TableQuestionId}`, questionMarkStatus)
const i = this.questionMarkInfoList.findIndex(i => i.RowId === this.operateRowId && i.TableQuestionId === this.operateQuestionId) // } else {
if (i === -1) return // this.$set(this.questionsMarkStatus, `${obj.rowId}_${item.TableQuestionId}`, {isMarked: item.MeasureData ? true : false, isSaved: false})
annotation = this.questionMarkInfoList[i].MeasureData // }
}
let picturePath = '' // }
if (annotation) { // })
// // } else if (this.operateRowId && this.operateQuestionId) {
const base64Str = await this.getScreenshots({ visitTaskId: this.visitTaskId, annotation }) // const i = this.questionMarkInfoList.findIndex(i => i.RowId === this.operateRowId && i.TableQuestionId === this.operateQuestionId)
const pictureObj = await this.uploadScreenshots(`${new Date().getTime()}`, base64Str) // if (i === -1) return
picturePath = pictureObj.isSuccess ? this.$getObjectName(pictureObj.result.url) : '' // annotation = this.questionMarkInfoList[i].MeasureData
} // }
let params = { // let picturePath = ''
Answer: obj.answer, // if (annotation) {
VisitTaskId: this.visitTaskId, // //
QuestionId: obj.question.ParentQsId, // const base64Str = await this.getScreenshots({ visitTaskId: this.visitTaskId, annotation })
InstanceId: annotation ? annotation.instanceId : '', // const pictureObj = await this.uploadScreenshots(`${new Date().getTime()}`, base64Str)
SeriesId: annotation ? annotation.seriesId : '', // picturePath = pictureObj.isSuccess ? this.$getObjectName(pictureObj.result.url) : ''
StudyId: annotation ? annotation.studyId : '', // }
MarkTool: annotation ? annotation.markTool : '', // let params = {
PicturePath: picturePath, // Answer: obj.answer,
NumberOfFrames: annotation ? annotation.numberOfFrames : null, // VisitTaskId: this.visitTaskId,
MeasureData: annotation ? JSON.stringify(annotation) : '', // QuestionId: obj.question.ParentQsId,
QuestionType: 0, // InstanceId: annotation ? annotation.instanceId : '',
OrderMarkName: annotation ? annotation.data.label : '', // SeriesId: annotation ? annotation.seriesId : '',
RowId: this.operateRowId, // StudyId: annotation ? annotation.studyId : '',
TableQuestionId: this.operateQuestionId, // MarkTool: annotation ? annotation.markTool : '',
RowIndex: obj.rowIndex // PicturePath: picturePath,
} // NumberOfFrames: annotation ? annotation.numberOfFrames : null,
// // MeasureData: annotation ? JSON.stringify(annotation) : '',
await saveTableQuestionMark(params, -10) // QuestionType: 0,
this.$set(this.questionsMarkStatus, `${this.operateRowId}_${this.operateQuestionId}`, {isMarked: annotation ? true : false, isSaved: true}) // OrderMarkName: annotation ? annotation.data.label : '',
this.resetOperateState() // RowId: this.operateRowId,
loading.close() // TableQuestionId: this.operateQuestionId,
} catch(e) { // RowIndex: obj.rowIndex
console.log(e) // }
loading.close() // //
// await saveTableQuestionMark(params, -10)
// this.$set(this.questionsMarkStatus, `${this.operateRowId}_${this.operateQuestionId}`, {isMarked: annotation ? true : false, isSaved: true})
// this.resetOperateState()
// loading.close()
// } catch(e) {
// console.log(e)
// loading.close()
// }
// }
// },
async operateImageMarker(obj) {
const STATE = {
BIND: 0, //
ADD: 1, //
VIEW: 2, //
CHANGE: 3, //
REMOVE: 4, //
SAVE_OUTER: 5, //
UPDATE: 6, //
SAVE_TABLE: 7 //
}
const { question, operateStateEnum, rowId, answer } = obj
const { Id, IsTableQuestion, ImageTool, ImageToolAttribute, ParentQsId, RowId } = question
Object.assign(this, {
operateStateEnum,
isTableQuestion: !!IsTableQuestion,
imageTool: ImageTool,
imageToolAttribute: ImageToolAttribute,
operateQuestionId: Id,
operateRowId: RowId,
operateParentQsId: ParentQsId
})
const stateHandlers = {
[STATE.BIND]: () => this.$emit('setReadingToolPassive'),
[STATE.ADD]: () => this.$emit('setReadingToolActive', ImageTool),
[STATE.VIEW]: this.handleViewState,
[STATE.CHANGE]: () => this.$emit('setReadingToolPassive'),
[STATE.REMOVE]: this.handleRemoveState,
[STATE.SAVE_OUTER]: this.handleSaveOuterState,
[STATE.UPDATE]: this.handleUpdateState,
[STATE.SAVE_TABLE]: this.handleSaveTableState
}
const handler = stateHandlers[operateStateEnum]
handler && await handler.call(this, obj)
},
async handleViewState(obj) {
const index = this.findMarkIndex(obj.question)
if (index === -1) return
const annotation = this.questionMarkInfoList[index].MeasureData
this.$emit('viewCustomAnnotationSeries', {
visitTaskId: this.visitTaskId,
annotation
})
},
handleRemoveState(obj) {
const index = this.findMarkIndex(obj.question)
if (index === -1) return
Object.assign(this.questionMarkInfoList[index], {
MeasureData: '',
StudyId: '',
SeriesId: '',
InstanceId: ''
})
const key = this.operateRowId
? `${this.operateRowId}_${obj.question.Id}`
: obj.question.Id
this.$set(this.questionsMarkStatus, key, {
isMarked: false,
isSaved: false
})
},
async handleSaveOuterState(obj) {
this.loading = true;
try {
const answers = [{ id: obj.question.Id, answer: this.questionForm[obj.question.Id] }]
const markInfo = []
const index = this.questionMarkInfoList.findIndex(
item => item.QuestionId === this.operateQuestionId
)
if (index > -1) {
const item = { ...this.questionMarkInfoList[index] }
item.MeasureData = item.MeasureData ? JSON.stringify(item.MeasureData) : ''
markInfo.push(item)
} }
await saveTaskQuestion(-10, {
visitTaskId: this.visitTaskId,
answers,
questionMarkInfoList: markInfo
})
this.$set(this.questionsMarkStatus, obj.question.Id, {
isMarked: !!this.questionMarkInfoList[index]?.MeasureData,
isSaved: true
})
} catch (e) {
console.error('保存失败:', e)
} finally {
this.loading = false
} }
}, },
handleUpdateState(obj) {
async bindAnnotationToQuestion(annotation) { const key = this.operateRowId
console.log('bindAnnotationToQuestion') ? `${this.operateRowId}_${obj.question.Id}`
: obj.question.Id
this.$set(this.questionsMarkStatus, key, {
isMarked: false,
isSaved: false
})
},
async handleSaveTableState(obj) {
const loading = this.$loading({ fullscreen: true })
try { try {
if (!(this.operateStateEnum === null || this.operateStateEnum === 0 || this.operateStateEnum === 1 || this.operateStateEnum === 3)) return let annotation = null
if (this.operateStateEnum === 1 && annotation.markTool !== this.imageTool) return if (!this.operateRowId && obj.rowId && obj.question.ParentQsId) {
if (this.operateStateEnum === null) { this.updateQuestionsMarkStatus(obj)
for(let i = 0; i < this.questionMarkInfoList.length; i++) { annotation = this.getAnnotationByRow(obj.rowId)
if (this.questionMarkInfoList[i].MeasureData.annotationUID === annotation.annotationUID) { } else if (this.operateRowId && this.operateQuestionId) {
this.questionMarkInfoList[i].MeasureData = annotation annotation = this.getAnnotationByRow(this.operateRowId)
if (this.questionMarkInfoList[i].TableQuestionId) { }
store.dispatch('dicom3d/setOperateInfo', {annotation, parentQsId: this.questionMarkInfoList[i].QuestionId, questionId: this.questionMarkInfoList[i].TableQuestionId, rowId: this.questionMarkInfoList[i].RowId, imageToolAttribute: this.questionMarkInfoList[i].MarkTool}) //
let picturePath = ''
let keyId = i > -1 && this.questionMarkInfoList[i].RowId ? `${this.questionMarkInfoList[i].RowId}_${this.questionMarkInfoList[i].TableQuestionId}` : this.questionMarkInfoList[i].TableQuestionId if (annotation) {
this.$set(this.questionsMarkStatus, keyId, {isMarked: true, isSaved: false}) const base64Str = await this.getScreenshots({
} else { visitTaskId: this.visitTaskId,
this.setAnswerToQuestion(annotation, this.questionMarkInfoList[i].QuestionId) annotation
this.$set(this.questionsMarkStatus, this.questionMarkInfoList[i].QuestionId, {isMarked: true, isSaved: false}) })
} const pictureObj = await this.uploadScreenshots(`${Date.now()}`, base64Str)
} picturePath = pictureObj.isSuccess ? this.$getObjectName(pictureObj.result.url) : ''
}
await saveTableQuestionMark({
Answer: obj.answer,
VisitTaskId: this.visitTaskId,
QuestionId: obj.question.ParentQsId,
...(annotation ? {
InstanceId: annotation.instanceId,
SeriesId: annotation.seriesId,
StudyId: annotation.studyId,
MarkTool: annotation.markTool,
NumberOfFrames: annotation.numberOfFrames,
MeasureData: JSON.stringify(annotation),
OrderMarkName: annotation.data.label
} : {}),
PicturePath: picturePath,
QuestionType: 0,
RowId: this.operateRowId,
TableQuestionId: this.operateQuestionId,
RowIndex: obj.rowIndex
}, -10)
this.$set(this.questionsMarkStatus,
`${this.operateRowId}_${this.operateQuestionId}`,
{ isMarked: !!annotation, isSaved: true }
)
this.resetOperateState()
} catch(e) {
console.error('表格保存失败:', e)
} finally {
loading.close()
}
},
findMarkIndex(question) {
const { Id, RowId } = question
if (this.isTableQuestion) {
return RowId
? this.questionMarkInfoList.findIndex(i =>
i.TableQuestionId === Id && i.RowId === RowId)
: this.questionMarkInfoList.findIndex(i =>
i.TableQuestionId === Id && !i.RowId)
}
return this.questionMarkInfoList.findIndex(i => i.QuestionId === Id)
},
updateQuestionsMarkStatus(obj) {
this.operateRowId = obj.rowId
this.questionMarkInfoList.forEach(item => {
if (item.QuestionId === obj.question.ParentQsId && !item.RowId) {
item.RowId = obj.rowId
const oldKey = item.TableQuestionId
const newKey = `${obj.rowId}_${item.TableQuestionId}`
if (this.questionsMarkStatus[oldKey]) {
const status = { ...this.questionsMarkStatus[oldKey] }
delete this.questionsMarkStatus[oldKey]
this.$set(this.questionsMarkStatus, newKey, status)
} }
return }
})
},
getAnnotationByRow(rowId) {
const index = this.questionMarkInfoList.findIndex(
i => i.RowId === rowId && i.TableQuestionId === this.operateQuestionId
)
return index > -1 ? this.questionMarkInfoList[index].MeasureData : null
},
async bindAnnotationToQuestion(annotation) {
try {
const VALID_STATES = [null, 0, 1, 3]
const currentState = this.operateStateEnum
if (!VALID_STATES.includes(currentState)) return
const isInvalidAnnotation = currentState === 1 && annotation.markTool !== this.imageTool
if (isInvalidAnnotation) return
if (currentState === null) {
return this.handleNullState(annotation)
} }
if (!this.operateQuestionId) return if (!this.operateQuestionId) return
if (this.operateStateEnum === 0 || this.operateStateEnum === 3) { if ([0, 3].includes(currentState)) {
if (!annotation.data.label) { if (!annotation.data.label || annotation.markTool !== this.imageTool) {
this.$alert('该标记不能与问题绑定!') this.$alert('该标记不能与问题绑定!')
return return
} }
if (annotation.markTool !== this.imageTool) { if (currentState === 3) {
this.$alert('该标记不能与问题绑定!') const conflictIndex = this.questionMarkInfoList.findIndex(
return item => item.MeasureData.annotationUID === annotation.annotationUID
} && item.RowId !== this.operateRowId
// rowId )
if (this.operateStateEnum === 3) { if (conflictIndex > -1) {
const i = this.questionMarkInfoList.findIndex(i=>i.MeasureData.annotationUID === annotation.annotationUID && i.RowId !== this.operateRowId)
if (i > -1) {
this.$alert('该标记已绑定到其他行,不能更改绑定!') this.$alert('该标记已绑定到其他行,不能更改绑定!')
return return
} }
} }
let msg = this.operateStateEnum === 0 ? '是否确认绑定?' : '是否确认更改?' const message = currentState === 0 ? '是否确认绑定?' : '是否确认更改?'
const confirm = await this.$confirm(msg, { const result = await this.$confirm(message, {
type: 'warning', type: 'warning',
distinguishCancelAndClose: true distinguishCancelAndClose: true
}) })
if (confirm !== 'confirm') return const isConfirmed = result === 'confirm'
if (!isConfirmed) return
} }
let i = -1 const targetIndex = this.findTargetIndex()
if (this.isTableQuestion && this.operateRowId) { if (targetIndex === -1) {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === this.operateQuestionId && i.RowId === this.operateRowId) this.questionMarkInfoList.push({
} else if (this.isTableQuestion) {
i = this.questionMarkInfoList.findIndex(i => i.TableQuestionId === this.operateQuestionId && !i.RowId)
} else {
i = this.questionMarkInfoList.findIndex(i => i.QuestionId === this.operateQuestionId)
}
if (i === -1) {
const markInfo = {
InstanceId: annotation.instanceId, InstanceId: annotation.instanceId,
SeriesId: annotation.seriesId, SeriesId: annotation.seriesId,
StudyId: annotation.studyId, StudyId: annotation.studyId,
@ -577,79 +749,145 @@ export default {
PicturePath: '', PicturePath: '',
NumberOfFrames: annotation.numberOfFrames, NumberOfFrames: annotation.numberOfFrames,
MeasureData: annotation, MeasureData: annotation,
RowId: this.operateRowId ? this.operateRowId : '', RowId: this.operateRowId || '',
QuestionId: this.isTableQuestion ? this.operateParentQsId : this.operateQuestionId, QuestionId: this.isTableQuestion
TableQuestionId: this.isTableQuestion ? this.operateQuestionId : '', ? this.operateParentQsId
} : this.operateQuestionId,
this.questionMarkInfoList.push(markInfo) TableQuestionId: this.isTableQuestion
? this.operateQuestionId
: ''
})
} else { } else {
this.questionMarkInfoList[i].InstanceId = annotation.instanceId const target = this.questionMarkInfoList[targetIndex]
this.questionMarkInfoList[i].SeriesId = annotation.seriesId Object.assign(target, {
this.questionMarkInfoList[i].StudyId = annotation.studyId InstanceId: annotation.instanceId,
this.questionMarkInfoList[i].MarkTool = annotation.metadata.toolName SeriesId: annotation.seriesId,
this.questionMarkInfoList[i].PicturePath = '' StudyId: annotation.studyId,
this.questionMarkInfoList[i].NumberOfFrames = annotation.numberOfFrames MarkTool: annotation.metadata.toolName,
this.questionMarkInfoList[i].MeasureData = annotation PicturePath: '',
NumberOfFrames: annotation.numberOfFrames,
MeasureData: annotation
})
} }
let obj = null this.updateMarkStatus(targetIndex, annotation)
if (this.isTableQuestion) { this.operateStateEnum = null
obj = {isMarked: true, isSaved: false}
store.dispatch('dicom3d/setOperateInfo', {annotation, parentQsId: this.operateParentQsId, questionId: this.operateQuestionId, rowId: this.operateRowId, imageToolAttribute: this.imageToolAttribute})
let keyId = i > -1 && this.questionMarkInfoList[i].RowId ? `${this.questionMarkInfoList[i].RowId}_${this.questionMarkInfoList[i].TableQuestionId}` : this.operateRowId ? `${this.operateRowId}_${this.operateQuestionId}` : this.operateQuestionId
this.$set(this.questionsMarkStatus, keyId, obj)
} else {
obj = {isMarked: true, isSaved: false}
this.setAnswerToQuestion(annotation, this.operateQuestionId)
this.$set(this.questionsMarkStatus, this.operateQuestionId, obj)
}
this.operateStateEnum === null
} catch (e) { } catch (e) {
console.log(e) console.error('绑定失败:', e); //
} }
}, },
updateAnnotationToQuestion(annotation) { handleNullState(annotation) {
const i = this.questionMarkInfoList.findIndex(i => i.MeasureData && i.MeasureData.annotationUID === annotation.annotationUID) const qsArr = []
if (i === -1) return const markList = this.questionMarkInfoList
this.questionMarkInfoList[i].MeasureData = annotation for (let i = 0; i < markList.length; i++) {
let obj = null const item = markList[i];
if (this.isTableQuestion || this.questionMarkInfoList[i].TableQuestionId) { if (item.MeasureData?.annotationUID !== annotation.annotationUID) continue
this.operateParentQsId = this.operateParentQsId ? this.operateParentQsId : this.questionMarkInfoList[i].QuestionId item.MeasureData = annotation
this.operateQuestionId = this.operateQuestionId ? this.operateQuestionId : this.questionMarkInfoList[i].TableQuestionId
this.operateRowId = this.operateRowId ? this.operateRowId : this.questionMarkInfoList[i].RowId if (item.TableQuestionId) {
this.imageToolAttribute = this.imageToolAttribute ? this.imageToolAttribute : annotation.metadata.toolName qsArr.push({ ...item, ImageToolAttribute: this.imageToolAttribute })
obj = {isMarked: true, isSaved: false}
store.dispatch('dicom3d/setOperateInfo', {annotation, parentQsId: this.operateParentQsId, questionId: this.operateQuestionId, rowId: this.operateRowId, imageToolAttribute: this.imageToolAttribute}) const keyId = item.RowId
let keyId = this.questionMarkInfoList[i].RowId ? `${this.questionMarkInfoList[i].RowId}_${this.questionMarkInfoList[i].TableQuestionId}` : this.questionMarkInfoList[i].TableQuestionId ? `${item.RowId}_${item.TableQuestionId}`
this.$set(this.questionsMarkStatus, keyId, obj) : item.TableQuestionId
} else { this.$set(this.questionsMarkStatus, keyId, {
obj = {isMarked: true, isSaved: false} isMarked: true,
this.setAnswerToQuestion(annotation, this.questionMarkInfoList[i].QuestionId) isSaved: false
this.$set(this.questionsMarkStatus, this.questionMarkInfoList[i].QuestionId, obj) })
} else {
this.setAnswerToQuestion(annotation, item.QuestionId)
this.$set(this.questionsMarkStatus, item.QuestionId, {
isMarked: true,
isSaved: false
})
}
}
if (qsArr.length) {
store.dispatch('dicom3d/setOperateInfo', qsArr)
}
},
findTargetIndex() {
if (this.isTableQuestion && this.operateRowId) {
return this.questionMarkInfoList.findIndex(
item => item.TableQuestionId === this.operateQuestionId
&& item.RowId === this.operateRowId
)
} else if (this.isTableQuestion) {
return this.questionMarkInfoList.findIndex(
item => item.TableQuestionId === this.operateQuestionId
&& !item.RowId
)
}
return this.questionMarkInfoList.findIndex(
item => item.QuestionId === this.operateQuestionId
)
},
updateMarkStatus(index, annotation) {
const status = { isMarked: true, isSaved: false }
if (this.isTableQuestion) {
const keyId = index > -1 && this.questionMarkInfoList[index].RowId
? `${this.questionMarkInfoList[index].RowId}_${this.questionMarkInfoList[index].TableQuestionId}`
: this.operateRowId
? `${this.operateRowId}_${this.operateQuestionId}`
: this.operateQuestionId
this.$set(this.questionsMarkStatus, keyId, status)
store.dispatch('dicom3d/setOperateInfo', [{
MeasureData: annotation,
QuestionId: this.operateParentQsId,
TableQuestionId: this.operateQuestionId,
RowId: this.operateRowId,
ImageToolAttribute: this.imageToolAttribute
}])
} else {
this.setAnswerToQuestion(annotation, this.operateQuestionId)
this.$set(this.questionsMarkStatus, this.operateQuestionId, status)
}
},
updateAnnotationToQuestion(annotation) {
const questionMarkInfo = { isMarked: true, isSaved: false }
const qsArr = []
for (let i = 0; i < this.questionMarkInfoList.length; i++) {
const item = this.questionMarkInfoList[i]
if (!item.MeasureData || item.MeasureData.annotationUID !== annotation.annotationUID) continue
item.MeasureData = annotation
const isTableMode = this.isTableQuestion || item.TableQuestionId
if (!isTableMode) {
this.setAnswerToQuestion(annotation, item.QuestionId)
this.$set(this.questionsMarkStatus, item.QuestionId, questionMarkInfo)
continue
}
this.operateParentQsId = item.QuestionId
this.operateQuestionId = item.TableQuestionId
this.operateRowId ||= item.RowId
qsArr.push({ ...item })
const keyId = item.RowId ? `${item.RowId}_${item.TableQuestionId}` : item.TableQuestionId;
this.$set(this.questionsMarkStatus, keyId, questionMarkInfo);
}
if (qsArr.length > 0) {
store.dispatch('dicom3d/setOperateInfo', qsArr);
} }
}, },
setAnswerToQuestion(annotation, questionId) { setAnswerToQuestion(annotation, questionId) {
if (!questionId || !annotation) return if (!questionId || !annotation) return
const referencedImageId = annotation.metadata.referencedImageId let val = this.getAnnotationProp(annotation, this.imageToolAttribute)
if (annotation.metadata.toolName === 'Length') { this.$set(this.questionForm, questionId, val)
let length = annotation.data.cachedStats[`imageId:${referencedImageId}`].length },
length = length ? parseFloat(length).toFixed(this.digitPlaces) : length getAnnotationProp(annotation, prop) {
this.$set(this.questionForm, questionId, length) if (!annotation) return
} else if (annotation.metadata.toolName === 'Bidirectional') { const referencedImageId = annotation?.metadata?.referencedImageId
if (this.imageToolAttribute === 'length') { if (!referencedImageId) return null
let length = annotation.data.cachedStats[`imageId:${referencedImageId}`].length const cacheKey = `imageId:${referencedImageId}`
length = length ? parseFloat(length).toFixed(this.digitPlaces) : length const cachedStats = annotation.data?.cachedStats?.[cacheKey]
this.$set(this.questionForm, questionId, length) const hasProp = cachedStats
} else if (this.imageToolAttribute === 'width') { && Object.prototype.hasOwnProperty.call(cachedStats, prop)
let short = annotation.data.cachedStats[`imageId:${referencedImageId}`].width if (!hasProp) return null
short = short ? parseFloat(short).toFixed(this.digitPlaces) : short const value = cachedStats[prop]
this.$set(this.questionForm, questionId, short) return value !== null
} ? parseFloat(value).toFixed(this.digitPlaces)
} : value
}, },
unBindAnnotationToQuestion(obj) { unBindAnnotationToQuestion(obj) {
const { markTableQuestions = [], questionId } = obj || {} const { markTableQuestions = [], questionId } = obj || {}

View File

@ -400,7 +400,7 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler(v) { handler(v) {
// console.log(v, this.rowId) this.$forceUpdate()
} }
} }
}, },