irc_web/.svn/pristine/b5/b593915430ac7a50101a9c4da61...

157 lines
4.5 KiB
Plaintext

<template>
<div>
<el-form
ref="readingCriterionsForm"
v-loading="loading"
:model="form"
:rules="rules"
label-width="120px"
size="small"
>
<!-- 修约小数位数 -->
<el-form-item
:label="$t('trials:processCfg:form:digitPlaces')"
prop="DigitPlaces"
>
<el-radio-group
v-model="form.DigitPlaces"
:disabled="isConfirm || (!hasPermi(['trials:trials-panel:setting:reading-unit:edit']))"
>
<el-radio
v-for="item of $d.DigitPlaces"
:key="item.id"
:label="item.value"
>
{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<!-- 表单类型 -->
<el-form-item
label="表单类型"
prop="FormType"
>
<el-radio-group
v-model="form.FormType"
:disabled="isConfirm || (!hasPermi(['trials:trials-panel:setting:reading-unit:edit']))"
>
<el-radio
v-for="item of $d.CriterionFormType"
:key="item.id"
:label="item.value"
>
{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<QuestionsList
v-if="form.FormType===1"
:list="readingInfo.TrialQuestionList"
:trial-criterion-id="readingInfo.TrialCriterionId"
:is-confirm="isConfirm"
@reloadArbitrationRules="reloadArbitrationRules"
/>
<PageBreakList
v-if="form.FormType===2"
:list="readingInfo.ReadingCriterionPageList"
:trial-criterion-id="readingInfo.TrialCriterionId"
:is-confirm="isConfirm"
@reloadArbitrationRules="reloadArbitrationRules"
/>
</el-form-item>
<el-form-item v-if="!isConfirm && hasPermi(['trials:trials-panel:setting:reading-unit:edit'])">
<!-- 保存 -->
<el-button
type="primary"
@click="handleSave(true)"
>
{{ $t('common:button:save') }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { getTrialReadingCriterionInfo, setTrialReadingCriterion } from '@/api/trials'
import PageBreakList from './PageBreakList'
import QuestionsList from './QuestionsList'
export default {
name: 'ReadingCriterion',
components: { PageBreakList, QuestionsList },
data() {
return {
loading: false,
form: {
TrialCriterionId: '',
FormType: null,
DigitPlaces: null
},
rules: {
FormType: [
{ required: true, message: this.$t('common:ruleMessage:select'), trigger: ['blur', 'change'] }
],
DigitPlaces: [
{ required: true, message: this.$t('common:ruleMessage:select'), trigger: ['blur', 'change'] }
]
},
readingInfo: {},
isConfirm: true
}
},
mounted() {
this.initPage()
},
methods: {
initPage() {
this.loading = true
const trialId = this.$route.query.trialId
getTrialReadingCriterionInfo({ trialId }).then(res => {
this.loading = false
this.readingInfo = res.Result
for (const k in this.form) {
if (res.Result.hasOwnProperty(k)) {
this.form[k] = res.Result[k]
}
}
this.isConfirm = res.Result.IsSign
}).catch(() => {
this.loading = false
})
},
// 配置信息保存
handleSave(isPrompt = true) {
return new Promise((resolve, reject) => {
this.$refs['readingCriterionsForm'].validate((valid) => {
if (!valid) {
reject(false)
} else {
this.loading = true
// 保存配置信息
if (!isPrompt) {
this.form.IsSignSave = true
}
setTrialReadingCriterion(this.form).then(res => {
this.loading = false
if (res.IsSuccess && isPrompt) {
this.$message.success(this.$t('common:message:savedSuccessfully'))
}
this.$emit('reloadArbitrationRules')
resolve(true)
}).catch(_ => {
this.loading = false
reject(false)
})
}
})
})
},
reloadArbitrationRules() {
this.$emit('reloadArbitrationRules')
}
}
}
</script>