Commit 1152a441 authored by 邓超's avatar 邓超

fix: 机构管理密码强度规则修改

parent 9972a808
Pipeline #60941 passed with stages
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, notification, message, TreeSelect } from 'antd'; import { Modal, Form, Input, notification, message, TreeSelect } from 'antd';
import { addUser, GetUserRelationListNew } from '@/services/userManage/api'; import { addUser, GetUserRelationListNew } from '@/services/userManage/api';
import classNames from 'classnames';
import { ok } from '../../../assets/images/icons/ok.svg'; import { ok } from '../../../assets/images/icons/ok.svg';
import styles from './AddUserModal.less'; import styles from './AddUserModal.less';
const { SHOW_CHILD } = TreeSelect; const { SHOW_CHILD } = TreeSelect;
...@@ -16,7 +17,7 @@ const AddUserModal = props => { ...@@ -16,7 +17,7 @@ const AddUserModal = props => {
); // 邮箱 ); // 邮箱
const [value, setValue] = useState(['0-1-1']); const [value, setValue] = useState(['0-1-1']);
const [treeData, setTreeData] = useState([]); const [treeData, setTreeData] = useState([]);
const [passwordLevel, setPasswordLevel] = useState(''); // 密码等级 const [passwordLevel, setPasswordLevel] = useState(''); // 密码等级
const onChange = newValue => { const onChange = newValue => {
console.log('onChange ', value); console.log('onChange ', value);
setValue(newValue); setValue(newValue);
...@@ -163,25 +164,23 @@ const AddUserModal = props => { ...@@ -163,25 +164,23 @@ const AddUserModal = props => {
switch (modes) { switch (modes) {
case 1: case 1:
setPasswordLevel('弱'); setPasswordLevel('弱');
// return 1;
break; break;
case 2: case 2:
setPasswordLevel('弱');
break;
case 3:
if (sValue.length > 8) { if (sValue.length > 8) {
setPasswordLevel('中'); setPasswordLevel('中');
} else { } else {
setPasswordLevel('弱'); setPasswordLevel('弱');
} }
break; break;
case 4: case 3:
if (sValue.length < 10) { if (sValue.length > 8) {
setPasswordLevel('中');
} else {
setPasswordLevel('强'); setPasswordLevel('强');
} else {
setPasswordLevel('中');
} }
break;
case 4:
setPasswordLevel('强');
break; break;
} }
}; };
...@@ -213,7 +212,7 @@ const AddUserModal = props => { ...@@ -213,7 +212,7 @@ const AddUserModal = props => {
destroyOnClose destroyOnClose
afterClose={() => { afterClose={() => {
addUserForm.resetFields(); addUserForm.resetFields();
setPasswordLevel(''); setPasswordLevel('');
}} }}
onOk={submitAddUser} onOk={submitAddUser}
okText="确认" okText="确认"
...@@ -235,20 +234,32 @@ const AddUserModal = props => { ...@@ -235,20 +234,32 @@ const AddUserModal = props => {
> >
<Input placeholder="请输入登录名称(小于16位)" maxLength="16" /> <Input placeholder="请输入登录名称(小于16位)" maxLength="16" />
</Form.Item> </Form.Item>
<Form.Item <div className={styles.formBox}>
hasFeedback <Form.Item
name="password" hasFeedback
label="账号密码" name="password"
rules={[ label="账号密码"
{ rules={[
pattern: /^[a-zA-Z0-9_]{6,16}$/, {
message: '长度6-16位,支持字母与数字,允许下划线', pattern: /^[a-zA-Z0-9_]{6,16}$/,
}, message: '长度6-16位,支持字母与数字,允许下划线',
{ required: true }, },
]} { required: true },
> ]}
<Input placeholder="请输入账号密码(6~16位)" maxlength="16" suffix={passwordLevel} /> >
</Form.Item> <Input placeholder="请输入账号密码(6~16位)" maxlength="16" />
</Form.Item>
<div
className={classNames(styles.tipsText, {
[styles.tipsRed]: passwordLevel === '弱',
[styles.tipsOrange]: passwordLevel === '中',
[styles.tipsGreen]: passwordLevel === '强',
})}
>
{passwordLevel}
</div>
</div>
<Form.Item <Form.Item
hasFeedback hasFeedback
name="userName" name="userName"
......
...@@ -5,4 +5,28 @@ ...@@ -5,4 +5,28 @@
.ant-form-item-feedback-icon { .ant-form-item-feedback-icon {
margin-left: 10px; margin-left: 10px;
} }
.formBox {
position: relative;
.tipsText {
position: absolute;
right: 40px;
top: 5px;
z-index: 11;
}
.tipsGreen {
color: limegreen;
}
.tipsRed {
color: red;
}
.tipsOrange {
color: coral;
}
}
} }
\ No newline at end of file
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, notification, message } from 'antd'; import { Modal, Form, Input, notification, message } from 'antd';
import { updateUserPassword } from '@/services/userManage/api'; import { updateUserPassword } from '@/services/userManage/api';
import classNames from 'classnames';
import styles from './AddUserModal.less';
const ChangePasswordModal = props => { const ChangePasswordModal = props => {
const { visible, currentUser, currentSelectOrg, submitSearchUser, onSelect, onCancel } = props; const { visible, currentUser, currentSelectOrg, submitSearchUser, onSelect, onCancel } = props;
const [passwordForm] = Form.useForm(); // 修改密码 const [passwordForm] = Form.useForm(); // 修改密码
const [newPasswordLevel, setNewPasswordLevel] = useState(''); const [newPasswordLevel, setNewPasswordLevel] = useState('');
const [passwordConfirmLevel, setPasswordConfirmLevel] = useState(''); const [passwordConfirmLevel, setPasswordConfirmLevel] = useState('');
useEffect(() => { useEffect(() => {
console.log(currentUser); console.log(currentUser);
if (visible) { if (visible) {
...@@ -104,17 +106,16 @@ const ChangePasswordModal = props => { ...@@ -104,17 +106,16 @@ const ChangePasswordModal = props => {
case 1: case 1:
return '弱'; return '弱';
case 2: case 2:
return '弱';
case 3:
if (sValue.length > 8) { if (sValue.length > 8) {
return '中'; return '中';
} }
return '弱'; return '弱';
case 3:
case 4: if (sValue.length > 8) {
if (sValue.length < 10) { return '强';
return '中';
} }
return '中';
case 4:
return '强'; return '强';
} }
}; };
...@@ -143,52 +144,68 @@ const ChangePasswordModal = props => { ...@@ -143,52 +144,68 @@ const ChangePasswordModal = props => {
newPassword: '', newPassword: '',
passwordConfirm: '', passwordConfirm: '',
}); });
setNewPasswordLevel('');
setPasswordConfirmLevel('');
onCancel(); onCancel();
}} }}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
> >
<Form form={passwordForm} labelCol={{ span: 4 }} onFieldsChange={changeValue}> <div className={styles.modalContent}>
<Form.Item name="oldPassword" label="原始密码"> <Form form={passwordForm} labelCol={{ span: 4 }} onFieldsChange={changeValue}>
<Input disabled /> <Form.Item name="oldPassword" label="原始密码">
</Form.Item> <Input disabled />
<Form.Item </Form.Item>
name="newPassword" <div className={styles.formBox}>
label="新密码" <Form.Item
rules={[ name="newPassword"
{ label="新密码"
pattern: /^[a-zA-Z0-9_]{6,16}$/, rules={[
message: '长度6-16位,支持字母与数字,允许下划线', {
}, pattern: /^[a-zA-Z0-9_]{6,16}$/,
{ required: true }, message: '长度6-16位,支持字母与数字,允许下划线',
]} },
> { required: true },
<Input ]}
placeholder="请输入新密码" >
autoComplete="off" <Input placeholder="请输入新密码" autoComplete="off" maxLength="16" />
maxLength="16" </Form.Item>
suffix={newPasswordLevel} <div
/> className={classNames(styles.tipsText, {
</Form.Item> [styles.tipsRed]: newPasswordLevel === '弱',
<Form.Item [styles.tipsOrange]: newPasswordLevel === '中',
name="passwordConfirm" [styles.tipsGreen]: newPasswordLevel === '强',
label="确认密码" })}
rules={[ >
{ {newPasswordLevel}
pattern: /^[a-zA-Z0-9_]{6,16}$/, </div>
message: '长度6-16位,支持字母与数字,允许下划线', </div>
}, <div className={styles.formBox}>
{ required: true }, <Form.Item
]} name="passwordConfirm"
> label="确认密码"
<Input rules={[
placeholder="再次确认新密码" {
autoComplete="off" pattern: /^[a-zA-Z0-9_]{6,16}$/,
maxLength="16" message: '长度6-16位,支持字母与数字,允许下划线',
suffix={passwordConfirmLevel} },
/> { required: true },
</Form.Item> ]}
</Form> >
<Input placeholder="再次确认新密码" autoComplete="off" maxLength="16" />
</Form.Item>
<div
className={classNames(styles.tipsText, {
[styles.tipsRed]: passwordConfirmLevel === '弱',
[styles.tipsOrange]: passwordConfirmLevel === '中',
[styles.tipsGreen]: passwordConfirmLevel === '强',
})}
>
{passwordConfirmLevel}
</div>
</div>
</Form>
</div>
</Modal> </Modal>
); );
}; };
......
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