421 lines
13 KiB
Plaintext
421 lines
13 KiB
Plaintext
<template>
|
||
<el-form
|
||
ref="clinicalDataForm"
|
||
v-loading="loading"
|
||
:model="form"
|
||
size="small"
|
||
:rules="rules"
|
||
:disabled="type === 'look'"
|
||
label-width="130px"
|
||
>
|
||
<div class="base-dialog-body">
|
||
<el-form-item label="类型" prop="ClinicalQuestionType">
|
||
<el-select v-model="form.ClinicalQuestionType" clearable @change="((val)=>{typeChange(val, form)})">
|
||
<el-option
|
||
v-for="item of $d.ClinicalQuestionType"
|
||
:key="item.value"
|
||
:value="item.value"
|
||
:label="item.label"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.ClinicalQuestionType === 'group'"
|
||
label="分组名称"
|
||
prop="GroupName"
|
||
>
|
||
<el-input v-model="form.GroupName" />
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.ClinicalQuestionType === 'group'"
|
||
label="分组名称(EN)"
|
||
prop="GroupEnName"
|
||
>
|
||
<el-input v-model="form.GroupEnName" />
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.ClinicalQuestionType !== 'group'"
|
||
label="问题名称"
|
||
prop="QuestionName"
|
||
>
|
||
<el-input v-model="form.QuestionName" />
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.ClinicalQuestionType !== 'group'"
|
||
label="问题名称(EN)"
|
||
prop="QuestionEnName"
|
||
>
|
||
<el-input v-model="form.QuestionEnName" />
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.Type === 'select' || form.Type === 'radio'"
|
||
label="选项"
|
||
prop="TypeValue"
|
||
>
|
||
<el-input
|
||
v-model="form.TypeValue"
|
||
placeholder="选项请用‘|’分割多个选项"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item v-if="form.ClinicalQuestionType !== 'group'" label="是否显示" prop="ShowQuestion">
|
||
<el-radio-group
|
||
v-model="form.ShowQuestion"
|
||
@change="((val)=>{isShowQuestionChange(val, form)})"
|
||
>
|
||
<el-radio
|
||
v-for="item of $d.ShowQuestion"
|
||
:key="`ShowQuestion${item.value}`"
|
||
:label="item.value"
|
||
>
|
||
{{ item.label }}
|
||
</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="form.ClinicalQuestionType !== 'group' && form.ShowQuestion===1"
|
||
label="显示依赖父问题"
|
||
prop="ParentId"
|
||
>
|
||
<el-select
|
||
v-model="form.ParentId"
|
||
clearable
|
||
@change="((val)=>{parentQuestionChange(val, form)})"
|
||
>
|
||
<el-option
|
||
v-for="item of parentOptions"
|
||
:key="`ParentId${item.QuestionId}`"
|
||
:label="item.QuestionName"
|
||
:value="item.QuestionId"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<!-- 显示时依赖父问题触发值 -->
|
||
<el-form-item v-if="form.ParentId && form.ShowQuestion===1" label="显示触发值" prop="ParentTriggerValue">
|
||
<el-select v-model="form.ParentTriggerValue" clearable>
|
||
<el-option
|
||
v-for="item of parentTriggerValOptions"
|
||
:key="item.id"
|
||
:label="item.label"
|
||
:value="item.value.toString()"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item v-if="form.ClinicalQuestionType !== 'group' && form.ClinicalQuestionType !== 'table'" label="是否必填" prop="IsRequired">
|
||
<el-radio-group
|
||
v-model="form.IsRequired"
|
||
>
|
||
<el-radio
|
||
v-for="item of $d.YesOrNo"
|
||
:key="`QuestionRequired${item.value}`"
|
||
:label="item.value"
|
||
>
|
||
{{ item.label }}
|
||
</el-radio>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item v-if="form.ClinicalQuestionType !== 'group'" label="问题分组">
|
||
<el-select v-model="form.GroupId" clearable :disabled="isParentExistGroup">
|
||
<el-option
|
||
v-for="group of groupOptions"
|
||
:key="group.GroupId"
|
||
:label="group.GroupName"
|
||
:value="group.GroupId"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item v-if="form.ClinicalQuestionType === 'upload'" label="最大上传个数">
|
||
<el-input-number v-model="form.ImageCount" controls-position="right" :min="1" :max="10" />
|
||
</el-form-item>
|
||
<el-form-item label="序号" prop="ShowOrder">
|
||
<el-input-number
|
||
v-model="form.ShowOrder"
|
||
controls-position="right"
|
||
:min="0"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
|
||
<el-form-item>
|
||
<!-- 取消 -->
|
||
<el-button
|
||
:disabled="btnLoading"
|
||
size="small"
|
||
type="primary"
|
||
@click="close"
|
||
>
|
||
{{ $t('common:button:cancel') }}
|
||
</el-button>
|
||
<!-- 保存 -->
|
||
<el-button size="small" type="primary" :loading="btnLoading" @click="save">
|
||
{{ $t('common:button:save') }}
|
||
</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</template>
|
||
<script>
|
||
import { addOrUpdateSystemClinicalQuestion, getSystemClinicalOtherQuestionList, getSystemClinicalGroupQuestionList } from '@/api/dictionary'
|
||
export default {
|
||
name: 'AddOrUpdateClinicalData',
|
||
props: {
|
||
clinicalId: {
|
||
type: String,
|
||
default() { return '' }
|
||
},
|
||
data: {
|
||
type: Object,
|
||
default() { return {} }
|
||
},
|
||
type: {
|
||
type: String,
|
||
default() { return '' }
|
||
}
|
||
},
|
||
data() {
|
||
var validateTypeVal = (rule, value, callback) => {
|
||
if (value === '') {
|
||
callback(new Error(this.$t('common:ruleMessage:specify')))
|
||
} else {
|
||
var arr = value.split('|')
|
||
if (new Set(arr).size !== arr.length) {
|
||
callback(new Error('选项不允许存在相同值'))
|
||
} else {
|
||
callback()
|
||
}
|
||
}
|
||
}
|
||
return {
|
||
validateTypeVal: validateTypeVal,
|
||
form: {
|
||
Id: '',
|
||
QuestionName: '',
|
||
QuestionEnName: '',
|
||
ClinicalQuestionType: null,
|
||
ValueType: '',
|
||
Unit: '',
|
||
QuestionGenre: '',
|
||
TypeValue: '',
|
||
DictionaryCode: '',
|
||
ParentId: '',
|
||
ParentTriggerValue: '',
|
||
ShowOrder: 0,
|
||
ShowQuestion: 0,
|
||
IsRequired: 2,
|
||
IsJudgeQuestion: false,
|
||
GroupName: '',
|
||
GroupEnName: '',
|
||
Remark: '',
|
||
ImageCount: 1,
|
||
RelevanceId: '',
|
||
RelevanceValue: '',
|
||
LesionType: '',
|
||
QuestionType: null,
|
||
IsShowInDicom: false,
|
||
OrderMark: '',
|
||
MaxQuestionCount: 0,
|
||
GlobalReadingShowType: 3,
|
||
DefaultValue: null,
|
||
LimitEdit: 0,
|
||
GroupId: null,
|
||
ConvertShowType: 0
|
||
},
|
||
rules: {
|
||
Type: [
|
||
{ required: true, message: '请选择', trigger: 'blur' }
|
||
],
|
||
LesionType: [
|
||
{ required: true, message: '请选择', trigger: 'blur' }
|
||
],
|
||
QuestionName: [{ required: true, message: '请注明', trigger: 'blur' },
|
||
{ max: 300, message: '最大长度为 300' }],
|
||
QuestionGenre: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
TypeValue: [{ required: true, message: '请注明', trigger: 'blur' },
|
||
{ validator: validateTypeVal, trigger: 'blur' },
|
||
{ max: 500, message: '最大长度为 500' }],
|
||
DictionaryCode: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
ShowQuestion: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
IsRequired: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
ParentId: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
ParentTriggerValue: [
|
||
{ required: true, message: '请选择', trigger: 'blur' }
|
||
],
|
||
RelevanceId: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
RelevanceValue: [{ required: true, message: '请选择', trigger: 'blur' }],
|
||
GroupName: [{ required: true, message: '请注明', trigger: 'blur' },
|
||
{ max: 50, message: '最大长度为 50' }]
|
||
},
|
||
loading: false,
|
||
btnLoading: false,
|
||
parentOptions: [],
|
||
parentTriggerValOptions: [],
|
||
groupOptions: [],
|
||
isParentExistGroup: false,
|
||
lesionTypes: [],
|
||
dicList: [],
|
||
CriterionDictionaryList: []
|
||
}
|
||
},
|
||
mounted() {
|
||
this.initForm()
|
||
},
|
||
methods: {
|
||
async initForm() {
|
||
await this.getGroupOptions()
|
||
await this.getParentQuestions()
|
||
await this.getBasicConfigSelect()
|
||
if (Object.keys(this.data).length > 0) {
|
||
for (const k in this.form) {
|
||
if (this.data.hasOwnProperty(k)) {
|
||
this.form[k] = this.data[k]
|
||
}
|
||
}
|
||
if (this.form.ParentId !== '' && this.form.ParentId !== null && this.form.GroupName !== '') {
|
||
this.isParentExistGroup = true
|
||
}
|
||
if (this.form.ParentId) {
|
||
var index = this.parentOptions.findIndex(item => {
|
||
return item.QuestionId === this.form.ParentId
|
||
})
|
||
if (index !== -1) {
|
||
if (this.parentOptions[index].QuestionGenre === 3) {
|
||
this.parentTriggerValOptions = this.$d[this.parentOptions[index].DictionaryCode]
|
||
} else {
|
||
const options = []
|
||
this.parentOptions[index].TypeValue.split('|').forEach((item, index) => {
|
||
options.push({ id: index, label: item, value: item })
|
||
})
|
||
this.parentTriggerValOptions = options
|
||
}
|
||
}
|
||
}
|
||
if (this.form.RelevanceId) {
|
||
var i = this.parentOptions.findIndex(item => {
|
||
return item.QuestionId === this.form.RelevanceId
|
||
})
|
||
if (i !== -1) {
|
||
if (this.parentOptions[index].QuestionGenre === 3) {
|
||
this.reParentTriggerValOptions = this.$d[this.parentOptions[index].DictionaryCode]
|
||
} else {
|
||
const options = []
|
||
this.parentOptions[index].TypeValue.split('|').forEach((item, index) => {
|
||
options.push({ id: index, label: item, value: item })
|
||
})
|
||
this.reParentTriggerValOptions = options
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
save() {
|
||
this.$refs.clinicalDataForm.validate(valid => {
|
||
if (!valid) return
|
||
this.btnLoading = true
|
||
if (this.form.ClinicalQuestionType !== 'upload') {
|
||
this.form.ImageCount = 0
|
||
}
|
||
addOrUpdateSystemClinicalQuestion(this.form).then(res => {
|
||
this.btnLoading = false
|
||
this.$emit('getList')
|
||
this.$emit('close')
|
||
this.$message.success(this.$t('common:message:savedSuccessfully'))
|
||
})
|
||
.catch(() => {
|
||
this.btnLoading = false
|
||
})
|
||
})
|
||
},
|
||
getBasicConfigSelect() {
|
||
this.dicList = this.$d
|
||
},
|
||
getGroupOptions() {
|
||
return new Promise((resolve, reject) => {
|
||
this.loading = true
|
||
var param = {
|
||
SystemClinicalId: this.clinicalId
|
||
}
|
||
getSystemClinicalGroupQuestionList(param).then(res => {
|
||
this.groupOptions = res.Result
|
||
this.loading = false
|
||
resolve()
|
||
}).catch(() => {
|
||
this.loading = false
|
||
reject()
|
||
})
|
||
})
|
||
},
|
||
getParentQuestions() {
|
||
return new Promise((resolve, reject) => {
|
||
this.loading = true
|
||
var param = {
|
||
SystemClinicalId: this.clinicalId
|
||
}
|
||
getSystemClinicalOtherQuestionList(param).then(res => {
|
||
this.parentOptions = res.Result
|
||
this.loading = false
|
||
resolve()
|
||
}).catch(() => {
|
||
this.loading = false
|
||
reject()
|
||
})
|
||
})
|
||
},
|
||
typeChange(val, data) {
|
||
if (val !== 'select' && val !== 'radio') {
|
||
}
|
||
if (val === 'table') {
|
||
data.IsRequired = 2
|
||
} else {
|
||
data.LesionType = null
|
||
}
|
||
data.TypeValue = ''
|
||
data.ValueType = ''
|
||
data.Unit = ''
|
||
},
|
||
isShowQuestionChange(val, form) {
|
||
if (val === 2) {
|
||
form.IsRequired = 2
|
||
form.ParentId = ''
|
||
form.ParentTriggerValue = ''
|
||
} else {
|
||
form.ParentId = ''
|
||
form.ParentTriggerValue = ''
|
||
}
|
||
},
|
||
parentQuestionChange(val, form) {
|
||
this.isParentExistGroup = false
|
||
if (val) {
|
||
var index = this.parentOptions.findIndex(item => {
|
||
return item.QuestionId === val
|
||
})
|
||
if (index !== -1) {
|
||
if (this.parentOptions[index].QuestionGenre === 3) {
|
||
this.parentTriggerValOptions = this.$d[this.parentOptions[index].DictionaryCode]
|
||
} else {
|
||
var options = []
|
||
this.parentOptions[index].TypeValue.split('|').forEach((item, index) => {
|
||
options.push({ id: index, label: item, value: item })
|
||
})
|
||
this.parentTriggerValOptions = options
|
||
}
|
||
if (this.parentOptions[index].GroupName) {
|
||
this.isParentExistGroup = true
|
||
form.GroupName = this.parentOptions[index].GroupName
|
||
}
|
||
}
|
||
} else {
|
||
form.GroupName = ''
|
||
form.GroupEnName = ''
|
||
}
|
||
form.ParentTriggerValue = ''
|
||
},
|
||
close() {
|
||
this.$emit('close')
|
||
}
|
||
|
||
}
|
||
}
|
||
</script>
|
||
<style lang="scss" scoped>
|
||
</style>
|