Compare commits

..

No commits in common. "0d85f138a54199198d1e6cd6da0e7f07f04b4a71" and "f848e9a9dd46b1f48f5d04f70034135cce85f6be" have entirely different histories.

4 changed files with 292 additions and 540 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 }, arr) { setOperateInfo({ state }, obj) {
state.operateInfo = arr state.operateInfo = Object.assign({}, obj)
}, },
setDeleteAnnotationIds({ state }, arr) { setDeleteAnnotationIds({ state }, arr) {
state.deleteAnnotationIds = arr state.deleteAnnotationIds = Object.assign({}, obj)
}, },
} }

View File

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