78 lines
1.8 KiB
Plaintext
78 lines
1.8 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.Id"
|
|
:question="question"
|
|
:question-form="questionForm"
|
|
:reading-task-state="readingTaskState"
|
|
@resetFormItemData="resetFormItemData"
|
|
/>
|
|
</el-form>
|
|
</div>
|
|
|
|
</template>
|
|
<script>
|
|
import { getMedicineQuestionPreview } from '@/api/trials'
|
|
import FormItem from './FormItem'
|
|
export default {
|
|
name: 'QuestionTpl',
|
|
components: {
|
|
FormItem
|
|
},
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
questionForm: {},
|
|
isRender: false,
|
|
trialId: '',
|
|
readingTaskState: 0
|
|
}
|
|
},
|
|
mounted() {
|
|
this.trialId = this.$route.query.trialId
|
|
this.getQuestions()
|
|
},
|
|
methods: {
|
|
|
|
getQuestions() {
|
|
this.loading = true
|
|
var param = {
|
|
trialId: this.trialId
|
|
}
|
|
getMedicineQuestionPreview(param).then(res => {
|
|
this.questions = res.Result
|
|
|
|
this.questions.map(q => {
|
|
if (q.Type !== 'group' && q.Type !== 'summary') {
|
|
this.$set(this.questionForm, q.Id, q.Answer ? q.Answer : '')
|
|
if (q.Childrens.length > 0) {
|
|
this.setChild(q.Childrens)
|
|
}
|
|
}
|
|
})
|
|
this.isRender = true
|
|
this.loading = false
|
|
}).catch(() => { this.loading = false })
|
|
},
|
|
setChild(obj) {
|
|
obj.forEach(i => {
|
|
this.$set(this.questionForm, i.Id, i.Answer)
|
|
if (i.Childrens && i.Childrens.length > 0) {
|
|
this.setChild(i.Childrens)
|
|
}
|
|
})
|
|
},
|
|
resetFormItemData(v) {
|
|
this.questionForm[v] = null
|
|
}
|
|
}
|
|
}
|
|
</script>
|