78 lines
1.9 KiB
Plaintext
78 lines
1.9 KiB
Plaintext
<template>
|
|
|
|
<el-form
|
|
ref="sponsorForm"
|
|
:model="form"
|
|
:rules="rules"
|
|
class="demo-ruleForm"
|
|
size="small"
|
|
label-width="120px"
|
|
>
|
|
<div class="base-dialog-body">
|
|
<el-form-item label="Sponsor Name: " prop="SponsorName">
|
|
<el-input v-model="form.SponsorName" />
|
|
</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="handleCancel">Cancel</el-button>
|
|
<el-button size="small" type="primary" :loading="btnLoading" @click="handleSave">Save</el-button>
|
|
</el-form-item>
|
|
</div>
|
|
</el-form>
|
|
</template>
|
|
<script>
|
|
import { addOrUpdateSponsor } from '@/api/dictionary'
|
|
export default {
|
|
name: 'SponsorForm',
|
|
props: {
|
|
data: {
|
|
type: Object,
|
|
default() {
|
|
return {}
|
|
}
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
btnLoading: false,
|
|
form: {
|
|
Id: '',
|
|
SponsorName: ''
|
|
},
|
|
rules: {
|
|
SponsorName: [{ required: true, message: 'Please specify', trigger: 'blur' }, { max: 50, message: 'The maximum length is 50' }]
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
if (Object.keys(this.data).length && this.data.Id) {
|
|
this.form = { ...this.data }
|
|
}
|
|
},
|
|
methods: {
|
|
handleSave() {
|
|
this.$refs.sponsorForm.validate(valid => {
|
|
if (!valid) return
|
|
this.btnLoading = true
|
|
addOrUpdateSponsor(this.form).then(res => {
|
|
this.btnLoading = false
|
|
if (res.IsSuccess) {
|
|
this.$message.success('Saved successfully')
|
|
this.$refs['sponsorForm'].resetFields()
|
|
this.$emit('getList')
|
|
this.$emit('close')
|
|
}
|
|
}).catch(() => {
|
|
this.btnLoading = false
|
|
})
|
|
})
|
|
},
|
|
handleCancel() {
|
|
this.$emit('close')
|
|
}
|
|
}
|
|
|
|
}
|
|
</script>
|