elment 表单校验 编辑回显时有值还会触发校验&& 关闭新增弹框后重新打开还有标红校验

问题

 

 解决 1.两个表单的ref绑定的名称一样,把名称换一下,关闭的时候使用resetFields

页面代码:

 

新增时解耦:

   close() {
        this.$refs.userform.resetFields();
        this.$refs.userformEdit.resetFields()
        this.userform = {isDorm:0,isBreak:0,isGongjijin: 0};
        this.dialogApply = false;
        this.dialogInfo = false;
      },

若首先编辑,会初始化值,再新增resetFields无效

编辑时解耦: 主要是把赋值写在nextTick里面,

  this.$nextTick(()=> {
            this.userform = copy;
            this.oldBedNumId=copy.cwId;
            this.dormIsShow=false;
            this.noOne=false;
            if (this.userform.stafferType!=null&&this.userform.stafferType!=undefined){
              this.userform.stafferType = this.userform.stafferType.toString();
            }
            this.setSsqAndOrg(1);
          })

 

posted @ 2022-03-18 17:37  Li_ll  Views(1112)  Comments(0Edit  收藏  举报