首页 > 其他 > 详细

自定义校验

时间:2021-07-07 12:38:51      阅读:16      评论:0      收藏:0      [点我收藏+]
validatorTagTypeValue(rule, value, callback) {
      const errors = []
      if (value !== ‘‘ && value !== undefined) {
        uniqueTagTypeValue({ noDictCode: this.dictCode, dictValue: value, dictType: ‘t_penetration_tag_type‘ }).then(res => {
          if (res.code !== 0) {
            errors.push(‘类型值‘ + value + ‘已存在‘)
          }
          callback(errors)
        })
          .catch(() => {
            this.$message.error(‘系统错误,请稍后再试‘)
            errors.push(‘系统错误,请稍后再试‘)
            callback(errors)
          })
          .finally(() => {
            this.confirmLoading = false
          })
      } else {
        callback()
      }
    },
formValidatorRules: {
        typeValue: [{ required: true, message: ‘标签类型值不能为空‘ }, { validator: this.validatorTagTypeValue }]
      },
<a-input v-decorator="[‘dictValue‘,{rules: formValidatorRules.typeValue}]"
                 placeholder="标签类型值" />

 

自定义校验

原文:https://www.cnblogs.com/ff2ting/p/14980372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!