147 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			147 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
<template>
 | 
						|
  <div v-loading="loading" class="ecrf-wrapper" style="min-height:200px">
 | 
						|
    <el-form
 | 
						|
      v-if="isRender"
 | 
						|
      ref="questions"
 | 
						|
      size="small"
 | 
						|
      :model="questionForm"
 | 
						|
    >
 | 
						|
      <FormItem
 | 
						|
        v-for="question of questions"
 | 
						|
        :key="question.Id"
 | 
						|
        :question="question"
 | 
						|
        :question-form="questionForm"
 | 
						|
        :reading-task-state="readingTaskState"
 | 
						|
        :visit-task-id="visitTaskId"
 | 
						|
        @setFormItemData="setFormItemData"
 | 
						|
        @resetFormItemData="resetFormItemData"
 | 
						|
      />
 | 
						|
 | 
						|
      <el-form-item v-if="readingTaskState < 2">
 | 
						|
        <div style="text-align:right">
 | 
						|
          <el-button size="mini" @click="handleSave">保存</el-button>
 | 
						|
        </div>
 | 
						|
 | 
						|
      </el-form-item>
 | 
						|
    </el-form>
 | 
						|
  </div>
 | 
						|
 | 
						|
</template>
 | 
						|
 | 
						|
<script>
 | 
						|
 | 
						|
import { getDicomReadingQuestionAnswer, changeDicomReadingQuestionAnswer } from '@/api/trials'
 | 
						|
import FormItem from './FormItem'
 | 
						|
import Store from './Store'
 | 
						|
export default {
 | 
						|
  name: 'ECRF',
 | 
						|
  components: {
 | 
						|
    FormItem
 | 
						|
  },
 | 
						|
  data() {
 | 
						|
    return {
 | 
						|
      loading: false,
 | 
						|
      questions: [],
 | 
						|
      questionForm: {},
 | 
						|
      isRender: false,
 | 
						|
      readingTaskState: 2,
 | 
						|
      visitTaskId: ''
 | 
						|
    }
 | 
						|
  },
 | 
						|
  mounted() {
 | 
						|
    // this.getQuestions()
 | 
						|
  },
 | 
						|
  methods: {
 | 
						|
    getQuestions(visitTaskId) {
 | 
						|
      this.visitTaskId = visitTaskId
 | 
						|
      this.loading = true
 | 
						|
      var param = {
 | 
						|
        trialId: this.$router.currentRoute.query.trialId,
 | 
						|
        visitTaskId: visitTaskId
 | 
						|
      }
 | 
						|
      getDicomReadingQuestionAnswer(param).then(res => {
 | 
						|
        this.readingTaskState = res.OtherInfo.ReadingTaskState
 | 
						|
 | 
						|
        res.Result.map((v) => {
 | 
						|
          if (v.Type === 'group' && v.Childrens.length === 0) return
 | 
						|
          if (!v.IsPage && v.Type !== 'group' && v.Type !== 'summary') {
 | 
						|
            this.$set(this.questionForm, v.Id, v.Answer ? v.Answer : null)
 | 
						|
          }
 | 
						|
          if (v.Childrens.length > 0) {
 | 
						|
            this.setChild(v.Childrens)
 | 
						|
          }
 | 
						|
        })
 | 
						|
        this.questions = res.Result
 | 
						|
 | 
						|
        this.isRender = true
 | 
						|
        this.loading = false
 | 
						|
      }).catch(() => { this.loading = false })
 | 
						|
    },
 | 
						|
    setChild(obj) {
 | 
						|
      obj.forEach(i => {
 | 
						|
        if (i.Type !== 'group' && i.Type !== 'summary' && i.Id) {
 | 
						|
          this.$set(this.questionForm, i.Id, i.Answer ? i.Answer : null)
 | 
						|
        }
 | 
						|
        if (i.Childrens && i.Childrens.length > 0) {
 | 
						|
          this.setChild(i.Childrens)
 | 
						|
        }
 | 
						|
      })
 | 
						|
    },
 | 
						|
    handleSave() {
 | 
						|
      this.$refs['questions'].validate((valid) => {
 | 
						|
        if (!valid) return
 | 
						|
        this.loading = true
 | 
						|
        var answers = []
 | 
						|
        for (const k in this.questionForm) {
 | 
						|
          answers.push({ id: k, answer: this.questionForm[k] })
 | 
						|
        }
 | 
						|
        var params = {
 | 
						|
          visitTaskId: this.visitTaskId,
 | 
						|
          answers: answers
 | 
						|
 | 
						|
        }
 | 
						|
        changeDicomReadingQuestionAnswer(params).then(res => {
 | 
						|
          this.$message.success(this.$t('common:message:savedSuccessfully'))
 | 
						|
          this.loading = false
 | 
						|
          Store.$emit('getReportInfo', true)
 | 
						|
        }).catch(() => {
 | 
						|
          this.loading = false
 | 
						|
        })
 | 
						|
      })
 | 
						|
    },
 | 
						|
    resetFormItemData(v) {
 | 
						|
      this.questionForm[v] = null
 | 
						|
    },
 | 
						|
    setFormItemData(obj) {
 | 
						|
      this.questionForm[obj.key] = obj.val
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
</script>
 | 
						|
<style lang="scss" scoped>
 | 
						|
  .ecrf-wrapper{
 | 
						|
    >>>.el-form-item__label{
 | 
						|
      color: #c3c3c3;
 | 
						|
    }
 | 
						|
    >>>.el-input__inner{
 | 
						|
      background-color: transparent;
 | 
						|
      color: #ddd;
 | 
						|
      border: 1px solid #5e5e5e;
 | 
						|
    }
 | 
						|
    >>>.el-form-item{
 | 
						|
      display: flex;
 | 
						|
      flex-direction: row;
 | 
						|
      justify-content: flex-start;
 | 
						|
    }
 | 
						|
    >>>.el-form-item__content{
 | 
						|
      flex: 1;
 | 
						|
    }
 | 
						|
    .el-form-item__content
 | 
						|
    .el-select{
 | 
						|
      width: 100%;
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  </style>
 | 
						|
 |