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

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) => { const departmentToString = (staff: Staff) => {
if(token.staffId==='manager')
return '总经理'
let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管' let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管'
for (const department of staff.staffDepartments) { for (const department of staff.staffDepartments) {
result += '\xa0\xa0' + department.departmentName result += '\xa0\xa0' + department.departmentName
@ -115,7 +117,7 @@ function MainMenu(props: any) {
<Menu <Menu
style={{borderInlineEnd: 'unset'}} style={{borderInlineEnd: 'unset'}}
mode="inline" mode="inline"
defaultSelectedKeys={props.defaultSelectedKeys} selectedKeys={props.defaultSelectedKeys}
items={props.items} items={props.items}
/> />
) )
@ -125,8 +127,7 @@ function HomeView() {
const token = useAppSelector(getToken); const token = useAppSelector(getToken);
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation() const location = useLocation()
const dispatch = useAppDispatch(); const dispatch = useAppDispatch()
console.log(store.getState())
let items = [{ let items = [{
key: "/invoice/mine", key: "/invoice/mine",
@ -157,7 +158,7 @@ function HomeView() {
token: {colorBgContainer, colorPrimary}, token: {colorBgContainer, colorPrimary},
} = theme.useToken(); } = theme.useToken();
const [menuItems, setMenuItems] = useState(items.slice(0, 2)) const [menuItems, setMenuItems] = useState<any>([])
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(['']) const [defaultSelectedKeys, setDefaultSelectedKeys] = useState([''])
const getStaffInfo = () => { const getStaffInfo = () => {
@ -170,19 +171,24 @@ function HomeView() {
dispatch(setStaff(staff)) dispatch(setStaff(staff))
if (location.pathname === '/') if (location.pathname === '/')
navigate('/invoice/mine') {
if(token.staffId==='manager')
navigate('/reimbursement/approval')
else
navigate('/invoice/mine')
}
if (staff.managingDepartment) { if(token.staffId==='manager') {
// @ts-ignore setMenuItems(items.slice(3, 6))
} else if (staff.managingDepartment) {
if (staff.managingDepartment.departmentId === 1) { if (staff.managingDepartment.departmentId === 1) {
setMenuItems(items) setMenuItems(items.slice(0, 5))
} else { } else {
setMenuItems(items.slice(0, 4)) setMenuItems(items.slice(0, 4))
} }
} else { } else {
setMenuItems(items.slice(0, 2)) setMenuItems(items.slice(0, 2))
} }
setDefaultSelectedKeys([location.pathname])
}).catch(function (error) { }).catch(function (error) {
console.log(error) console.log(error)
@ -196,6 +202,9 @@ function HomeView() {
getStaffInfo() getStaffInfo()
}, []); }, []);
useEffect(() => {
setDefaultSelectedKeys([location.pathname])
}, [location.pathname]);
return ( return (
<Layout style={{height: '100%'}}> <Layout style={{height: '100%'}}>
<Sider <Sider

View File

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