|
@@ -107,11 +107,28 @@ export default {
|
|
|
rules() {
|
|
|
const that = this;
|
|
|
return {
|
|
|
- loginName: [{ required: true, message: "登录名必填" }],
|
|
|
- name: [{ required: true, message: "姓名必填" }],
|
|
|
+ loginName: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "登录名必填",
|
|
|
+ whitespace: true,
|
|
|
+ },
|
|
|
+ { min: 1, max: 20, message: "最长为20个字符" },
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ { required: true, message: "姓名必填", whitespace: true },
|
|
|
+ { min: 1, max: 20, message: "最长为20个字符" },
|
|
|
+ ],
|
|
|
password: [
|
|
|
{ required: !this.isEdit, message: "密码必填" },
|
|
|
{
|
|
|
+ required: !this.isEdit,
|
|
|
+ min: 1,
|
|
|
+ max: 16,
|
|
|
+ message: "最长为16个字符",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ required: !this.isEdit,
|
|
|
type: "string",
|
|
|
pattern: /^[a-z0-9_]+$/i,
|
|
|
message: "仅支持大小写英文字母、数字和下划线",
|
|
@@ -120,6 +137,7 @@ export default {
|
|
|
passwordConfirm: [
|
|
|
{ required: !this.isEdit, message: "密码必填" },
|
|
|
{
|
|
|
+ required: !this.isEdit,
|
|
|
type: "string",
|
|
|
pattern: /^[a-z0-9_]+$/i,
|
|
|
message: "仅支持大小写英文字母、数字和下划线",
|
|
@@ -128,15 +146,31 @@ export default {
|
|
|
type: "string",
|
|
|
trigger: "blur",
|
|
|
validator: function (rule, value, callback) {
|
|
|
- // console.log(value, that.form.password);
|
|
|
+ console.log(that.isEdit, value, that.form.password);
|
|
|
+ if (
|
|
|
+ that.isEdit &&
|
|
|
+ (that.form.password === undefined ||
|
|
|
+ that.form.password.trim().length === 0) &&
|
|
|
+ (value === undefined || value.trim().length === 0)
|
|
|
+ ) {
|
|
|
+ console.log("object");
|
|
|
+ callback();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log("pos");
|
|
|
if (value !== that.form.password) {
|
|
|
- callback(true);
|
|
|
+ callback(new Error("与密码不一致"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
}
|
|
|
},
|
|
|
message: "与密码不一致",
|
|
|
},
|
|
|
],
|
|
|
roleCode: [{ required: true, message: "角色必填" }],
|
|
|
+ mobileNumber: [
|
|
|
+ { required: false, pattern: /^\d*$/i, message: "手机号必须是数字" },
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
},
|