菜单与 审核按钮,登录新用户修改密码

This commit is contained in:
孙景学
2025-08-05 11:24:32 +08:00
parent d73f2ee647
commit 26722d643d
17 changed files with 260 additions and 91 deletions

View File

@ -1,10 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Card, Row, Col, Spin, message } from 'antd';
import { Column, Pie, Bar } from '@ant-design/charts';
import ChangePasswordModal from './components/ChangePasswordModal';
import {
changePasswordOnFirstLogin,
getYearcountNum,
getAccessTypeCountNum,
getSupplierTypeCountNum,
@ -22,38 +20,6 @@ const HomeDashboard: React.FC = () => {
const [supplierAuditData, setSupplierAuditData] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
// ======= 新增部分:弹窗控制 =======
const [showChangePwd, setShowChangePwd] = useState(false);
useEffect(() => {
// 检查 firstLogin
const userStr = sessionStorage.getItem('currentUser');
if (userStr) {
try {
const userObj = JSON.parse(userStr);
if (userObj?.supplierUser?.firstLogin === 0) {
setShowChangePwd(true);
}
} catch (e) { }
}
}, []);
// 修改密码确认回调
const handleChangePwd = async (values: { userId: string; newPassword: string; confirmPassword: string; }) => {
try {
await changePasswordOnFirstLogin({ ...values });
message.success('密码修改成功,请重新登录');
// 更新缓存 firstLogin=1
const userStr = sessionStorage.getItem('currentUser');
if (userStr) {
const userObj = JSON.parse(userStr);
if (userObj?.supplierUser) userObj.supplierUser.firstLogin = 1;
sessionStorage.setItem('currentUser', JSON.stringify(userObj));
}
setShowChangePwd(false);
} catch (e: any) {
message.error(e?.message || '修改密码失败');
}
};
useEffect(() => {
setLoading(true);
@ -193,19 +159,6 @@ const HomeDashboard: React.FC = () => {
return (
<>
<ChangePasswordModal
visible={showChangePwd}
onOk={handleChangePwd}
onCancel={() => {
setShowChangePwd(false)
const userStr = sessionStorage.getItem('currentUser');
if (userStr) {
const userObj = JSON.parse(userStr);
if (userObj?.supplierUser) userObj.supplierUser.firstLogin = 1;
sessionStorage.setItem('currentUser', JSON.stringify(userObj));
}
}}
/>
<Spin spinning={loading}>
<Row gutter={[24, 24]}>
{/* 第一行3图 */}

View File

@ -1,18 +1,5 @@
import request from '@/utils/request';
/**
*
* @param params
* @returns
*
*/
interface PasswordOnFirstLogin {
userId:string;
newPassword:string;
confirmPassword:string;
}
export const changePasswordOnFirstLogin = (data:PasswordOnFirstLogin) => request.post(`/v1/login/supplier/changePasswordOnFirstLogin`, { data});
/**
*
* @param params