84 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
<template>
 | 
						|
  <div v-loading="loading" style="min-height:400px;">
 | 
						|
    <el-form
 | 
						|
      v-if="isRender"
 | 
						|
      ref="questions"
 | 
						|
      size="small"
 | 
						|
      :model="questionForm"
 | 
						|
    >
 | 
						|
      <FormItem
 | 
						|
        v-for="question of questions"
 | 
						|
        :key="question.ReadingQuestionTrialId"
 | 
						|
        :question="question"
 | 
						|
        :question-form="questionForm"
 | 
						|
        :reading-task-state="readingTaskState"
 | 
						|
        @resetFormItemData="resetFormItemData"
 | 
						|
      />
 | 
						|
    </el-form>
 | 
						|
  </div>
 | 
						|
 | 
						|
</template>
 | 
						|
<script>
 | 
						|
import { getTrialReadingQuestion } from '@/api/trials'
 | 
						|
import FormItem from '@/views/trials/trials-panel/reading/none-dicoms/components/FormItem.vue'
 | 
						|
export default {
 | 
						|
  name: 'QuestionTpl',
 | 
						|
  components: {
 | 
						|
    FormItem
 | 
						|
  },
 | 
						|
  props: {
 | 
						|
    criterionId: {
 | 
						|
      type: String,
 | 
						|
      required: true
 | 
						|
    }
 | 
						|
 | 
						|
  },
 | 
						|
  data() {
 | 
						|
    return {
 | 
						|
      loading: false,
 | 
						|
      questionForm: {},
 | 
						|
      isRender: false,
 | 
						|
      readingTaskState: 0
 | 
						|
    }
 | 
						|
  },
 | 
						|
  mounted() {
 | 
						|
    this.getQuestions()
 | 
						|
  },
 | 
						|
  methods: {
 | 
						|
 | 
						|
    getQuestions() {
 | 
						|
      this.loading = true
 | 
						|
      var param = {
 | 
						|
        readingQuestionCriterionTrialId: this.criterionId
 | 
						|
      }
 | 
						|
      getTrialReadingQuestion(param).then(res => {
 | 
						|
        this.questions = res.Result
 | 
						|
 | 
						|
        this.questions.map(q => {
 | 
						|
          if (q.Type !== 'group' && q.Type !== 'summary') {
 | 
						|
            this.$set(this.questionForm, q.ReadingQuestionTrialId, q.Answer)
 | 
						|
            if (q.Childrens.length > 0) {
 | 
						|
              this.setChild(q.Childrens)
 | 
						|
            }
 | 
						|
          }
 | 
						|
        })
 | 
						|
        console.log(this.questionForm)
 | 
						|
        this.isRender = true
 | 
						|
        this.loading = false
 | 
						|
      }).catch(() => { this.loading = false })
 | 
						|
    },
 | 
						|
    setChild(obj) {
 | 
						|
      obj.forEach(i => {
 | 
						|
        this.$set(this.questionForm, i.ReadingQuestionTrialId, i.Answer)
 | 
						|
        if (i.Childrens && i.Childrens.length > 0) {
 | 
						|
          this.setChild(i.Childrens)
 | 
						|
        }
 | 
						|
      })
 | 
						|
    },
 | 
						|
    resetFormItemData(v) {
 | 
						|
      this.questionForm[v] = ''
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
</script>
 |