vue iview modal弹出框 form表单验证

1、ref="addApply" :model="addApply" :rules="ruleValidate"   不要忘记propthis

 

2、规则spa

3、code

复制代码
 
 
复制代码
_createApply(name){
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        let addApply = Object.assign({},this.addApply)
                        addApply.serviceEndDate = formatDate(new Date(addApply.serviceEndDate),'yyyy-MM-dd')
                        createApply(addApply).then(res=>{
                            if(res.data.errcode ===0){
                                this.dialogAdd = false
                                this.$Message.info('建立成功!')
                                this._getApplyList()
                                this.$refs[name].resetFields();
                            } else if(res.data.errcode === 40199){
                                this.$Message.error('建立失败,该书库应用已存在!')
                            }
                        })
                    }
                }) 
            },
复制代码
cancleSubmit(name){
                this.$refs[name].resetFields();
            },

 

 4、效果图orm

相关文章
相关标签/搜索