Commit a395b5c7 authored by 邓超's avatar 邓超

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

parent 632c2cf0
Pipeline #68596 passed with stages
...@@ -76,86 +76,87 @@ const AddUserModal = props => { ...@@ -76,86 +76,87 @@ const AddUserModal = props => {
const password = addUserForm.getFieldValue('password') || ''; const password = addUserForm.getFieldValue('password') || '';
const phone = addUserForm.getFieldValue('phone') || ''; const phone = addUserForm.getFieldValue('phone') || '';
const email = addUserForm.getFieldValue('email') || ''; const email = addUserForm.getFieldValue('email') || '';
addUserForm.validateFields().then(validate => {
// 正则验证 // 正则验证
if (loginName === '') { if (loginName === '') {
notification.error({ notification.error({
message: '提交失败', message: '提交失败',
description: '登录名不能为空!', 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);
}); });
} } 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 => { const changeValue = changedFields => {
......
...@@ -50,103 +50,105 @@ const EditUserModal = props => { ...@@ -50,103 +50,105 @@ const EditUserModal = props => {
const oldPassword = passwordForm.getFieldValue('oldPassword'); const oldPassword = passwordForm.getFieldValue('oldPassword');
const newPassword = passwordForm.getFieldValue('newPassword'); const newPassword = passwordForm.getFieldValue('newPassword');
const passwordConfirm = passwordForm.getFieldValue('passwordConfirm'); const passwordConfirm = passwordForm.getFieldValue('passwordConfirm');
// 正则验证 editUserForm.validateFields().then(validate => {
if (loginName === '') { // 正则验证
notification.error({ if (loginName === '') {
message: '提交失败', notification.error({
description: '登录名称不能为空!', message: '提交失败',
}); description: '登录名称不能为空!',
return; });
} return;
if (!noChinese.test(loginName)) { }
notification.error({ if (!noChinese.test(loginName)) {
message: '提交失败', notification.error({
description: '登录名不支持中文!', message: '提交失败',
}); description: '登录名不支持中文!',
return; });
} return;
if (userName === '') { }
notification.error({ if (userName === '') {
message: '提交失败', notification.error({
description: '用户姓名不能为空!', message: '提交失败',
}); description: '用户姓名不能为空!',
return; });
} return;
if (phone !== '' && !isPhone.test(phone)) { }
notification.error({ if (phone !== '' && !isPhone.test(phone)) {
message: '提交失败', notification.error({
description: '请输入11位手机号!', message: '提交失败',
}); description: '请输入11位手机号!',
return; });
} return;
if (email !== '' && !isEmail.test(email)) { }
notification.error({ if (email !== '' && !isEmail.test(email)) {
message: '提交失败', notification.error({
description: '邮箱格式不正确!', message: '提交失败',
}); description: '邮箱格式不正确!',
return; });
} return;
// if ((newPassword && passwordConfirm === '') || (passwordConfirm && newPassword === '')) { }
// notification.error({ // if ((newPassword && passwordConfirm === '') || (passwordConfirm && newPassword === '')) {
// message: '提交失败', // notification.error({
// description: '请填写密码', // message: '提交失败',
// }); // description: '请填写密码',
// return; // });
// } // return;
if ((newPassword && newPassword.length < 6) || (passwordConfirm && passwordConfirm < 6)) { // }
notification.error({ if ((newPassword && newPassword.length < 6) || (passwordConfirm && passwordConfirm < 6)) {
message: '提交失败', notification.error({
description: '密码至少为6位!', message: '提交失败',
}); description: '密码至少为6位!',
return; });
} return;
if (newPassword !== passwordConfirm) { }
notification.error({ if (newPassword !== passwordConfirm) {
message: '提交失败', notification.error({
description: '确认密码不一致!', message: '提交失败',
}); description: '确认密码不一致!',
return; });
} return;
// 所有验证通过才可以提交,phone/email为空时不验证 }
if ( // 所有验证通过才可以提交,phone/email为空时不验证
loginName && if (
noChinese.test(loginName) && loginName &&
userName && noChinese.test(loginName) &&
(phone === '' || isPhone.test(phone)) && userName &&
(email === '' || isEmail.test(email)) (phone === '' || isPhone.test(phone)) &&
) { (email === '' || isEmail.test(email))
editUser(currentUser.userId, loginName, userName, phone, email) ) {
.then(res => { editUser(currentUser.userId, loginName, userName, phone, email)
if (res.msg === '') { .then(res => {
onCancel(); if (res.msg === '') {
// 重新获取用户表 onCancel();
if (!newPassword) { // 重新获取用户表
// eslint-disable-next-line no-unused-expressions if (!newPassword) {
currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]); // eslint-disable-next-line no-unused-expressions
} currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
}
notification.success({ notification.success({
message: '提交成功', message: '提交成功',
duration: 2, duration: 2,
}); });
submitChangePassword(); submitChangePassword();
} else { } else {
notification.error({ notification.error({
message: '提交失败', message: '提交失败',
description: res.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({ .catch(err => {
loginName: voca.stripTags(currentUser.loginName), message.error(err);
userName: voca.stripTags(currentUser.userName),
phone: voca.stripTags(currentUser.phone) || '',
email: currentUser.email || '',
}); });
}) }
.catch(err => { });
message.error(err);
});
}
}; };
const title = ( const title = (
<span> <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