233 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			233 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
| <template>
 | |
|   <div v-loading="loading" style="min-height: 500px;">
 | |
|     <el-form
 | |
|       v-if="isRender"
 | |
|       ref="questions"
 | |
|       size="small"
 | |
|       :model="questionForm"
 | |
|     >
 | |
|       <template>
 | |
|         <QuestionFormItem
 | |
|           v-for="question of questions"
 | |
|           :key="question.Id"
 | |
|           :visitTaskId="visitTaskId"
 | |
|           :question="question"
 | |
|           :question-form="questionForm"
 | |
|           :reading-task-state="readingTaskState"
 | |
|           :criterion-id="criterionId"
 | |
|           :CalculationList="CalculationList"
 | |
|           :IsBaseline="IsBaseline"
 | |
|           @resetFormItemData="resetFormItemData"
 | |
|           @setFormItemData="setFormItemData"
 | |
|         />
 | |
|       </template>
 | |
|     </el-form>
 | |
|   </div>
 | |
| 
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| 
 | |
| import { getTrialReadingQuestion, getCustomQuestionPreview, changeDicomReadingQuestionAnswer, getCustomTableQuestionAnswer, getQuestionCalculateRelation } from '@/api/trials'
 | |
| import QuestionFormItem from './CustomizeQuestionFormItem'
 | |
| import DicomEvent from "../components/DicomEvent";
 | |
| export default {
 | |
|   name: 'QuestionsPreview',
 | |
|   components: {
 | |
|     QuestionFormItem
 | |
|   },
 | |
|   props: {
 | |
|     criterionId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     },
 | |
|     visitTaskId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     }
 | |
|   },
 | |
|   data() {
 | |
|     return {
 | |
|       loading: false,
 | |
|       questions: [],
 | |
|       questionForm: {},
 | |
|       publicQuestions: [],
 | |
|       isRender: false,
 | |
|       readingTaskState: 0,
 | |
|       activeName: 0,
 | |
|       CalculationList: [],
 | |
|       IsBaseline: true
 | |
|     }
 | |
|   },
 | |
|   mounted() {
 | |
|     this.getQuestionCalculateRelation()
 | |
|     this.getCustomTableQuestionAnswer()
 | |
|     DicomEvent.$on('reGetQuestionAnswer', () => {
 | |
|       this.getCustomTableQuestionAnswer()
 | |
|     })
 | |
|   },
 | |
|   beforeDestroy() {
 | |
|     DicomEvent.$off('getCustomTableQuestionAnswer')
 | |
|   },
 | |
|   methods: {
 | |
|     handleSave(isMsg) {
 | |
|       return new Promise(resolve => {
 | |
|         this.$refs['questions'].validate((valid) => {
 | |
|           if (!valid) {
 | |
|             resolve(false)
 | |
|             return
 | |
|           }
 | |
|           this.loading = true
 | |
|           var answers = []
 | |
|           for (const k in this.questionForm) {
 | |
|             if (this.questionForm[k] instanceof Array) {} else {
 | |
|               answers.push({ id: k, answer: this.questionForm[k].toString() })
 | |
|             }
 | |
|           }
 | |
|           var params = {
 | |
|             visitTaskId: this.visitTaskId,
 | |
|             answers: answers
 | |
|           }
 | |
|           changeDicomReadingQuestionAnswer(params).then(res => {
 | |
|             if (isMsg) {
 | |
|               this.$message.success(this.$t('common:message:savedSuccessfully'))
 | |
|             }
 | |
|             this.loading = false
 | |
|             resolve(true)
 | |
|           }).catch(() => {
 | |
|             this.loading = false
 | |
|             resolve(false)
 | |
|           })
 | |
|         })
 | |
|       })
 | |
|     },
 | |
|     getQuestionCalculateRelation() {
 | |
|       getQuestionCalculateRelation({
 | |
|         TrialReadingCriterionId: this.criterionId
 | |
|       }).then(res => {
 | |
|         this.CalculationList = res.Result
 | |
|       })
 | |
|     },
 | |
|     getCustomTableQuestionAnswer(visitTaskId) {
 | |
|       console.log('getCustomTableQuestionAnswer')
 | |
|       this.isRender = false
 | |
|       this.loading = true
 | |
|       getCustomTableQuestionAnswer({
 | |
|         VisitTaskId: visitTaskId ? visitTaskId : this.visitTaskId
 | |
|       }).then(res => {
 | |
|         this.IsBaseline = res.OtherInfo.IsBaseline
 | |
|         this.readingTaskState = res.OtherInfo.readingTaskState
 | |
|         DicomEvent.$emit('setReadingState', res.OtherInfo.readingTaskState)
 | |
|         res.Result.SinglePage.map((v) => {
 | |
|           if (v.Type === 'group' && v.Childrens.length === 0) return
 | |
|           if (!v.IsPage && v.Type !== 'group' && v.Type !== 'summary' && v.Type !== 'table') {
 | |
|             this.$set(this.questionForm, v.Id, v.Answer)
 | |
|           }
 | |
|           if (v.Type === 'table') {
 | |
|             this.$set(this.questionForm, v.Id, v.TableQuestions.Answers)
 | |
|           }
 | |
|           if (v.Childrens.length > 0) {
 | |
|             this.setChild(v.Childrens)
 | |
|           }
 | |
|         })
 | |
|         this.questions = res.Result.SinglePage
 | |
|         this.isRender = true
 | |
|         this.loading = false
 | |
|       })
 | |
|     },
 | |
|     getQuestions() {
 | |
|       this.loading = true
 | |
|       var param = {
 | |
|         readingQuestionCriterionTrialId: this.criterionId,
 | |
|         FormType: 1
 | |
|       }
 | |
|       getTrialReadingQuestion(param).then(res => {
 | |
|         if (res.OtherInfo.FormType === 2) {
 | |
|           if (res.Result.MultiPage.length > 0) {
 | |
|             res.Result.MultiPage.map((v) => {
 | |
|               if (v.Type === 'group' && v.Childrens.length === 0 && i.Type !== 'table') return
 | |
|               if (!v.IsPage && v.Type !== 'group' && v.Type !== 'summary' && i.Type !== 'table') {
 | |
|                 this.$set(this.questionForm, v.Id, '')
 | |
|               }
 | |
|               if (v.Childrens.length > 0) {
 | |
|                 this.setChild(v.Childrens)
 | |
|               }
 | |
|             })
 | |
|             this.questions = res.Result.MultiPage
 | |
|             this.activeName = res.Result.MultiPage[0].PageName
 | |
|           }
 | |
|           if (res.Result.PublicPage.length > 0) {
 | |
|             res.Result.PublicPage.map((v) => {
 | |
|               if (v.Type === 'group' && v.Childrens.length === 0 && i.Type !== 'table') return
 | |
|               if (!v.IsPage && v.Type !== 'group' && v.Type !== 'summary' && i.Type !== 'table') {
 | |
|                 this.$set(this.questionForm, v.Id, '')
 | |
|               }
 | |
|               if (v.Childrens.length > 0) {
 | |
|                 this.setChild(v.Childrens)
 | |
|               }
 | |
|             })
 | |
|             this.publicQuestions = res.Result.PublicPage
 | |
|           }
 | |
|         } else {
 | |
|           res.Result.SinglePage.map((v) => {
 | |
|             if (v.Type === 'group' && v.Childrens.length === 0 && v.Type !== 'table') return
 | |
|             if (!v.IsPage && v.Type !== 'group' && v.Type !== 'summary' && v.Type !== 'table' && v.Type !== 'number') {
 | |
|               this.$set(this.questionForm, v.Id, v.Answer)
 | |
|             }
 | |
|             if (v.Type === 'table') {
 | |
|               this.$set(this.questionForm, v.Id, v.TableQuestions.Answers)
 | |
|             }
 | |
|             if (v.Type === 'number') {
 | |
|               this.$set(this.questionForm, v.Id, v.Answer === '' ? '' : v.Answer)
 | |
|             }
 | |
|             if (v.Childrens.length > 0) {
 | |
|               this.setChild(v.Childrens)
 | |
|             }
 | |
|           })
 | |
|           this.questions = res.Result.SinglePage
 | |
|         }
 | |
|         this.isRender = true
 | |
|         this.loading = false
 | |
|       }).catch(() => { this.loading = false })
 | |
|     },
 | |
|     setChild(obj) {
 | |
|       obj.forEach(i => {
 | |
|         if (i.Type !== 'group' && i.Type !== 'summary' && i.Id && i.Type !== 'table') {
 | |
|           this.$set(this.questionForm, i.Id, i.Answer)
 | |
|         }
 | |
|         if (i.Type === 'table') {
 | |
|           this.$set(this.questionForm, i.Id, i.TableQuestions.Answers)
 | |
|         }
 | |
|         if (i.Type === 'number') {
 | |
|           this.$set(this.questionForm, i.Id, i.Answer === '' ? '' : i.Answer)
 | |
|         }
 | |
|         if (i.Childrens && i.Childrens.length > 0) {
 | |
|           this.setChild(i.Childrens)
 | |
|         }
 | |
|       })
 | |
|     },
 | |
|     resetFormItemData(v) {
 | |
|       this.questionForm[v] = ''
 | |
|     },
 | |
|     setFormItemData(obj) {
 | |
|       this.$set(this.questionForm, obj.key, JSON.parse(JSON.stringify(obj.val)))
 | |
|     }
 | |
|   }
 | |
| }
 | |
| </script>
 | |
| <style lang="scss" scoped>
 | |
| ::-webkit-scrollbar {
 | |
|     width: 7px;
 | |
|     height: 7px;
 | |
|   }
 | |
|   ::-webkit-scrollbar-thumb {
 | |
|     border-radius: 10px;
 | |
|     background: #d0d0d0;
 | |
|   }
 | |
| .tabContent{
 | |
|   height:300px;
 | |
|   overflow-y: auto;
 | |
| 
 | |
| }
 | |
| </style>
 |