212 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			212 lines
		
	
	
		
			6.2 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-item v-if="readingTaskState < 2">
 | |
|         <div style="text-align:center;">
 | |
|           <!-- <el-button>取消</el-button> -->
 | |
|           <el-button type="primary" @click="handleSave">保存</el-button>
 | |
|           <el-button type="primary" @click="handleSubmit">提交</el-button>
 | |
|         </div>
 | |
| 
 | |
|       </el-form-item>
 | |
|     </el-form>
 | |
| 
 | |
|     <!-- 签名框 -->
 | |
|     <el-dialog
 | |
|       v-if="signVisible"
 | |
|       :visible.sync="signVisible"
 | |
|       :close-on-click-modal="false"
 | |
|       width="600px"
 | |
|       custom-class="base-dialog-wrapper"
 | |
|     >
 | |
|       <div slot="title">
 | |
|         <span style="font-size:18px;">{{ $t('common:dialogTitle:sign') }}</span>
 | |
|         <span style="font-size:12px;margin-left:5px">{{ `(${$t('common:label:sign')}${ currentUser })` }}</span>
 | |
|       </div>
 | |
|       <SignForm ref="signForm" :sign-code-enum="signCode" @closeDialog="closeSignDialog" />
 | |
|     </el-dialog>
 | |
|   </div>
 | |
| 
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| 
 | |
| import { getTrialReadingQuestion, saveVisitTaskQuestions, submitVisitTaskQuestionsInDto } from '@/api/trials'
 | |
| import const_ from '@/const/sign-code'
 | |
| import FormItem from './FormItem'
 | |
| import SignForm from '@/views/trials/components/newSignForm'
 | |
| export default {
 | |
|   name: 'ECRF',
 | |
|   components: {
 | |
|     FormItem,
 | |
|     SignForm
 | |
|   },
 | |
|   props: {
 | |
|     trialId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     },
 | |
|     subjectId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     },
 | |
|     criterionId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     },
 | |
|     visitTaskId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     }
 | |
|   },
 | |
|   data() {
 | |
|     return {
 | |
|       loading: false,
 | |
|       questions: [],
 | |
|       questionForm: {},
 | |
|       isRender: false,
 | |
|       signVisible: false,
 | |
|       signCode: null,
 | |
|       currentUser: zzSessionStorage.getItem('userName'),
 | |
|       readingTaskState: 0
 | |
|     }
 | |
|   },
 | |
|   mounted() {
 | |
|     this.getQuestions()
 | |
|   },
 | |
|   methods: {
 | |
|     getQuestions() {
 | |
|       this.loading = true
 | |
|       var param = {
 | |
|         readingQuestionCriterionTrialId: this.criterionId,
 | |
|         visitTaskId: this.visitTaskId
 | |
|       }
 | |
|       getTrialReadingQuestion(param).then(res => {
 | |
|         this.readingTaskState = res.OtherInfo.readingTaskState
 | |
|         var questions = []
 | |
|         res.Result.map((v) => {
 | |
|           console.log(v)
 | |
|           if (v.Type === 'group' && v.Childrens.length === 0) return
 | |
|           questions.push(v)
 | |
|           if (v.Type !== 'group' && v.Type !== 'summary') {
 | |
|             this.$set(this.questionForm, v.ReadingQuestionTrialId, v.Answer)
 | |
|           }
 | |
|           if (v.Childrens.length > 0) {
 | |
|             this.setChild(v.Childrens)
 | |
|           }
 | |
|         })
 | |
|         this.questions = questions
 | |
| 
 | |
|         // 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)
 | |
|         //     }
 | |
|         //   }
 | |
|         // })
 | |
|         this.isRender = true
 | |
|         this.loading = false
 | |
|       }).catch(() => { this.loading = false })
 | |
|     },
 | |
|     setChild(obj) {
 | |
|       obj.forEach(i => {
 | |
|         if (i.Type !== 'group' && i.Type !== 'summary') {
 | |
|           this.$set(this.questionForm, i.ReadingQuestionTrialId, i.Answer)
 | |
|         }
 | |
|         // this.$set(this.questionForm, i.ReadingQuestionTrialId, i.Answer)
 | |
|         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({ readingQuestionTrialId: k, answer: this.questionForm[k] })
 | |
|         }
 | |
|         var params = {
 | |
|           trialId: this.trialId,
 | |
|           visitTaskId: this.visitTaskId,
 | |
|           readingQuestionCriterionTrialId: this.criterionId,
 | |
|           answerList: answers
 | |
| 
 | |
|         }
 | |
|         saveVisitTaskQuestions(params).then(res => {
 | |
|           this.$message.success(this.$t('common:message:savedSuccessfully'))
 | |
|           this.loading = false
 | |
|         }).catch(() => {
 | |
|           this.loading = false
 | |
|         })
 | |
|       })
 | |
|     },
 | |
|     handleSubmit() {
 | |
|       this.$refs['questions'].validate((valid) => {
 | |
|         if (!valid) return
 | |
|         const { ImageAssessmentReportConfirmation } = const_.processSignature
 | |
|         this.signCode = ImageAssessmentReportConfirmation
 | |
|         this.signVisible = true
 | |
|       })
 | |
|     },
 | |
|     // 关闭签名框
 | |
|     closeSignDialog(isSign, signInfo) {
 | |
|       if (isSign) {
 | |
|         this.signConfirm(signInfo)
 | |
|       } else {
 | |
|         this.signVisible = false
 | |
|       }
 | |
|     },
 | |
|     // 签名并确认
 | |
|     signConfirm(signInfo) {
 | |
|       this.loading = true
 | |
|       var answers = []
 | |
|       for (const k in this.questionForm) {
 | |
|         answers.push({ readingQuestionTrialId: k, answer: this.questionForm[k] })
 | |
|       }
 | |
|       var params = {
 | |
|         data: {
 | |
|           trialId: this.trialId,
 | |
|           visitTaskId: this.visitTaskId,
 | |
|           readingQuestionCriterionTrialId: this.criterionId,
 | |
|           answerList: answers
 | |
|         },
 | |
|         signInfo: signInfo
 | |
|       }
 | |
|       submitVisitTaskQuestionsInDto(params).then(res => {
 | |
|         this.loading = false
 | |
|         if (res.IsSuccess) {
 | |
|           this.$message.success(this.$t('common:message:savedSuccessfully'))
 | |
|           this.isEdit = false
 | |
|           this.$refs['signForm'].btnLoading = false
 | |
|           this.signVisible = false
 | |
|           window.location.reload()
 | |
|           window.opener.postMessage('noneDicoms', window.location)
 | |
|         }
 | |
|       }).catch(_ => {
 | |
|         this.loading = false
 | |
|         this.$refs['signForm'].btnLoading = false
 | |
|       })
 | |
|     },
 | |
|     resetFormItemData(v) {
 | |
|       this.questionForm[v] = ''
 | |
|     }
 | |
|   }
 | |
| }
 | |
| </script>
 |