irc_web/.svn/pristine/82/829e688e14f58546b0870a2735a...

334 lines
9.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>
<el-dialog
v-if="signVisible"
:visible.sync="signVisible"
:close-on-click-modal="false"
width="600px"
append-to-body
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 { getTrialClinicalQuestionPreview, submitClinicalForm, SubmitClinicalFormAndSign } from '@/api/trials'
import { getClinicalFormInfo } from '@/api/dictionary'
import SignForm from '@/views/trials/components/newSignForm'
import QuestionFormItem from './QuestionFormItem'
import const_ from '@/const/sign-code'
export default {
name: 'QuestionsPreview',
components: {
QuestionFormItem,
SignForm
},
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 {
signVisible: false,
signCode: null,
loading: false,
questions: [],
questionForm: {},
publicQuestions: [],
isRender: false,
activeName: 0,
CalculationList: [],
currentUser: zzSessionStorage.getItem('userName'),
}
},
mounted() {
if (this.openType === 'add') {
this.getTrialClinicalQuestionPreview()
} else {
this.getClinicalFormInfo()
}
},
methods: {
closeSignDialog(isSign, signInfo) {
if (isSign) {
this.SubmitClinicalFormAndSign(signInfo)
} else {
this.signVisible = false
}
},
SubmitClinicalFormAndSign(signInfo) {
let params2 = {}
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.toString()
})
} else {
params.QuestionAnswers.push({
QuestionId: v,
Answer: item.toString()
})
}
})
if (signInfo) {
params2.signInfo = signInfo
}
params2.data = params
params2.signInfo.TrialId = this.trialId
this.loading = true
SubmitClinicalFormAndSign(params2).then(res => {
this.$message.success('提交成功')
this.close()
})
},
getClinicalFormInfo() {
getClinicalFormInfo({
ClinicalFormId: this.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
if ((this.data.UploadRole === 0 && [2, 3].includes(this.data.ClinicalDataLevel)) || !this.data.UploadRole || !this.data.ClinicalDataLevel) {
let params = {
QuestionAnswers: [],
TableQuestionAnswerList: [],
}
params.ClinicalFormId = this.clinicalFormId
params.ReadingId = this.visitId
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.toString()
})
}
})
submitClinicalForm(params).then(res => {
this.$message.success('保存成功')
this.close()
})
} else {
const { ClinicalDataConfirmation } = const_.processSignature
this.signCode = ClinicalDataConfirmation
this.signVisible = true
}
})
},
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.ClinicalQuestionType === 'checkbox') {
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 === 'checkbox') {
this.$set(this.questionForm, i.Id, i.Answer ? i.Answer.split(',') : [])
}
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>