新增了个人中心
parent
d8b146a7a0
commit
ed5abb7b95
@ -0,0 +1,34 @@
|
|||||||
|
import httpClient from '@/utils/axios'
|
||||||
|
import type { ApiResult } from '@/api/types'
|
||||||
|
|
||||||
|
import type { SysPassDTO, SysConfigurationDTO } from '@/api/personCenter/types'
|
||||||
|
/**
|
||||||
|
* 个人中心修改密码
|
||||||
|
* @param passDto 修改密码对象
|
||||||
|
*/
|
||||||
|
export function updatePass(passDto: SysPassDTO) {
|
||||||
|
return httpClient.put<ApiResult<void>>(`/system/user/pass/${passDto.userId}`, {
|
||||||
|
oldPass: passDto.oldPass,
|
||||||
|
pass: passDto.pass,
|
||||||
|
confirmPass: passDto.confirmPass
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 个人中心
|
||||||
|
* @param saveConfigurationDto 个人中心对象
|
||||||
|
*/
|
||||||
|
export function saveConfiguration(saveConfigurationDto: SysConfigurationDTO) {
|
||||||
|
return httpClient.put<ApiResult<void>>(`system/user`, {
|
||||||
|
gender: saveConfigurationDto.gender,
|
||||||
|
userId: saveConfigurationDto.userId,
|
||||||
|
nickname: saveConfigurationDto.nickname,
|
||||||
|
phone: saveConfigurationDto.phone,
|
||||||
|
username: saveConfigurationDto.username
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取指定用户的基本信息
|
||||||
|
*/
|
||||||
|
export function getUserInfo(userId: number | undefined) {
|
||||||
|
return httpClient.get<ApiResult>(`system/user/${userId}`)
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
//个人中心修改密码
|
||||||
|
export interface SysPassDTO {
|
||||||
|
userId: number | undefined
|
||||||
|
oldPass: string
|
||||||
|
pass: string
|
||||||
|
confirmPass: string
|
||||||
|
}
|
||||||
|
|
||||||
|
//个人中心保存配置
|
||||||
|
export interface SysConfigurationDTO {
|
||||||
|
gender: number | undefined
|
||||||
|
userId: number | undefined
|
||||||
|
// jobNumber: number
|
||||||
|
nickname: string | undefined
|
||||||
|
phone: string | undefined
|
||||||
|
username: string | undefined
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,145 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal
|
||||||
|
:title="title"
|
||||||
|
:visible="visible"
|
||||||
|
:mask-closable="false"
|
||||||
|
:body-style="{ paddingBottom: '8px' }"
|
||||||
|
:confirm-loading="submitLoading"
|
||||||
|
:width="500"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
@cancel="handleClose"
|
||||||
|
>
|
||||||
|
<a-form :model="formModel" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||||
|
<a-form-item label="旧密码" v-bind="validateInfos.oldPass">
|
||||||
|
<a-input-password v-model:value="formModel.oldPass" type="password" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="新密码" v-bind="validateInfos.pass">
|
||||||
|
<a-input-password v-model:value="formModel.pass" type="password" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="确认密码" v-bind="validateInfos.confirmPass">
|
||||||
|
<a-input-password v-model:value="formModel.confirmPass" type="password" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
// import { overrideProperties } from '@/utils/bean-utils'
|
||||||
|
import { passEncrypt } from '@/utils/password-utils'
|
||||||
|
import { useAdminForm, useFormAction, FormAction, labelCol, wrapperCol } from '@/hooks/form'
|
||||||
|
import type { FormRequestMapping } from '@/hooks/form'
|
||||||
|
import { useModal } from '@/hooks/modal'
|
||||||
|
//修改密码
|
||||||
|
import { updatePass } from '@/api/personCenter'
|
||||||
|
import type { SysPassDTO } from '@/api/personCenter/types'
|
||||||
|
|
||||||
|
const emits = defineEmits<{
|
||||||
|
(e: 'submit-success'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { title, visible, openModal, closeModal } = useModal()
|
||||||
|
|
||||||
|
const { formAction, isCreateForm, isUpdateForm } = useFormAction()
|
||||||
|
|
||||||
|
interface formModelItem {
|
||||||
|
userId: number | undefined
|
||||||
|
oldPass: string
|
||||||
|
pass: string
|
||||||
|
confirmPass: string
|
||||||
|
}
|
||||||
|
// 表单模型
|
||||||
|
const formModel = reactive<formModelItem>({
|
||||||
|
userId: undefined,
|
||||||
|
oldPass: '',
|
||||||
|
pass: '',
|
||||||
|
confirmPass: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表单的校验规则
|
||||||
|
interface formRuleItem {
|
||||||
|
oldPass: Array<object>
|
||||||
|
pass: Array<object>
|
||||||
|
confirmPass: Array<object>
|
||||||
|
}
|
||||||
|
const confirmPass = (rule: any, value: any, callback: any) => {
|
||||||
|
if (value) {
|
||||||
|
if (formModel.pass !== value) {
|
||||||
|
callback(new Error('两次输入的密码不一致'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback(new Error('请再次输入密码'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 表单校验规则
|
||||||
|
const formRule = ref<formRuleItem>({
|
||||||
|
oldPass: [{ required: true, message: '请输入旧密码', trigger: 'blur' }],
|
||||||
|
pass: [
|
||||||
|
{ required: true, message: '请输入新密码', trigger: 'blur' },
|
||||||
|
{ min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
confirmPass: [{ required: true, validator: confirmPass, trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表单的提交请求
|
||||||
|
const formRequestMapping: FormRequestMapping<SysPassDTO> = {
|
||||||
|
[FormAction.CREATE]: updatePass
|
||||||
|
// [FormAction.UPDATE]: updatePass
|
||||||
|
}
|
||||||
|
|
||||||
|
const { submitLoading, validateAndSubmit, resetFields, validateInfos } = useAdminForm(
|
||||||
|
formAction,
|
||||||
|
formRequestMapping,
|
||||||
|
formModel,
|
||||||
|
formRule
|
||||||
|
)
|
||||||
|
|
||||||
|
/* 表单提交处理 */
|
||||||
|
const handleSubmit = () => {
|
||||||
|
validateAndSubmit(
|
||||||
|
{
|
||||||
|
...formModel,
|
||||||
|
oldPass: passEncrypt(formModel.oldPass),
|
||||||
|
pass: passEncrypt(formModel.pass),
|
||||||
|
confirmPass: passEncrypt(formModel.confirmPass)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
closeModal()
|
||||||
|
emits('submit-success')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 弹窗关闭方法 */
|
||||||
|
const handleClose = () => {
|
||||||
|
closeModal()
|
||||||
|
submitLoading.value = false
|
||||||
|
}
|
||||||
|
// interface recordItem{
|
||||||
|
// userId:
|
||||||
|
// }
|
||||||
|
defineExpose({
|
||||||
|
open(newFormAction: FormAction, record: number | undefined) {
|
||||||
|
openModal()
|
||||||
|
resetFields()
|
||||||
|
if (newFormAction === FormAction.CREATE) {
|
||||||
|
title.value = '修改密码'
|
||||||
|
}
|
||||||
|
formModel.userId = record
|
||||||
|
// else {
|
||||||
|
// title.value = '编辑用户'
|
||||||
|
// formRule.value = {
|
||||||
|
// username: [{ required: true, message: '请输入用户名!' }],
|
||||||
|
// nickname: [{ required: true, message: '请输入昵称!' }]
|
||||||
|
// }
|
||||||
|
// overrideProperties(formModel, record)
|
||||||
|
// }
|
||||||
|
formAction.value = newFormAction
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
@ -0,0 +1 @@
|
|||||||
|
declare module 'vue-image-crop-upload'
|
@ -1,23 +1,13 @@
|
|||||||
{
|
{
|
||||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
"include": [
|
"include": ["types/**/*.ts", "src/**/*", "src/**/*.vue", "vite.config.ts"],
|
||||||
"types/**/*.ts",
|
"exclude": ["src/**/__tests__/*"],
|
||||||
"src/**/*",
|
|
||||||
"src/**/*.vue"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"src/**/__tests__/*"
|
|
||||||
],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": ["./src/*"],
|
||||||
"./src/*"
|
"#/*": ["./pro-components/*"]
|
||||||
],
|
}
|
||||||
"#/*": [
|
|
||||||
"./pro-components/*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue