249 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			249 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
| <template>
 | |
|   <div v-loading="loading" style="min-height: 500px;">
 | |
|     <el-form
 | |
|       v-if="isRender"
 | |
|       ref="questions"
 | |
|       size="small"
 | |
|       :model="questionForm"
 | |
|       :disabled="openType === 'look'"
 | |
|     >
 | |
|       <template>
 | |
|         <QuestionFormItem
 | |
|           class="father"
 | |
|           v-for="question of questions"
 | |
|           :key="question.Id"
 | |
|           :question="question"
 | |
|           :question-form="questionForm"
 | |
|           :trial-clinical-id="trialClinicalId"
 | |
|           @resetFormItemData="resetFormItemData"
 | |
|           @setFormItemData="setFormItemData"
 | |
|         />
 | |
|       </template>
 | |
|     </el-form>
 | |
|     <div class="base-dialog-footer" v-if="!isViewer && openType !== 'look'" style="text-align:right;margin-top:10px;">
 | |
|         <!-- 取消 -->
 | |
|         <el-button
 | |
|           size="small"
 | |
|           type="primary"
 | |
|           @click="close"
 | |
|         >
 | |
|           {{ $t('common:button:cancel') }}
 | |
|         </el-button>
 | |
|         <!-- 保存 -->
 | |
|         <el-button size="small" type="primary" @click="submitClinicalForm">
 | |
|           {{ $t('common:button:save') }}
 | |
|         </el-button>
 | |
|     </div>
 | |
|   </div>
 | |
| 
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| 
 | |
| import { getTrialClinicalQuestionPreview, submitClinicalForm } from '@/api/trials'
 | |
| import { getClinicalFormInfo } from '@/api/dictionary'
 | |
| import QuestionFormItem from './QuestionFormItem'
 | |
| export default {
 | |
|   name: 'QuestionsPreview',
 | |
|   components: {
 | |
|     QuestionFormItem
 | |
|   },
 | |
|   props: {
 | |
|     openType: {
 | |
|       type: String,
 | |
|     },
 | |
|     isViewer: {
 | |
|       type: Boolean,
 | |
|       default: () => true
 | |
|     },
 | |
|     visitId: {
 | |
|       type: String,
 | |
|       default: () => ''
 | |
|     },
 | |
|     subjectId: {
 | |
|       type: String,
 | |
|       default: () => ''
 | |
|     },
 | |
|     trialId: {
 | |
|       type: String,
 | |
|       default: () => ''
 | |
|     },
 | |
|     readingId: {
 | |
|       type: String,
 | |
|       default: () => ''
 | |
|     },
 | |
|     clinicalFormId: {
 | |
|       type: String,
 | |
|       default: () => ''
 | |
|     },
 | |
|     data: {
 | |
|       type: Object,
 | |
|       default: () => {}
 | |
|     },
 | |
|     trialClinicalId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     },
 | |
|   },
 | |
|   data() {
 | |
|     return {
 | |
|       loading: false,
 | |
|       questions: [],
 | |
|       questionForm: {},
 | |
|       publicQuestions: [],
 | |
|       isRender: false,
 | |
|       activeName: 0,
 | |
|       CalculationList: []
 | |
|     }
 | |
|   },
 | |
|   mounted() {
 | |
|     if (this.openType === 'add') {
 | |
|       this.getTrialClinicalQuestionPreview()
 | |
|     } else {
 | |
|       this.getClinicalFormInfo()
 | |
|     }
 | |
|   },
 | |
