/**
 * 默认字典数据
 */
export default {
  Password(e, equalToPassword) {
    return [
      {
        required: e.required,
        message: e.message,
        transform: (value) => value,
        trigger: "blur",
      },
      {
        type: "string",
        message: "请输入不包含空格的字符",
        trigger: "blur",
        transform(value) {
          if (value && value.indexOf(" ") === -1) {
            return value;
          } else {
            return false;
          }
        },
      },
      {
        trigger: "blur",
        validator: (rule, value, callback) => {
          var passwordreg = /(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,16}/;
          if (!passwordreg.test(value)) {
            callback(
              new Error("密码必须由数字、字母、特殊字符组合,请输入6-16位")
            );
          } else {
            callback();
          }
        },
      },
      equalToPassword ? equalToPassword : {},
    ];
  },
  equalToPassword(rule, value, callback, newPassword) {
    if (newPassword !== value) {
      callback(new Error("两次输入的密码不一致"));
    } else {
      callback();
    }
  },
  Email: [
    { required: true, message: "邮箱地址不能为空", trigger: "blur" },
    {
      type: "email",
      message: "请输入正确的邮箱地址",
      trigger: ["blur", "change"],
    },
  ],
  Phone(required, message_one, message_two) {
    return [
      {
        required: required,
        message: message_one ? message_one : "请输入手机号码",
        trigger: "blur",
      },
      {
        pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
        message: message_two ? message_two : "请输入正确的手机号码",
        trigger: "blur",
      },
    ];
  },


  CheckMobile(e, equalToMobile) {
    return [
      {
        required: e.required,
        message: e.message,
        transform: (value) => value,
        trigger: "blur",
      },
      equalToMobile ? equalToMobile : {},
    ];
  },
  equalToMobile(rule, array, callback, element) {
    if (array.indexOf(element) == -1) {
      callback(new Error("请输入和访客部门相匹配的手机号码"));
    } else {
      callback();
    }
  },
};
