irc_web/src/views/research-mobile/components/EquipmentForm.vue

169 lines
4.3 KiB
Vue

<template>
<div
v-loading="loading"
class="equipment_form_content"
>
<el-form
ref="equipmentForm"
:model="form"
:rules="rules"
label-position="left"
>
<!-- 扫描设备 -->
<el-form-item :label="$t('trials:equiptResearch:form:equipment')" prop="EquipmentTypeId">
<el-select
v-model="form.EquipmentTypeId"
style="width:100%"
>
<el-option
v-for="item of $d.SiteSurvey_ScanEquipmentType"
:key="item.id"
:label="item.label"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- 扫描参数 -->
<el-form-item v-if="isShowParameters" :label="$t('trials:equiptResearch:form:param')">
<el-input v-model="form.Parameters" />
</el-form-item>
<!-- 扫描仪器制造商名称 -->
<el-form-item :label="$t('trials:equiptResearch:form:manufacturer')">
<el-input v-model="form.ManufacturerName" />
</el-form-item>
<!-- 扫描仪型号 -->
<el-form-item :label="$t('trials:equiptResearch:form:model')">
<el-input v-model="form.ScannerType" />
</el-form-item>
<!-- 备注 -->
<el-form-item :label="$t('trials:equiptResearch:form:remark')">
<el-input v-model="form.Note" />
</el-form-item>
<div style="text-align: center;padding:20px 0px;">
<!-- -->
<el-button
size="large"
type="primary"
@click="handleCancel"
>
{{ $t("common:button:cancel") }}
</el-button>
<!-- 保存 -->
<el-button
size="large"
type="primary"
@click="handleSave"
>
{{ $t("common:button:save") }}
</el-button>
</div>
</el-form>
</div>
</template>
<script>
import { addOrUpdateTrialSiteEquipmentSurvey } from '@/api/research'
import { getQueryString } from '@/utils/history.js'
export default {
name: 'EquipmentForm',
props: {
equipmentInfo: {
type: Object,
default() {
return {}
}
},
trialSiteSurveyEquipmentType: {
type: String,
default: ''
},
isShowParameters: {
type: Boolean,
default: false
}
},
data() {
return {
form: {
Id: '',
EquipmentTypeId: '',
Parameters: '',
ManufacturerName: '',
ScannerType: '',
Note: '',
TrialSiteSurveyId: ''
},
rules: {
EquipmentTypeId: [
{ required: true, message: this.$t('trials:researchForm:formRule:select'), trigger: ['blur', 'change'] }
]
},
loading: false,
dictionaryList: {}
}
},
mounted() {
this.initForm()
},
methods: {
async initForm() {
Object.keys(this.equipmentInfo).forEach(key => {
this.form[key] = this.equipmentInfo[key]
})
},
// 保存参与者信息
async handleSave() {
try {
const validate = await this.$refs.equipmentForm.validate()
if (!validate) return
this.loading = true
if (!this.form.TrialSiteSurveyId) {
this.form.TrialSiteSurveyId = getQueryString('trialSiteSurveyId')
}
const trialId = getQueryString('trialId')
const res = await addOrUpdateTrialSiteEquipmentSurvey(trialId, this.form)
this.loading = false
if (res.IsSuccess) {
this.$message.success(this.$t('common:message:savedSuccessfully'))
this.$emit('getList')
this.$emit('close')
}
} catch (e) {
this.loading = false
console.log(e)
}
},
handleTrialRoleChange(v) {
if (v === 1) {
// crc
this.form.IsGenerateAccount = true
this.form.UserTypeId = this.crcId
} else if (v === 2) {
// cra
this.form.IsGenerateAccount = true
this.form.UserTypeId = this.craId
} else {
this.form.IsGenerateAccount = false
this.form.UserTypeId = ''
}
},
// 取消保存
handleCancel() {
this.$emit('close')
}
}
}
</script>
<style lang="scss" scoped>
.equipment_form_content{
padding: 0 10px;
/deep/.el-form-item {
margin-bottom: 0px;
padding: 5px 0 20px 0;
border-bottom: 1px solid #f5f7fa;
.el-form-item__content{
color: #82848a;
}
}
}
</style>