修改密码页面添加

This commit is contained in:
2026-08-27 16:43:26 +08:00
parent f850774d65
commit 97a0465890
9 changed files with 132 additions and 26 deletions
@@ -33,9 +33,9 @@ type DropdownOption =
const options = computed(() => {
const opts: DropdownOption[] = [
{
label: '个人中心',
label: '修改密码',
key: 'user-center',
icon: SvgIconVNode({ icon: 'ph:user-circle', fontSize: 18 })
icon: SvgIconVNode({ icon: 'boxicons:lock-open', fontSize: 18 })
},
{
type: 'divider',
@@ -67,8 +67,7 @@ function handleDropdown(key: DropdownKey) {
if (key === 'logout') {
logout();
} else {
// If your other options are jumps from other routes, they will be directly supported here
// routerPushByKey(key);
routerPushByKey('systemmanage_changepassword');
}
}
</script>
+2 -1
View File
@@ -255,7 +255,8 @@ const local: App.I18n.Schema = {
report: '统计报表',
signstatistics: '质量会签统计',
factoryoverview: '全工厂统计概览',
systemmanage_setting: '系统配置'
systemmanage_setting: '系统配置',
systemmanage_changepassword: '修改密码'
},
form: {
required: '不能为空',
+1
View File
@@ -42,6 +42,7 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
report: () => import("@/views/report/index.vue"),
riskstatistics: () => import("@/views/riskStatistics/index.vue"),
signstatistics: () => import("@/views/signStatistics/index.vue"),
systemmanage_changepassword: () => import("@/views/systemManage/changePassword/index.vue"),
systemmanage_role: () => import("@/views/systemManage/role/index.vue"),
systemmanage_setting: () => import("@/views/systemManage/setting/index.vue"),
systemmanage_template: () => import("@/views/systemManage/template/index.vue"),
+10 -21
View File
@@ -56,7 +56,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.changeledger_mychanges',
meta: {
title: '我发起的变更',
icon: '',
i18nKey: 'route.changeledger_mychanges'
}
},
@@ -66,7 +65,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.changeledger_workshopchanges',
meta: {
title: '本车间变更',
icon: '',
i18nKey: 'route.changeledger_workshopchanges'
}
}
@@ -100,7 +98,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.docs_archives',
meta: {
title: '资料档案库',
icon: '',
i18nKey: 'route.docs_archives'
}
},
@@ -110,7 +107,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.docs_query',
meta: {
title: '变更归档查询',
icon: '',
i18nKey: 'route.docs_query'
}
}
@@ -167,7 +163,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_closeconfirm',
meta: {
title: '关闭确认',
icon: '',
i18nKey: 'route.my_closeconfirm'
}
},
@@ -177,7 +172,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_datachangecenter',
meta: {
title: '变更数据中心',
icon: '',
i18nKey: 'route.my_datachangecenter'
}
},
@@ -187,7 +181,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_effect',
meta: {
title: '变更投入和效果',
icon: '',
i18nKey: 'route.my_effect'
}
},
@@ -197,7 +190,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_highrisk',
meta: {
title: '本专业高风险',
icon: '',
i18nKey: 'route.my_highrisk'
}
},
@@ -207,7 +199,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_highriskdetail',
meta: {
title: '高风险场景详情',
icon: '',
hideInMenu: true,
i18nKey: 'route.my_highriskdetail'
}
@@ -218,7 +209,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_initiatechange',
meta: {
title: '发起变更',
icon: '',
i18nKey: 'route.my_initiatechange'
}
},
@@ -228,7 +218,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_mydraft',
meta: {
title: '我的草稿',
icon: '',
i18nKey: 'route.my_mydraft'
}
},
@@ -238,7 +227,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_mytask',
meta: {
title: '我的任务',
icon: '',
i18nKey: 'route.my_mytask'
}
},
@@ -248,7 +236,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_pending',
meta: {
title: '待我处理',
icon: '',
i18nKey: 'route.my_pending'
}
},
@@ -258,7 +245,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_pendingchange',
meta: {
title: '待投用变更',
icon: '',
i18nKey: 'route.my_pendingchange'
}
},
@@ -268,7 +254,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_process',
meta: {
title: '流程演示',
icon: '',
i18nKey: 'route.my_process'
}
},
@@ -278,7 +263,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_processdetail',
meta: {
title: '流程演示详情',
icon: '',
hideInMenu: true,
i18nKey: 'route.my_processdetail'
}
@@ -289,7 +273,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.my_pssr',
meta: {
title: 'PSSR监督',
icon: '',
i18nKey: 'route.my_pssr'
}
}
@@ -339,13 +322,22 @@ export const generatedRoutes: GeneratedRoute[] = [
i18nKey: 'route.systemmanage'
},
children: [
{
name: 'systemmanage_changepassword',
path: '/systemmanage/changepassword',
component: 'view.systemmanage_changepassword',
meta: {
title: '修改密码',
i18nKey: 'route.systemmanage_changepassword',
order: 5
}
},
{
name: 'systemmanage_role',
path: '/systemmanage/role',
component: 'view.systemmanage_role',
meta: {
title: '角色管理',
icon: '',
order: 2,
i18nKey: 'route.systemmanage_role'
}
@@ -356,7 +348,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.systemmanage_setting',
meta: {
title: '系统配置',
icon: '',
order: 4,
i18nKey: 'route.systemmanage_setting'
}
@@ -367,7 +358,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.systemmanage_template',
meta: {
title: '审批模板管理',
icon: '',
order: 3,
i18nKey: 'route.systemmanage_template'
}
@@ -378,7 +368,6 @@ export const generatedRoutes: GeneratedRoute[] = [
component: 'view.systemmanage_user',
meta: {
title: '架构及用户管理',
icon: '',
order: 1,
i18nKey: 'route.systemmanage_user'
}
+1
View File
@@ -194,6 +194,7 @@ const routeMap: RouteMap = {
"riskstatistics": "/riskstatistics",
"signstatistics": "/signstatistics",
"systemmanage": "/systemmanage",
"systemmanage_changepassword": "/systemmanage/changepassword",
"systemmanage_role": "/systemmanage/role",
"systemmanage_setting": "/systemmanage/setting",
"systemmanage_template": "/systemmanage/template",
+9
View File
@@ -100,3 +100,12 @@ export function resetPasswordApi(id: number) {
});
}
// 修改用户密码
export function changePasswordApi(params: { oldPassword: string, password: string }) {
return request({
url: `/api/user/change-password`,
method: 'post',
data: params
});
}
+6
View File
@@ -42,6 +42,7 @@ declare module 'vue' {
NCascader: typeof import('naive-ui')['NCascader']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
NCol: typeof import('naive-ui')['NCol']
NColorPicker: typeof import('naive-ui')['NColorPicker']
NDataTable: typeof import('naive-ui')['NDataTable']
NDatePicker: typeof import('naive-ui')['NDatePicker']
@@ -64,6 +65,7 @@ declare module 'vue' {
NMenu: typeof import('naive-ui')['NMenu']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NNInput: typeof import('naive-ui')['NNInput']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NPagination: typeof import('naive-ui')['NPagination']
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
@@ -71,6 +73,7 @@ declare module 'vue' {
NProgress: typeof import('naive-ui')['NProgress']
NRadio: typeof import('naive-ui')['NRadio']
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NRow: typeof import('naive-ui')['NRow']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSelect: typeof import('naive-ui')['NSelect']
NSpace: typeof import('naive-ui')['NSpace']
@@ -132,6 +135,7 @@ declare global {
const NCascader: typeof import('naive-ui')['NCascader']
const NCheckbox: typeof import('naive-ui')['NCheckbox']
const NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
const NCol: typeof import('naive-ui')['NCol']
const NColorPicker: typeof import('naive-ui')['NColorPicker']
const NDataTable: typeof import('naive-ui')['NDataTable']
const NDatePicker: typeof import('naive-ui')['NDatePicker']
@@ -154,6 +158,7 @@ declare global {
const NMenu: typeof import('naive-ui')['NMenu']
const NMessageProvider: typeof import('naive-ui')['NMessageProvider']
const NModal: typeof import('naive-ui')['NModal']
const NNInput: typeof import('naive-ui')['NNInput']
const NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
const NPagination: typeof import('naive-ui')['NPagination']
const NPopconfirm: typeof import('naive-ui')['NPopconfirm']
@@ -161,6 +166,7 @@ declare global {
const NProgress: typeof import('naive-ui')['NProgress']
const NRadio: typeof import('naive-ui')['NRadio']
const NRadioGroup: typeof import('naive-ui')['NRadioGroup']
const NRow: typeof import('naive-ui')['NRow']
const NScrollbar: typeof import('naive-ui')['NScrollbar']
const NSelect: typeof import('naive-ui')['NSelect']
const NSpace: typeof import('naive-ui')['NSpace']
+2
View File
@@ -48,6 +48,7 @@ declare module "@elegant-router/types" {
"riskstatistics": "/riskstatistics";
"signstatistics": "/signstatistics";
"systemmanage": "/systemmanage";
"systemmanage_changepassword": "/systemmanage/changepassword";
"systemmanage_role": "/systemmanage/role";
"systemmanage_setting": "/systemmanage/setting";
"systemmanage_template": "/systemmanage/template";
@@ -140,6 +141,7 @@ declare module "@elegant-router/types" {
| "report"
| "riskstatistics"
| "signstatistics"
| "systemmanage_changepassword"
| "systemmanage_role"
| "systemmanage_setting"
| "systemmanage_template"
@@ -0,0 +1,98 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useAppStore } from '@/store/modules/app';
import { Icon } from '@iconify/vue'
import { useThemeStore } from '@/store/modules/theme';
import { useRouterPush } from '@/hooks/common/router';
import { changePasswordApi } from '@/service/api/user';
const appStore = useAppStore();
const themeStore = useThemeStore();
const { toLogin } = useRouterPush();
const gap = computed(() => (appStore.isMobile ? 0 : 16));
const formModel = ref<{oldPassword: string;password: string;confirmPassword: string;}>({
oldPassword: '',
password: '',
confirmPassword: '',
});
const rules = {
oldPassword: [{ required: true, message: '请输入旧密码', trigger: ['blur'] }],
password: [{ required: true, message: '请输入新密码', trigger: ['blur'] }],
confirmPassword: [{ validator: (rule: any, value: string, callback: any) => {
if (value !== formModel.value.password) {
callback(new Error('两次输入密码不一致'));
} else {
callback();
}
}, required: true, message: '两次输入密码不一致', trigger: ['blur'] }],
}
const formRef = ref<any>(null);
const btnLoading = ref<boolean>(false);
const submitForm = async (e: MouseEvent) => {
e.preventDefault()
formRef.value?.validate(async (errors: any) => {
if (!errors) {
btnLoading.value = true;
const {error} = await changePasswordApi({
oldPassword: formModel.value.oldPassword,
password: formModel.value.password,
});
if(!error){
window.$message?.success('修改成功')
toLogin();
}
btnLoading.value = false;
}
})
}
onMounted(() => {
})
</script>
<template>
<NSpace vertical :size="16">
<!-- 修改密码 -->
<NCard :bordered="false" size="small" :style="{ borderRadius: themeStore.themeRadius + 'px' }">
<div class="border mb-3 py-2 px-3" :style="{ borderRadius: themeStore.themeRadius + 'px' }">
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<NGi span="24 s:24 m:24">
<div class="h-100% flex items-center gap-2">
<Icon icon="boxicons:lock-open" class="size-16px" :style="{ color: themeStore.themeColor }" />
<p class="text-[16px] font-600">修改密码</p>
</div>
</NGi>
</NGrid>
</div>
<div class="scroll">
<div class="mt-5 max-w-[800px] mx-auto">
<NForm ref="formRef" :model="formModel" :rules="rules">
<NFormItem path="oldPassword" label="旧密码">
<NInput v-model:value="formModel.oldPassword" type="password" clearable show-password-on="click" placeholder="请输入旧密码" />
</NFormItem>
<NFormItem path="password" label="新密码">
<NInput v-model:value="formModel.password" type="password" clearable show-password-on="click" placeholder="请输入新密码" />
</NFormItem>
<NFormItem path="confirmPassword" label="确认密码">
<NInput v-model:value="formModel.confirmPassword" type="password" clearable show-password-on="click" placeholder="请确认新密码" />
</NFormItem>
</NForm>
<NButton type="primary" block :loading="btnLoading" @click="submitForm">修改密码</NButton>
</div>
</div>
</NCard>
</NSpace>
</template>
<style scoped lang="scss">
.scroll {
height: calc(100vh - 205px);
overflow-y: auto;
}
</style>