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 | 68 | menu: Array<string>; | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | +export interface ChangeAccountParams { | |
| 72 | + userId?:string; | |
| 73 | + password?:string; | |
| 74 | + resetPassword?:string; | |
| 75 | +} | |
| 76 | + | |
| 71 | 77 | export class RoleOrGroupParam{ | 
| 72 | 78 | userId:string; | 
| 73 | 79 | queryRole:boolean; | 
| ... | ... | @@ -93,3 +99,4 @@ export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>; | 
| 93 | 99 | export type RoleListGetResultModel = RoleListItem[]; | 
| 94 | 100 | |
| 95 | 101 | export type AccountListModel = AccountListItem; | 
| 102 | + | ... | ... | 
| ... | ... | @@ -8,7 +8,12 @@ import { | 
| 8 | 8 | DeptListGetResultModel, | 
| 9 | 9 | AccountListGetResultModel, | 
| 10 | 10 | RolePageListGetResultModel, | 
| 11 | - RoleListGetResultModel, RoleReqDTO, AccountListItem, AccountListModel, RoleOrGroupParam, | |
| 11 | + RoleListGetResultModel, | |
| 12 | + RoleReqDTO, | |
| 13 | + AccountListItem, | |
| 14 | + AccountListModel, | |
| 15 | + RoleOrGroupParam, | |
| 16 | + ChangeAccountParams, | |
| 12 | 17 | } from './model/systemModel'; | 
| 13 | 18 | import {defHttp} from '/@/utils/http/axios'; | 
| 14 | 19 | |
| ... | ... | @@ -96,3 +101,13 @@ export const findCurrentUserRelation=(params:RoleOrGroupParam)=> | 
| 96 | 101 | url: Api.BaseUserUrl+"/relation", | 
| 97 | 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 | 13 | import { defineComponent } from 'vue'; | 
| 14 | 14 | import { PageWrapper } from '/@/components/Page'; | 
| 15 | 15 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 16 | - | |
| 16 | + import {USER_INFO_KEY} from "/@/enums/cacheEnum"; | |
| 17 | + import {getAuthCache} from "/@/utils/auth"; | |
| 17 | 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 | 25 | export default defineComponent({ | 
| 19 | 26 | name: 'ChangePassword', | 
| 20 | 27 | components: { BasicForm, PageWrapper }, | 
| ... | ... | @@ -25,16 +32,36 @@ | 
| 25 | 32 | showActionButtonGroup: false, | 
| 26 | 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 | 42 | async function handleSubmit() { | 
| 30 | 43 | try { | 
| 31 | 44 | const values = await validate(); | 
| 32 | 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 | 65 | } catch (error) {} | 
| 39 | 66 | } | 
| 40 | 67 | ... | ... | 
| 1 | 1 | import { FormSchema } from '/@/components/Form'; | 
| 2 | - | |
| 2 | +import {InputRegExp} from "/@/enums/regexpEnum"; | |
| 3 | 3 | export const formSchema: FormSchema[] = [ | 
| 4 | 4 | { | 
| 5 | 5 | field: 'passwordOld', | 
| ... | ... | @@ -37,6 +37,11 @@ export const formSchema: FormSchema[] = [ | 
| 37 | 37 | if (value !== values.passwordNew) { | 
| 38 | 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 | 45 | return Promise.resolve(); | 
| 41 | 46 | }, | 
| 42 | 47 | }, | ... | ... |