Commit a395b5c7 authored by 邓超's avatar 邓超

fix: 修改新增用户编辑用户限制

parent 632c2cf0
Pipeline #68596 passed with stages
......@@ -76,86 +76,87 @@ const AddUserModal = props => {
const password = addUserForm.getFieldValue('password') || '';
const phone = addUserForm.getFieldValue('phone') || '';
const email = addUserForm.getFieldValue('email') || '';
// 正则验证
if (loginName === '') {
notification.error({
message: '提交失败',
description: '登录名不能为空!',
});
} else if (!noChinese.test(loginName)) {
notification.error({
message: '提交失败',
description: '登录名不支持中文!',
});
} else if (password === '') {
notification.error({
message: '提交失败',
description: '密码不能为空!',
});
} else if (password.length < 6) {
notification.error({
message: '提交失败',
description: '密码至少为6位,且包含数字和字母!',
});
} else if (userName === '') {
notification.error({
message: '提交失败',
description: '用户名称不能为空!',
});
} else if (phone !== '' && !isPhone.test(phone)) {
notification.error({
message: '提交失败',
description: '请输入11位手机号!',
});
} else if (email !== '' && !isEmail.test(email)) {
notification.error({
message: '提交失败',
description: '邮箱格式不正确!',
});
}
// 所有验证通过才可以提交,phone/email为空时不验证
else if (
noChinese.test(loginName) &&
password.length >= 6 &&
userName &&
(phone === '' || isPhone.test(phone)) &&
(email === '' || isEmail.test(email))
) {
console.log(addUserForm.getFieldValue('GroupId'), 'afasdf');
console.log(orgID);
addUser({
GroupId: addUserForm.getFieldValue('GroupId') || '',
OUID: orgID.id,
loginName,
userName,
password: sha1(password).toUpperCase(),
phone,
email,
})
.then(res => {
console.log('fasdkljgiodsaujgioasdgi');
if (res.code === 0) {
addUserForm.resetFields();
onCancel(); // 设置Modal不可见
notification.success({
message: '提交成功',
duration: 2,
});
updateTrees1(orgID.id);
onSelect([`${orgID.id}`]);
// 重新获取用户表
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
}
})
.catch(err => {
message.error(err);
addUserForm.validateFields().then(validate => {
// 正则验证
if (loginName === '') {
notification.error({
message: '提交失败',
description: '登录名不能为空!',
});
}
} else if (!noChinese.test(loginName)) {
notification.error({
message: '提交失败',
description: '登录名不支持中文!',
});
} else if (password === '') {
notification.error({
message: '提交失败',
description: '密码不能为空!',
});
} else if (password.length < 6) {
notification.error({
message: '提交失败',
description: '密码至少为6位,且包含数字和字母!',
});
} else if (userName === '') {
notification.error({
message: '提交失败',
description: '用户名称不能为空!',
});
} else if (phone !== '' && !isPhone.test(phone)) {
notification.error({
message: '提交失败',
description: '请输入11位手机号!',
});
} else if (email !== '' && !isEmail.test(email)) {
notification.error({
message: '提交失败',
description: '邮箱格式不正确!',
});
}
// 所有验证通过才可以提交,phone/email为空时不验证
else if (
noChinese.test(loginName) &&
password.length >= 6 &&
userName &&
(phone === '' || isPhone.test(phone)) &&
(email === '' || isEmail.test(email))
) {
console.log(addUserForm.getFieldValue('GroupId'), 'afasdf');
console.log(orgID);
addUser({
GroupId: addUserForm.getFieldValue('GroupId') || '',
OUID: orgID.id,
loginName,
userName,
password: sha1(password).toUpperCase(),
phone,
email,
})
.then(res => {
console.log('fasdkljgiodsaujgioasdgi');
if (res.code === 0) {
addUserForm.resetFields();
onCancel(); // 设置Modal不可见
notification.success({
message: '提交成功',
duration: 2,
});
updateTrees1(orgID.id);
onSelect([`${orgID.id}`]);
// 重新获取用户表
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
}
})
.catch(err => {
message.error(err);
});
}
});
};
// 密码强度验证
const changeValue = changedFields => {
......
......@@ -50,103 +50,105 @@ const EditUserModal = props => {
const oldPassword = passwordForm.getFieldValue('oldPassword');
const newPassword = passwordForm.getFieldValue('newPassword');
const passwordConfirm = passwordForm.getFieldValue('passwordConfirm');
// 正则验证
if (loginName === '') {
notification.error({
message: '提交失败',
description: '登录名称不能为空!',
});
return;
}
if (!noChinese.test(loginName)) {
notification.error({
message: '提交失败',
description: '登录名不支持中文!',
});
return;
}
if (userName === '') {
notification.error({
message: '提交失败',
description: '用户姓名不能为空!',
});
return;
}
if (phone !== '' && !isPhone.test(phone)) {
notification.error({
message: '提交失败',
description: '请输入11位手机号!',
});
return;
}
if (email !== '' && !isEmail.test(email)) {
notification.error({
message: '提交失败',
description: '邮箱格式不正确!',
});
return;
}
// if ((newPassword && passwordConfirm === '') || (passwordConfirm && newPassword === '')) {
// notification.error({
// message: '提交失败',
// description: '请填写密码',
// });
// return;
// }
if ((newPassword && newPassword.length < 6) || (passwordConfirm && passwordConfirm < 6)) {
notification.error({
message: '提交失败',
description: '密码至少为6位!',
});
return;
}
if (newPassword !== passwordConfirm) {
notification.error({
message: '提交失败',
description: '确认密码不一致!',
});
return;
}
// 所有验证通过才可以提交,phone/email为空时不验证
if (
loginName &&
noChinese.test(loginName) &&
userName &&
(phone === '' || isPhone.test(phone)) &&
(email === '' || isEmail.test(email))
) {
editUser(currentUser.userId, loginName, userName, phone, email)
.then(res => {
if (res.msg === '') {
onCancel();
// 重新获取用户表
if (!newPassword) {
// eslint-disable-next-line no-unused-expressions
currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
}
editUserForm.validateFields().then(validate => {
// 正则验证
if (loginName === '') {
notification.error({
message: '提交失败',
description: '登录名称不能为空!',
});
return;
}
if (!noChinese.test(loginName)) {
notification.error({
message: '提交失败',
description: '登录名不支持中文!',
});
return;
}
if (userName === '') {
notification.error({
message: '提交失败',
description: '用户姓名不能为空!',
});
return;
}
if (phone !== '' && !isPhone.test(phone)) {
notification.error({
message: '提交失败',
description: '请输入11位手机号!',
});
return;
}
if (email !== '' && !isEmail.test(email)) {
notification.error({
message: '提交失败',
description: '邮箱格式不正确!',
});
return;
}
// if ((newPassword && passwordConfirm === '') || (passwordConfirm && newPassword === '')) {
// notification.error({
// message: '提交失败',
// description: '请填写密码',
// });
// return;
// }
if ((newPassword && newPassword.length < 6) || (passwordConfirm && passwordConfirm < 6)) {
notification.error({
message: '提交失败',
description: '密码至少为6位!',
});
return;
}
if (newPassword !== passwordConfirm) {
notification.error({
message: '提交失败',
description: '确认密码不一致!',
});
return;
}
// 所有验证通过才可以提交,phone/email为空时不验证
if (
loginName &&
noChinese.test(loginName) &&
userName &&
(phone === '' || isPhone.test(phone)) &&
(email === '' || isEmail.test(email))
) {
editUser(currentUser.userId, loginName, userName, phone, email)
.then(res => {
if (res.msg === '') {
onCancel();
// 重新获取用户表
if (!newPassword) {
// eslint-disable-next-line no-unused-expressions
currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
}
notification.success({
message: '提交成功',
duration: 2,
});
submitChangePassword();
} else {
notification.error({
message: '提交失败',
description: res.message,
notification.success({
message: '提交成功',
duration: 2,
});
submitChangePassword();
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
editUserForm.setFieldsValue({
loginName: voca.stripTags(currentUser.loginName),
userName: voca.stripTags(currentUser.userName),
phone: voca.stripTags(currentUser.phone) || '',
email: currentUser.email || '',
});
}
editUserForm.setFieldsValue({
loginName: voca.stripTags(currentUser.loginName),
userName: voca.stripTags(currentUser.userName),
phone: voca.stripTags(currentUser.phone) || '',
email: currentUser.email || '',
})
.catch(err => {
message.error(err);
});
})
.catch(err => {
message.error(err);
});
}
}
});
};
const title = (
<span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment