导航菜单加上总经理的情况

main
wuyize 2023-01-05 13:10:44 +08:00
parent 17b7ec0882
commit 65e321b0c0
2 changed files with 19 additions and 10 deletions

View File

@ -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) {
<Menu
style={{borderInlineEnd: 'unset'}}
mode="inline"
defaultSelectedKeys={props.defaultSelectedKeys}
selectedKeys={props.defaultSelectedKeys}
items={props.items}
/>
)
@ -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<any>([])
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState([''])
const getStaffInfo = () => {
@ -170,19 +171,24 @@ function HomeView() {
dispatch(setStaff(staff))
if (location.pathname === '/')
{
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 (
<Layout style={{height: '100%'}}>
<Sider

View File

@ -28,7 +28,7 @@ function LoginView() {
clientSecret: response.data.clientSecret
}))
//models.commit('setStaff', response.data.data)
navigate('/invoice/mine')
navigate('/')
}).catch(function (error) {
console.log(error);
setAlertMessage(error.response.data.msg)