From 65e321b0c013ea1679cdf602b49ab2a704180293 Mon Sep 17 00:00:00 2001 From: wuyize Date: Thu, 5 Jan 2023 13:10:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E8=8F=9C=E5=8D=95=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E6=80=BB=E7=BB=8F=E7=90=86=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/HomeView.tsx | 27 ++++++++++++++++++--------- src/pages/login/LoginView.tsx | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/pages/HomeView.tsx b/src/pages/HomeView.tsx index d1577ac..61dd0f8 100644 --- a/src/pages/HomeView.tsx +++ b/src/pages/HomeView.tsx @@ -69,6 +69,8 @@ function HeaderBar(props: any) { ]; const departmentToString = (staff: Staff) => { + if(token.staffId==='manager') + return '总经理' let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管' for (const department of staff.staffDepartments) { result += '\xa0\xa0' + department.departmentName @@ -115,7 +117,7 @@ function MainMenu(props: any) { ) @@ -125,8 +127,7 @@ function HomeView() { const token = useAppSelector(getToken); const navigate = useNavigate(); const location = useLocation() - const dispatch = useAppDispatch(); - console.log(store.getState()) + const dispatch = useAppDispatch() let items = [{ key: "/invoice/mine", @@ -157,7 +158,7 @@ function HomeView() { token: {colorBgContainer, colorPrimary}, } = theme.useToken(); - const [menuItems, setMenuItems] = useState(items.slice(0, 2)) + const [menuItems, setMenuItems] = useState([]) const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(['']) const getStaffInfo = () => { @@ -170,19 +171,24 @@ function HomeView() { dispatch(setStaff(staff)) if (location.pathname === '/') - navigate('/invoice/mine') + { + if(token.staffId==='manager') + navigate('/reimbursement/approval') + else + navigate('/invoice/mine') + } - if (staff.managingDepartment) { - // @ts-ignore + if(token.staffId==='manager') { + setMenuItems(items.slice(3, 6)) + } else if (staff.managingDepartment) { if (staff.managingDepartment.departmentId === 1) { - setMenuItems(items) + setMenuItems(items.slice(0, 5)) } else { setMenuItems(items.slice(0, 4)) } } else { setMenuItems(items.slice(0, 2)) } - setDefaultSelectedKeys([location.pathname]) }).catch(function (error) { console.log(error) @@ -196,6 +202,9 @@ function HomeView() { getStaffInfo() }, []); + useEffect(() => { + setDefaultSelectedKeys([location.pathname]) + }, [location.pathname]); return (