|   methods: {
 | |
|     getClinicalFormInfo() {
 | |
|       getClinicalFormInfo({
 | |
|         ClinicalFormId: this.data.ClinicalFormId
 | |
|       }).then(res => {
 | |
|         res.Result.map((v) => {
 | |
|           if (v.ClinicalQuestionType === 'group' && v.Childrens.length === 0) return
 | |
|           if (v.ClinicalQuestionType !== 'group' && v.ClinicalQuestionType !== 'table') {
 | |
|             this.$set(this.questionForm, v.Id, v.Answer)
 | |
|           }
 | |
|           if (v.ClinicalQuestionType === 'table') {
 | |
|             this.$set(this.questionForm, v.Id, v.TableAnswer)
 | |
|           }
 | |
|           if (v.Childrens.length > 0) {
 | |
|             this.setChild(v.Childrens)
 | |
|           }
 | |
|         })
 | |
|         console.log(this.questionForm)
 | |
|         this.questions = res.Result
 | |
|         this.isRender = true
 | |
|         this.loading = false
 | |
|       })
 | |
|     },
 | |
|     submitClinicalForm() {
 | |
|       this.$refs.questions.validate(valid => {
 | |
|         if (!valid) return
 | |
|         let params = {
 | |
|           QuestionAnswers: [],
 | |
|           TableQuestionAnswerList: [],
 | |
|         }
 | |
|         params.ClinicalFormId = this.clinicalFormId
 | |
|         params.VisitId = this.visitId
 | |
|         params.ReadingId = this.readingId
 | |
|         params.TrialId = this.trialId
 | |
|         params.SubjectId = this.subjectId
 | |
|         params.ClinicalDataTrialSetId = this.trialClinicalId
 | |
|         Object.keys(this.questionForm).forEach(v => {
 | |
|           let item = this.questionForm[v]
 | |
|           if (item instanceof Array) {
 | |
|             let TableQuestionAnswers = item.map(o => {
 | |
|               return Object.keys(o).map(x => {
 | |
|                 return {
 | |
|                   TableQuestionId: x,
 | |
|                   Answer: o[x]
 | |
|                 }
 | |
|               })
 | |
|             })
 | |
|             params.TableQuestionAnswerList.push({
 | |
|               QuestionId: v,
 | |
|               TableQuestionAnswers: TableQuestionAnswers
 | |
|             })
 | |
|           } else {
 | |
|             params.QuestionAnswers.push({
 | |
|               QuestionId: v,
 | |
|               Answer: item
 | |
|             })
 | |
|           }
 | |
|         })
 | |
|         submitClinicalForm(params).then(res => {
 | |
|           this.$message.success('保存成功')
 | |
|           this.close()
 | |
|         })
 | |
|       })
 | |
|     },
 | |
|     close() {
 | |
|       this.$emit('close')
 | |
|     },
 | |
|     getTrialClinicalQuestionPreview() {
 | |
|       this.loading = true
 | |
|       getTrialClinicalQuestionPreview({
 | |
|         TrialClinicalId: this.trialClinicalId
 | |
|       }).then(res => {
 | |
|         res.Result.map((v) => {
 | |
|           if (v.ClinicalQuestionType === 'group' && v.Childrens.length === 0) return
 | |
|           if (v.ClinicalQuestionType !== 'group' && v.ClinicalQuestionType !== 'table') {
 | |
|             this.$set(this.questionForm, v.Id, v.Answer)
 | |
|           }
 | |
|           if (v.ClinicalQuestionType === 'table') {
 | |
|             this.$set(this.questionForm, v.Id, [])
 | |
|           }
 | |
|           if (v.Childrens.length > 0) {
 | |
|             this.setChild(v.Childrens)
 | |
|           }
 | |
|         })
 | |
|         console.log(this.questionForm)
 | |
|         this.questions = res.Result
 | |
|         this.isRender = true
 | |
|         this.loading = false
 | |
|       })
 | |
|     },
 | |
|     setChild(obj) {
 | |
|       obj.forEach(i => {
 | |
|         if (i.ClinicalQuestionType !== 'group' && i.ClinicalQuestionType !== 'table') {
 | |
|           this.$set(this.questionForm, i.Id, i.Answer)
 | |
|         }
 | |
|         if (i.ClinicalQuestionType === 'table') {
 | |
|           this.$set(this.questionForm, i.Id, i.TableAnswer)
 | |
|         }
 | |
|         if (i.ClinicalQuestionType === 'number') {
 | |
|           this.$set(this.questionForm, i.Id, i.Answer)
 | |
|         }
 | |
|         if (i.Childrens && i.Childrens.length > 0) {
 | |
|           this.setChild(i.Childrens)
 | |
|         }
 | |
|       })
 | |
|     },
 | |
|     resetFormItemData(v, qs) {
 | |
|       if (qs.ClinicalQuestionType === 'table') {
 | |
|         this.questionForm[v] = []
 | |
|       } else if (qs.ClinicalQuestionType === 'number') {
 | |
|         this.questionForm[v] = 0
 | |
|       } else {
 | |
|         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;
 | |
| 
 | |
| }
 | |
| .father:after{
 | |
|   content: "";
 | |
|   display: block;
 | |
|   height: 0;
 | |
|   clear:both;
 | |
|   visibility: hidden;
 | |
| }
 | |
| </style>
 |