添加 修改密码
parent
2cb12f4769
commit
b420d85971
|
|
@ -32,7 +32,7 @@
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"relation-graph": "^2.2.11",
|
"relation-graph": "^2.2.11",
|
||||||
"zy-react-library": "^1.3.24"
|
"zy-react-library": "^1.3.28"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^5.4.1",
|
"@antfu/eslint-config": "^5.4.1",
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
<meta name="renderer" content="webkit"/>
|
<meta name="renderer" content="webkit"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
|
||||||
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
|
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
|
||||||
|
<meta charset="UTF-8" name="referrer" content="strict-origin-when-cross-origin"/>
|
||||||
<% for (const item of $links) { %>
|
<% for (const item of $links) { %>
|
||||||
<link type="text/css" rel="stylesheet" href="<%= item %>"></link>
|
<link type="text/css" rel="stylesheet" href="<%= item %>"></link>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
||||||
|
|
@ -90,3 +90,11 @@ export const getChangerRecordInfoById = declareRequest(
|
||||||
"userLoading",
|
"userLoading",
|
||||||
"Post > @/basicInfo/userCorpRecord/getUserCorpRecordById",
|
"Post > @/basicInfo/userCorpRecord/getUserCorpRecordById",
|
||||||
);
|
);
|
||||||
|
export const userUpdatePassword = declareRequest(
|
||||||
|
"userLoading",
|
||||||
|
"Post > @/basicInfo/user/updatePassword",
|
||||||
|
);
|
||||||
|
export const userGetInfo = declareRequest(
|
||||||
|
"userLoading",
|
||||||
|
"Get > /basicInfo/user/getInfo",
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import ListPage from "~/pages/Container/Supervision/ChangePassword";
|
||||||
|
|
||||||
|
function List(props) {
|
||||||
|
return (
|
||||||
|
<ListPage
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default List;
|
||||||
|
|
@ -77,7 +77,7 @@ function Add(props) {
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
name: data.name,
|
name: data.name,
|
||||||
url: process.env.app["fileUrl"] + data.userAvatarUrl,
|
url: window.fileUrl + data.userAvatarUrl,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import ListPage from "~/pages/Container/Supervision/ChangePassword";
|
||||||
|
|
||||||
|
function List(props) {
|
||||||
|
return (
|
||||||
|
<ListPage
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default List;
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
|
import { Button, Form, Input, message } from "antd";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import Page from "zy-react-library/components/Page";
|
||||||
|
|
||||||
|
import { NS_USER } from "~/enumerate/namespace";
|
||||||
|
|
||||||
|
const PASSWORD_PATTERN = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!#@*&])[A-Za-z\d!#@*&]{8,16}$/;
|
||||||
|
|
||||||
|
function ChangePassword(props) {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const [userId, setUserId] = useState();
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getCurrentUser = async () => {
|
||||||
|
const res = await props["userGetInfo"]();
|
||||||
|
if (res.success && res.data) {
|
||||||
|
setUserId(res.data.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getCurrentUser();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onSubmit = async (values) => {
|
||||||
|
if (!userId) {
|
||||||
|
message.error("未获取到当前用户信息,请刷新页面后重试");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSubmitting(true);
|
||||||
|
try {
|
||||||
|
const res = await props["userUpdatePassword"]({
|
||||||
|
...values,
|
||||||
|
id: userId,
|
||||||
|
});
|
||||||
|
if (res.success) {
|
||||||
|
message.success("密码修改成功请重新登录!");
|
||||||
|
window.base.call.loginOut({ quick: true });
|
||||||
|
form.resetFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page isShowAllAction={false} isShowFooter={false}>
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
labelCol={{ span: 8 }}
|
||||||
|
wrapperCol={{ span: 10 }}
|
||||||
|
onFinish={onSubmit}
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
label="原密码"
|
||||||
|
name="password"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "请输入原密码",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input.Password
|
||||||
|
autoComplete="current-password"
|
||||||
|
maxLength={18}
|
||||||
|
placeholder="请输入原密码"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="新密码"
|
||||||
|
name="newPassword"
|
||||||
|
dependencies={["password"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "请输入新密码",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: PASSWORD_PATTERN,
|
||||||
|
message: "密码长度为8-16位,必须包含大写字母、小写字母、数字和特殊符号(!#@*&)",
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(_, value) {
|
||||||
|
if (!value || value !== getFieldValue("password")) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error("新密码不能与原密码相同"));
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input.Password
|
||||||
|
autoComplete="new-password"
|
||||||
|
maxLength={16}
|
||||||
|
placeholder="请输入新密码"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="确认新密码"
|
||||||
|
name="confirmPassword"
|
||||||
|
dependencies={["newPassword"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "请再次输入新密码",
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(_, value) {
|
||||||
|
if (!value || value === getFieldValue("newPassword")) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error("两次输入的新密码不一致"));
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input.Password
|
||||||
|
autoComplete="new-password"
|
||||||
|
maxLength={16}
|
||||||
|
placeholder="请再次输入新密码"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item wrapperCol={{ offset: 8, span: 10 }}>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
htmlType="submit"
|
||||||
|
loading={submitting}
|
||||||
|
>
|
||||||
|
确认修改
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Connect([NS_USER], true)(ChangePassword);
|
||||||
|
|
@ -95,7 +95,7 @@ function Add(props) {
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
name: data.name,
|
name: data.name,
|
||||||
url: process.env.app["fileUrl"] + data.userAvatarUrl,
|
url: window.fileUrl + data.userAvatarUrl,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue