660 lines
20 KiB
Plaintext
660 lines
20 KiB
Plaintext
<template>
|
|
<el-form
|
|
ref="tableQsForm"
|
|
v-loading="loading"
|
|
:model="form"
|
|
size="small"
|
|
:rules="rules"
|
|
label-width="120px"
|
|
>
|
|
<div class="base-dialog-body">
|
|
<el-form-item label="类型" prop="Type">
|
|
<el-select
|
|
v-model="form.Type"
|
|
@change="((val)=>{qsTypeChange(val, form)})"
|
|
>
|
|
<el-option
|
|
v-for="item of $d.Criterion_Question_Type"
|
|
:key="item.value"
|
|
:value="item.value"
|
|
:label="item.label"
|
|
:disabled="item.label === 'group' || item.label === 'table' || item.label === 'summary' || item.label === 'upload'"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item
|
|
v-if="form.Type !== 'group'"
|
|
label="问题名称"
|
|
prop="QuestionName"
|
|
>
|
|
<el-input
|
|
v-model="form.QuestionName"
|
|
/>
|
|
</el-form-item>
|
|
<div v-if="form.Type === 'number'" style="background: #f8f8f8;padding: 10px 0px;border-radius: 10px;position: relative">
|
|
<el-button @click="addCustomCalculateMark" :disabled="form.CustomCalculateMark > 4" size="mini" type="primary" style="position: absolute;top: 80px;right: 10px;">
|
|
新增
|
|
</el-button>
|
|
<el-form-item
|
|
label="运算类型"
|
|
prop="CustomCalculateMark"
|
|
>
|
|
<el-radio-group
|
|
v-model="form.CustomCalculateMark"
|
|
@change="(v) => CustomCalculateMarkChange(v)"
|
|
style="line-height: 40px;"
|
|
>
|
|
<el-radio
|
|
v-for="item of $d.CustomCalculateMark"
|
|
:key="`CustomCalculateMark${item.value}`"
|
|
:label="item.value"
|
|
>
|
|
{{ item.label }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-table
|
|
:data="form.CalculateQuestions"
|
|
style="margin: 10px;margin-top:30px;width: calc(100% - 20px)"
|
|
size="small">
|
|
<el-table-column
|
|
label="序号"
|
|
min-width="70"
|
|
>
|
|
<template slot-scope="scope">
|
|
{{scope.$index + 1}}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="运算符号"
|
|
show-overflow-tooltip
|
|
>
|
|
<template slot-scope="scope">
|
|
{{scope.$index === 0 && [1, 2, 3, 4].includes(form.CustomCalculateMark) ? null : $fd('CustomCalculateMark', form.CustomCalculateMark)}}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="是否表格问题"
|
|
prop="IsTable"
|
|
show-overflow-tooltip
|
|
v-if="false"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-switch
|
|
v-model="scope.row.IsTable"
|
|
>
|
|
</el-switch>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="表格名称"
|
|
prop="QuestionId"
|
|
show-overflow-tooltip
|
|
v-if="false"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-select v-model="scope.row.QuestionId" :disabled="!scope.row.IsTable">
|
|
<el-option v-for="item of tableQuestions" :key="item.TableQuestionId" :label="item.TableQuestionName" :value="item.TableQuestionId"></el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="问题名称"
|
|
prop="TableQuestionId"
|
|
show-overflow-tooltip
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-select v-model="scope.row.TableQuestionId">
|
|
<el-option v-for="item of Questions" :key="item.TableQuestionId" :label="item.TableQuestionName" :value="item.TableQuestionId"></el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<!-- 选项类型 -->
|
|
<el-form-item
|
|
v-if="form.Type === 'select' || form.Type === 'radio' || form.Type === 'input'"
|
|
label="选项类型"
|
|
prop="TableQuestionType"
|
|
:rules="[
|
|
{ required: form.Type !== 'input', message: '请选择'}
|
|
]"
|
|
>
|
|
<el-radio-group
|
|
v-model="form.TableQuestionType"
|
|
@change="((val)=>{tableQuestionTypeChange(val, form)})"
|
|
>
|
|
<el-radio
|
|
v-for="item of $d.TableQuestionType"
|
|
:key="item.id"
|
|
:label="item.value"
|
|
:disabled="form.Type === 'radio' && (item.value===1 || item.value===2)"
|
|
>
|
|
{{ item.label }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
v-if="form.TableQuestionType === 0"
|
|
label="选项"
|
|
prop="TypeValue"
|
|
>
|
|
<el-input
|
|
v-model="form.TypeValue"
|
|
placeholder="选项请用‘|’分割多个选项"
|
|
/>
|
|
</el-form-item>
|
|
<!-- 关联表 -->
|
|
<!-- <el-form-item
|
|
v-if="form.TableQuestionType === 1"
|
|
label="关联表"
|
|
prop="DataTableName"
|
|
>
|
|
<el-select
|
|
v-model="form.DataTableName"
|
|
clearable
|
|
@change="((val)=>{dataTableNameChange(val, form)})"
|
|
>
|
|
<el-option
|
|
v-for="item of tblOptions"
|
|
:key="`RelevanceId${item.QuestionId}`"
|
|
:label="item.QuestionName"
|
|
:value="item.QuestionId"
|
|
/>
|
|
</el-select>
|
|
</el-form-item> -->
|
|
<!-- 关联字段 -->
|
|
|
|
<el-form-item
|
|
v-if="form.TableQuestionType === 2"
|
|
label="关联问题"
|
|
prop="DependParentId"
|
|
>
|
|
<el-select
|
|
v-model="form.DependParentId"
|
|
>
|
|
<el-option
|
|
v-for="item of parentOptions"
|
|
:key="`DependParentId${item.QuestionId}`"
|
|
:label="item.QuestionName"
|
|
:value="item.QuestionId"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item
|
|
v-if="form.TableQuestionType === 1 || !!form.DependParentId"
|
|
label="关联字段"
|
|
prop="DataTableColumn"
|
|
>
|
|
<el-select v-model="form.DataTableColumn">
|
|
<el-option
|
|
v-for="item of $d.OrganColumn"
|
|
:key="item.id"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item
|
|
v-if="form.TableQuestionType === 3 || form.TableQuestionType === 2"
|
|
label="关联字典"
|
|
prop="DictionaryCode"
|
|
:rules="[{ required: form.TableQuestionType === 3, message: '请选择', trigger: 'blur' }]"
|
|
>
|
|
<el-select v-model="form.DictionaryCode">
|
|
<el-option
|
|
v-for="item of dicList"
|
|
:key="item.Id"
|
|
:label="item.Code"
|
|
:value="item.Code"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item v-if="form.Type !== '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.Type !== '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">
|
|
<el-option
|
|
v-for="item of parentTriggerValOptions"
|
|
:key="item"
|
|
:label="item"
|
|
:value="item"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="form.Type !== 'group' && form.Type !== 'table'" label="是否必填" prop="IsRequired">
|
|
<el-radio-group
|
|
v-model="form.IsRequired"
|
|
:disabled="form.IsJudgeQuestion===true || form.ShowQuestion===2"
|
|
@change="((val)=>{isRequiredChange(val, form)})"
|
|
>
|
|
<el-radio
|
|
v-for="item of $d.QuestionRequired"
|
|
:key="`QuestionRequired${item.value}`"
|
|
:label="item.value"
|
|
>
|
|
{{ item.label }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<!-- 父问题 -->
|
|
<el-form-item
|
|
v-if="form.Type !== 'group' && form.IsRequired === 1"
|
|
label="必填依赖父问题"
|
|
prop="RelevanceId"
|
|
>
|
|
<el-select
|
|
v-model="form.RelevanceId"
|
|
clearable
|
|
@change="((val)=>{relevanceQuestionChange(val, form)})"
|
|
>
|
|
<el-option
|
|
v-for="item of parentOptions"
|
|
:key="`RelevanceId${item.QuestionId}`"
|
|
:label="item.QuestionName"
|
|
:value="item.QuestionId"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<!-- 必填依赖的父问题触发值 -->
|
|
<el-form-item
|
|
v-if="form.RelevanceId && form.IsRequired === 1"
|
|
label="必填触发值"
|
|
prop="RelevanceValue"
|
|
>
|
|
<el-select v-model="form.RelevanceValue">
|
|
<el-option
|
|
v-for="item of reParentTriggerValOptions"
|
|
:key="item"
|
|
:label="item"
|
|
:value="item"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item
|
|
v-if="form.Type !== 'group'"
|
|
label="问题标识"
|
|
prop="QuestionMark"
|
|
>
|
|
<el-select
|
|
v-model="form.QuestionMark"
|
|
>
|
|
<el-option
|
|
v-for="item of $d.QuestionMark"
|
|
:key="item.id"
|
|
:value="item.value"
|
|
:label="item.label"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item v-if="form.Type === '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>
|
|
<el-form-item label="最大行数">
|
|
<el-input-number
|
|
v-model="form.MaxRowCount"
|
|
controls-position="right"
|
|
:min="0"
|
|
:max="10"
|
|
/>
|
|
</el-form-item>
|
|
|
|
</div>
|
|
<div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
|
|
<el-form-item>
|
|
<!-- 取消 -->
|
|
<el-button
|
|
size="small"
|
|
type="primary"
|
|
@click="close"
|
|
>
|
|
{{ $t('common:button:cancel') }}
|
|
</el-button>
|
|
<!-- 保存 -->
|
|
<el-button size="small" type="primary" @click="save">
|
|
{{ $t('common:button:save') }}
|
|
</el-button>
|
|
</el-form-item>
|
|
</div>
|
|
</el-form>
|
|
</template>
|
|
<script>
|
|
import { addOrUpdateReadingTableQuestionTrial, getReadingTableOtherQuestionTrial, getCalculateTableQuestions } from '@/api/trials'
|
|
import { getBasicConfigSelect } from '@/api/dictionary'
|
|
export default {
|
|
name: 'AddOrUpdateTableQs',
|
|
props: {
|
|
data: {
|
|
type: Object,
|
|
default() { return {} }
|
|
},
|
|
readingQuestionId: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
criterionId: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
|
|
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 {
|
|
form: {
|
|
Id: '',
|
|
ReadingQuestionId: '',
|
|
QuestionName: '',
|
|
Type: 'select',
|
|
TypeValue: '',
|
|
ParentId: '',
|
|
ParentTriggerValue: '',
|
|
ShowOrder: 0,
|
|
ShowQuestion: null,
|
|
IsRequired: true,
|
|
Remark: '',
|
|
RelevanceId: '',
|
|
RelevanceValue: '',
|
|
DataTableName: '',
|
|
DataTableColumn: '',
|
|
DictionaryCode: '',
|
|
TableQuestionType: null,
|
|
MaxRowCount: null,
|
|
DependParentId: '',
|
|
QuestionMark: null,
|
|
CalculateQuestions: [],
|
|
CustomCalculateMark: ''
|
|
// IsEnable: true
|
|
},
|
|
rules: {
|
|
Type: [
|
|
{ required: true, message: '请选择', trigger: 'blur' }
|
|
],
|
|
QuestionName: [{ required: true, message: '请注明', trigger: 'blur' },
|
|
{ max: 50, message: '最大长度为 50' }],
|
|
|
|
TypeValue: [{ required: true, message: '请注明', trigger: 'blur' },
|
|
{ validator: validateTypeVal, trigger: 'blur' },
|
|
{ max: 200, message: '最大长度为 200' }],
|
|
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' }],
|
|
DataTableName: [{ required: true, message: '请选择', trigger: 'blur' }],
|
|
DataTableColumn: [{ required: true, message: '请选择', trigger: 'blur' }],
|
|
DependParentId: [{ required: true, message: '请选择', trigger: 'blur' }]
|
|
},
|
|
loading: false,
|
|
parentOptions: [],
|
|
parentTriggerValOptions: [],
|
|
reParentTriggerValOptions: [],
|
|
tblOptions: [],
|
|
colOptions: [],
|
|
dicList: [],
|
|
Questions: [],
|
|
tableQuestions: []
|
|
}
|
|
},
|
|
mounted() {
|
|
this.initForm()
|
|
this.getCalculateTableQuestions('number')
|
|
this.getCalculateTableQuestions('table')
|
|
},
|
|
methods: {
|
|
addCustomCalculateMark() {
|
|
this.form.CalculateQuestions.push({
|
|
IsTable: false,
|
|
QuestionId: null,
|
|
TableQuestionId: null
|
|
})
|
|
},
|
|
CustomCalculateMarkChange() {
|
|
if (this.form.CustomCalculateMark <= 4) {
|
|
this.form.CalculateQuestions = [
|
|
{
|
|
IsTable: false,
|
|
QuestionId: null,
|
|
TableQuestionId: null
|
|
},{
|
|
IsTable: false,
|
|
QuestionId: null,
|
|
TableQuestionId: null
|
|
}
|
|
]
|
|
} else {
|
|
this.form.CalculateQuestions = [
|
|
{
|
|
IsTable: false,
|
|
QuestionId: null,
|
|
TableQuestionId: null
|
|
}
|
|
]
|
|
}
|
|
|
|
},
|
|
getCalculateTableQuestions(type) {
|
|
getCalculateTableQuestions({
|
|
QuestionId: this.readingQuestionId,
|
|
type: type
|
|
}).then(res => {
|
|
if (type === 'table') {
|
|
this.tableQuestions = res.Result
|
|
} else {
|
|
this.Questions = res.Result
|
|
}
|
|
})
|
|
},
|
|
async initForm() {
|
|
await this.getParentQuestions()
|
|
if (Object.keys(this.data).length > 0) {
|
|
for (const k in this.form) {
|
|
if (k === 'CalculateQuestions') {
|
|
this.form[k] = JSON.parse(this.data[k])
|
|
console.log('CalculateQuestions', this.form[k])
|
|
} else {
|
|
if (this.data.hasOwnProperty(k)) {
|
|
this.form[k] = this.data[k]
|
|
}
|
|
}
|
|
}
|
|
|
|
if (this.form.ParentId) {
|
|
var index = this.parentOptions.findIndex(item => {
|
|
return item.QuestionId === this.form.ParentId
|
|
})
|
|
if (index !== -1) {
|
|
this.parentTriggerValOptions = this.parentOptions[index].TypeValue.split('|')
|
|
}
|
|
}
|
|
if (this.form.RelevanceId) {
|
|
var i = this.parentOptions.findIndex(item => {
|
|
return item.QuestionId === this.form.RelevanceId
|
|
})
|
|
if (i !== -1) {
|
|
this.reParentTriggerValOptions = this.parentOptions[i].TypeValue.split('|')
|
|
}
|
|
}
|
|
}
|
|
},
|
|
getBasicConfigSelect() {
|
|
getBasicConfigSelect('Reading_eCRF').then(res => {
|
|
this.dicList = res.Result
|
|
})
|
|
},
|
|
save() {
|
|
this.$refs.tableQsForm.validate(valid => {
|
|
if (!valid) return
|
|
this.loading = true
|
|
var params = Object.assign({}, this.form)
|
|
params.ReadingQuestionId = this.readingQuestionId
|
|
params.TrialCriterionId = this.criterionId
|
|
params.CalculateQuestions = JSON.stringify(this.form.CalculateQuestions)
|
|
addOrUpdateReadingTableQuestionTrial(params).then(res => {
|
|
this.$emit('getList')
|
|
this.loading = false
|
|
this.$emit('close')
|
|
this.$emit('reloadArbitrationRules')
|
|
|
|
this.$message.success(this.$t('common:message:savedSuccessfully'))
|
|
})
|
|
.catch(() => {
|
|
this.loading = false
|
|
})
|
|
})
|
|
},
|
|
getParentQuestions() {
|
|
return new Promise((resolve, reject) => {
|
|
this.loading = true
|
|
var param = {
|
|
readingQuestionId: this.readingQuestionId,
|
|
id: this.data.Id
|
|
}
|
|
getReadingTableOtherQuestionTrial(param).then(res => {
|
|
this.parentOptions = res.Result
|
|
this.loading = false
|
|
resolve()
|
|
}).catch(() => {
|
|
this.loading = false
|
|
reject()
|
|
})
|
|
})
|
|
},
|
|
isShowQuestionChange(val, form) {
|
|
if (val === 2) {
|
|
form.IsRequired = 2
|
|
form.ParentId = ''
|
|
form.ParentTriggerValue = ''
|
|
} else {
|
|
form.ParentId = ''
|
|
form.ParentTriggerValue = ''
|
|
}
|
|
},
|
|
isRequiredChange(val, form) {
|
|
if (val !== 1) {
|
|
form.RelevanceId = ''
|
|
form.RelevanceValue = ''
|
|
}
|
|
},
|
|
parentQuestionChange(val, form) {
|
|
if (val) {
|
|
var index = this.parentOptions.findIndex(item => {
|
|
return item.QuestionId === val
|
|
})
|
|
if (index !== -1) {
|
|
this.parentTriggerValOptions = this.parentOptions[index].TypeValue.split('|')
|
|
}
|
|
}
|
|
form.ParentTriggerValue = ''
|
|
},
|
|
relevanceQuestionChange(val, form) {
|
|
if (val) {
|
|
var index = this.parentOptions.findIndex(item => {
|
|
return item.QuestionId === val
|
|
})
|
|
if (index !== -1) {
|
|
this.reParentTriggerValOptions = this.parentOptions[index].TypeValue.split('|')
|
|
}
|
|
}
|
|
form.RelevanceValue = ''
|
|
},
|
|
tableQuestionTypeChange(val, form) {
|
|
this.form.DictionaryCode = ''
|
|
this.form.DataTableColumn = ''
|
|
this.form.DataTableName = ''
|
|
this.form.DependParentId = ''
|
|
this.form.TypeValue = ''
|
|
},
|
|
dataTableNameChange(val, form) {
|
|
if (val) {
|
|
var index = this.tblOptions.findIndex(item => {
|
|
return item.Id === val
|
|
})
|
|
if (index !== -1) {
|
|
this.colOptions = this.tblOptions[index].Columns
|
|
}
|
|
}
|
|
form.DataTableColumn = ''
|
|
},
|
|
qsTypeChange(val, form) {
|
|
form.TypeValue = ''
|
|
form.TableQuestionType = null
|
|
form.DependParentId = ''
|
|
form.DataTableColumn = ''
|
|
form.DataTableName = ''
|
|
form.DictionaryCode = ''
|
|
},
|
|
close() {
|
|
this.$emit('close')
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
</style>
|