修改编辑店铺时form的校验方式
This commit is contained in:
parent
7d2e069349
commit
b23b80c2f0
@ -93,7 +93,7 @@ export default class extends Vue {
|
|||||||
private postForm = Object.assign({}, defaultShopData)
|
private postForm = Object.assign({}, defaultShopData)
|
||||||
private loading = false
|
private loading = false
|
||||||
private rules = {
|
private rules = {
|
||||||
title: [{ validator: this.validateRequire }],
|
name: [{ validator: this.validateRequire }],
|
||||||
}
|
}
|
||||||
|
|
||||||
private tempTagView?: ITagView
|
private tempTagView?: ITagView
|
||||||
@ -146,23 +146,23 @@ export default class extends Vue {
|
|||||||
document.title = `${title} - ${this.postForm._id}`
|
document.title = `${title} - ${this.postForm._id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
private submitForm() {
|
private async submitForm() {
|
||||||
(this.$refs.postForm as Form).validate(async valid => {
|
const form = <Form>this.$refs.postForm
|
||||||
if (valid) {
|
try {
|
||||||
this.loading = true
|
await form.validate()
|
||||||
await saveShop(this.postForm)
|
this.loading = true
|
||||||
this.loading = false
|
await saveShop(this.postForm)
|
||||||
this.$notify({
|
this.loading = false
|
||||||
title: 'Success',
|
this.$notify({
|
||||||
message: 'The post published successfully',
|
title: 'Success',
|
||||||
type: 'success',
|
message: 'The post published successfully',
|
||||||
duration: 2000
|
type: 'success',
|
||||||
})
|
duration: 2000
|
||||||
} else {
|
})
|
||||||
console.error('Submit Error!')
|
} catch (err) {
|
||||||
return false
|
console.error('Submit Error!')
|
||||||
}
|
return false
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private draftForm() {
|
private draftForm() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user