irc_web/.svn/pristine/b7/b7c6f5fb9b5077634bcdee87af7...

104 lines
2.7 KiB
Plaintext

<template>
<el-form
ref="surgeryForm"
:model="form"
label-width="100px"
size="small"
:rules="rules"
class="surgery-wrapper"
>
<div class="base-dialog-body">
<!-- 手术名称 -->
<el-form-item :label="$t('trials:uploadClinicalData:table:surgeryName')" prop="OperationName">
<el-input v-model="form.OperationName" />
</el-form-item>
<!-- 手术日期 -->
<el-form-item :label="$t('trials:uploadClinicalData:table:surgeryDate')" prop="OperationTime">
<el-date-picker
v-model="form.OperationTime"
type="date"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
:picker-options="pickerOption"
style="width:100%;"
/>
</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" :disabled="saveBtnLoading" @click="cancel">
{{ $t('common:button:cancel') }}
</el-button>
<el-button size="small" type="primary" :loading="saveBtnLoading" @click="handleSave">
{{ $t('common:button:save') }}
</el-button>
</el-form-item>
</div>
</el-form>
</template>
<script>
import { addOrUpdatePreviousSurgery } from '@/api/trials'
export default {
props: {
parentData: {
type: Object,
default() { return {} }
},
data: {
type: Object,
default() { return {} }
},
subjectVisitId: {
type: String,
required: true
}
},
data() {
return {
trialId: this.$route.query.trialId,
form: {
OperationName: '',
OperationTime: ''
// IsSubjectLevel: true
},
rules: {
OperationName: [{ required: true, message: 'Please specify', trigger: ['blur', 'change'] }]
},
saveBtnLoading: false,
pickerOption: {
disabledDate: time => {
return time.getTime() > Date.now()
}
}
}
},
mounted() {
if (Object.keys(this.data).length && this.data.Id) {
this.form = { ...this.data }
}
},
methods: {
handleSave() {
this.$refs.surgeryForm.validate(valid => {
if (!valid) return
this.saveBtnLoading = true
this.form.SubjectVisitId = this.subjectVisitId
// this.form.Type = '既往手术史'
addOrUpdatePreviousSurgery(this.trialId, this.form).then(res => {
this.saveBtnLoading = false
this.$emit('closePSDialog')
this.$emit('refresh')
this.$message.success(this.$t('common:message:savedSuccessfully'))
}).catch(() => {
this.saveBtnLoading = false
})
})
},
cancel() {
this.$emit('closePSDialog')
}
}
}
</script>