自定义校验

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="标签类型值" />

 

自定义校验

上一篇:redis使用bitmap实现签到


下一篇:源数据与目标数据的映射(2张无关联的表联查)