data: function () {
    const validataNameLength = (rule, value, callback) => { // 定义规则
      if (value != '' && this.GetStrLength(value) <= 20) {
        callback()
      } else {
        callback(new Error('长度超出限制'))
      }
    };

    var validatePhone = (rule, value, callback) => {
      if (value && value != "") {
        if (
          !/^1[0-9]{10}$/.test(
            value
          )
        ) {
          callback(new Error("请输入正确的手机号码"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    }
    return {
      Height: window.innerHeight,
      listLoading: false,
      formLoading: false,
      model: {
        ui_userid: '',
        ui_loginid: '',
        ui_user_status: '',
        ui_user_name: '',
        ui_user_code: '',
        ui_contact_phone: '',
        ui_contact_extphone: '',
        ui_contact_email: ''
      },
      rules: {
        //这里是添加页面 验证是否输入值或者选择值 不填入会提示(参考JS验证不能为空)
        ui_loginid: [{
          required: true,
          message: "登录ID(手机号)不能为空",
          trigger: "change"
        }, {// 对应item-prop
          validator: validatePhone, // 对应上方规则
          trigger: 'change'// 修改验证
        }],
        ui_user_name: [{
          required: true,
          message: "中文名不能为空",
          trigger: "change"
        }, {// 对应item-prop
          validator: validataNameLength, // 对应上方规则
          trigger: 'change'// 修改验证
        }],
      },

Logo

前往低代码交流专区

更多推荐