更新了staff接口

main
wuyize 2022-12-30 16:59:38 +08:00
parent 2ad5c124b0
commit 006ce5cf70
1 changed files with 27 additions and 29 deletions

View File

@ -13,7 +13,6 @@ const {Title} = Typography;
const {Header, Content, Footer, Sider} = Layout; const {Header, Content, Footer, Sider} = Layout;
function HeaderBar(props: any) { function HeaderBar(props: any) {
const { const {
token: {colorBgContainer, colorPrimary}, token: {colorBgContainer, colorPrimary},
@ -69,8 +68,7 @@ function HeaderBar(props: any) {
const departmentToString = (staff: Staff) => { const departmentToString = (staff: Staff) => {
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 += ' ' + department.departmentName result += ' ' + department.departmentName
} }
return result return result
@ -106,6 +104,9 @@ function HeaderBar(props: any) {
function MyMenu(props: any) { function MyMenu(props: any) {
console.log(props) console.log(props)
if (props.defaultSelectedKeys[0] === '')
return null
else
return ( return (
<Menu <Menu
mode="inline" mode="inline"
@ -155,11 +156,11 @@ function HomeView() {
}) })
const [menuItems, setMenuItems] = useState(items.slice(0, 2)) const [menuItems, setMenuItems] = useState(items.slice(0, 2))
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(['/invoice/mine']) const [defaultSelectedKeys, setDefaultSelectedKeys] = useState([''])
const getStaffInfo = () => { const getStaffInfo = () => {
axiosInstance({ axiosInstance({
url: 'staff', url: 'common/staff',
method: 'get' method: 'get'
}).then(response => { }).then(response => {
console.log(response.data) console.log(response.data)
@ -167,21 +168,18 @@ function HomeView() {
setStaff(response.data) setStaff(response.data)
if (location.pathname === '/') if (location.pathname === '/')
navigate('/invoice/mine') navigate('/invoice/mine')
setDefaultSelectedKeys([location.pathname])
if(staff.managingDepartment) if (staff.managingDepartment) {
{
// @ts-ignore // @ts-ignore
if(staff.managingDepartment.departmentId===1) if (staff.managingDepartment.departmentId === 1) {
{
setMenuItems(items) setMenuItems(items)
} } 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)