Commit a1dee94b175a212cd91b6765cfd97c1087be74ee
1 parent
c7b48a75
feat(front): 添加修改密码【待完善初始设置时,直接设置密码】
Showing
5 changed files
with
68 additions
and
8 deletions
@@ -68,6 +68,12 @@ export interface RoleReqDTO { | @@ -68,6 +68,12 @@ export interface RoleReqDTO { | ||
68 | menu: Array<string>; | 68 | menu: Array<string>; |
69 | } | 69 | } |
70 | 70 | ||
71 | +export interface ChangeAccountParams { | ||
72 | + userId?:string; | ||
73 | + password?:string; | ||
74 | + resetPassword?:string; | ||
75 | +} | ||
76 | + | ||
71 | export class RoleOrGroupParam{ | 77 | export class RoleOrGroupParam{ |
72 | userId:string; | 78 | userId:string; |
73 | queryRole:boolean; | 79 | queryRole:boolean; |
@@ -93,3 +99,4 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; | @@ -93,3 +99,4 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; | ||
93 | export type RoleListGetResultModel = RoleListItem[]; | 99 | export type RoleListGetResultModel = RoleListItem[]; |
94 | 100 | ||
95 | export type AccountListModel = AccountListItem; | 101 | export type AccountListModel = AccountListItem; |
102 | + |
@@ -8,7 +8,12 @@ import { | @@ -8,7 +8,12 @@ import { | ||
8 | DeptListGetResultModel, | 8 | DeptListGetResultModel, |
9 | AccountListGetResultModel, | 9 | AccountListGetResultModel, |
10 | RolePageListGetResultModel, | 10 | RolePageListGetResultModel, |
11 | - RoleListGetResultModel, RoleReqDTO, AccountListItem, AccountListModel, RoleOrGroupParam, | 11 | + RoleListGetResultModel, |
12 | + RoleReqDTO, | ||
13 | + AccountListItem, | ||
14 | + AccountListModel, | ||
15 | + RoleOrGroupParam, | ||
16 | + ChangeAccountParams, | ||
12 | } from './model/systemModel'; | 17 | } from './model/systemModel'; |
13 | import {defHttp} from '/@/utils/http/axios'; | 18 | import {defHttp} from '/@/utils/http/axios'; |
14 | 19 | ||
@@ -96,3 +101,13 @@ export const findCurrentUserRelation=(params:RoleOrGroupParam)=> | @@ -96,3 +101,13 @@ export const findCurrentUserRelation=(params:RoleOrGroupParam)=> | ||
96 | url: Api.BaseUserUrl+"/relation", | 101 | url: Api.BaseUserUrl+"/relation", |
97 | params:params | 102 | params:params |
98 | }); | 103 | }); |
104 | + | ||
105 | +/** | ||
106 | + * 修改密码 | ||
107 | + * @param params | ||
108 | + */ | ||
109 | +export const resetPassword=(params:ChangeAccountParams)=> | ||
110 | + defHttp.post({ | ||
111 | + url: Api.BaseUserUrl + "/reset", | ||
112 | + params:params | ||
113 | + }); |
src/enums/regexpEnum.ts
0 → 100644
@@ -13,8 +13,15 @@ | @@ -13,8 +13,15 @@ | ||
13 | import { defineComponent } from 'vue'; | 13 | import { defineComponent } from 'vue'; |
14 | import { PageWrapper } from '/@/components/Page'; | 14 | import { PageWrapper } from '/@/components/Page'; |
15 | import { BasicForm, useForm } from '/@/components/Form'; | 15 | import { BasicForm, useForm } from '/@/components/Form'; |
16 | - | 16 | + import {USER_INFO_KEY} from "/@/enums/cacheEnum"; |
17 | + import {getAuthCache} from "/@/utils/auth"; | ||
17 | import { formSchema } from './pwd.data'; | 18 | import { formSchema } from './pwd.data'; |
19 | + import {resetPassword} from "/@/api/system/system"; | ||
20 | + import {useMultipleTabStore} from "/@/store/modules/multipleTab"; | ||
21 | + import {useUserStore} from "/@/store/modules/user"; | ||
22 | + import {useAppStore} from "/@/store/modules/app"; | ||
23 | + import {usePermissionStore} from "/@/store/modules/permission"; | ||
24 | + import {useMessage} from "/@/hooks/web/useMessage"; | ||
18 | export default defineComponent({ | 25 | export default defineComponent({ |
19 | name: 'ChangePassword', | 26 | name: 'ChangePassword', |
20 | components: { BasicForm, PageWrapper }, | 27 | components: { BasicForm, PageWrapper }, |
@@ -25,16 +32,36 @@ | @@ -25,16 +32,36 @@ | ||
25 | showActionButtonGroup: false, | 32 | showActionButtonGroup: false, |
26 | schemas: formSchema, | 33 | schemas: formSchema, |
27 | }); | 34 | }); |
28 | - | 35 | + const tabStore = useMultipleTabStore(); |
36 | + const userStore = useUserStore(); | ||
37 | + const appStore = useAppStore(); | ||
38 | + const permissionStore = usePermissionStore(); | ||
39 | + const {createMessage} = useMessage(); | ||
40 | + const userInfo = getAuthCache(USER_INFO_KEY); | ||
41 | + console.log(userInfo,"userInfo") | ||
29 | async function handleSubmit() { | 42 | async function handleSubmit() { |
30 | try { | 43 | try { |
31 | const values = await validate(); | 44 | const values = await validate(); |
32 | const { passwordOld, passwordNew } = values; | 45 | const { passwordOld, passwordNew } = values; |
46 | + const params = { | ||
47 | + userId:userInfo.userId, | ||
48 | + password:passwordOld, | ||
49 | + resetPassword:passwordNew | ||
50 | + }; | ||
33 | 51 | ||
34 | - // TODO custom api | ||
35 | - console.log(passwordOld, passwordNew); | ||
36 | - // const { router } = useRouter(); | ||
37 | - // router.push(pageEnum.BASE_LOGIN); | 52 | + await resetPassword(params).then((result)=>{ |
53 | + if(result.data){ | ||
54 | + createMessage.success("修改成功"); | ||
55 | + setTimeout(function (){ | ||
56 | + localStorage.clear(); | ||
57 | + appStore.resetAllState(); | ||
58 | + permissionStore.resetState(); | ||
59 | + tabStore.resetState(); | ||
60 | + userStore.resetState(); | ||
61 | + location.reload(); | ||
62 | + },500) | ||
63 | + } | ||
64 | + }); | ||
38 | } catch (error) {} | 65 | } catch (error) {} |
39 | } | 66 | } |
40 | 67 |
1 | import { FormSchema } from '/@/components/Form'; | 1 | import { FormSchema } from '/@/components/Form'; |
2 | - | 2 | +import {InputRegExp} from "/@/enums/regexpEnum"; |
3 | export const formSchema: FormSchema[] = [ | 3 | export const formSchema: FormSchema[] = [ |
4 | { | 4 | { |
5 | field: 'passwordOld', | 5 | field: 'passwordOld', |
@@ -37,6 +37,11 @@ export const formSchema: FormSchema[] = [ | @@ -37,6 +37,11 @@ export const formSchema: FormSchema[] = [ | ||
37 | if (value !== values.passwordNew) { | 37 | if (value !== values.passwordNew) { |
38 | return Promise.reject('两次输入的密码不一致!'); | 38 | return Promise.reject('两次输入的密码不一致!'); |
39 | } | 39 | } |
40 | + | ||
41 | + const pwdRegex = new RegExp(InputRegExp.PASSWORD_INPUT); | ||
42 | + if(!pwdRegex.test(value)){ | ||
43 | + return Promise.reject('密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符'); | ||
44 | + } | ||
40 | return Promise.resolve(); | 45 | return Promise.resolve(); |
41 | }, | 46 | }, |
42 | }, | 47 | }, |