vue iview modal彈出框 form表單驗證

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

 

2、規則spa

3、3d

 
 
_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、效果圖code

相關文章
相關標籤/搜索