修改编辑店铺时form的校验方式

This commit is contained in:
zhl 2021-04-19 20:08:08 +08:00
parent 7d2e069349
commit b23b80c2f0

View File

@ -93,7 +93,7 @@ export default class extends Vue {
private postForm = Object.assign({}, defaultShopData)
private loading = false
private rules = {
title: [{ validator: this.validateRequire }],
name: [{ validator: this.validateRequire }],
}
private tempTagView?: ITagView
@ -146,23 +146,23 @@ export default class extends Vue {
document.title = `${title} - ${this.postForm._id}`
}
private submitForm() {
(this.$refs.postForm as Form).validate(async valid => {
if (valid) {
this.loading = true
await saveShop(this.postForm)
this.loading = false
this.$notify({
title: 'Success',
message: 'The post published successfully',
type: 'success',
duration: 2000
})
} else {
console.error('Submit Error!')
return false
}
})
private async submitForm() {
const form = <Form>this.$refs.postForm
try {
await form.validate()
this.loading = true
await saveShop(this.postForm)
this.loading = false
this.$notify({
title: 'Success',
message: 'The post published successfully',
type: 'success',
duration: 2000
})
} catch (err) {
console.error('Submit Error!')
return false
}
}
private draftForm() {