更新了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;
function HeaderBar(props: any) {
const {
token: {colorBgContainer, colorPrimary},
@ -67,11 +66,10 @@ function HeaderBar(props: any) {
}
];
const departmentToString = (staff:Staff) => {
let result = staff.managingDepartment===null?'':staff.managingDepartment.departmentName+'主管'
for(const department of staff.staffDepartments)
{
result+=' '+department.departmentName
const departmentToString = (staff: Staff) => {
let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管'
for (const department of staff.staffDepartments) {
result += ' ' + department.departmentName
}
return result
}
@ -106,6 +104,9 @@ function HeaderBar(props: any) {
function MyMenu(props: any) {
console.log(props)
if (props.defaultSelectedKeys[0] === '')
return null
else
return (
<Menu
mode="inline"
@ -154,34 +155,31 @@ function HomeView() {
staffDepartments: []
})
const [menuItems, setMenuItems] = useState(items.slice(0,2))
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(['/invoice/mine'])
const [menuItems, setMenuItems] = useState(items.slice(0, 2))
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState([''])
const getStaffInfo = () => {
axiosInstance({
url: 'staff',
url: 'common/staff',
method: 'get'
}).then(response => {
console.log(response.data)
const staff = response.data
setStaff( response.data)
if(location.pathname==='/')
setStaff(response.data)
if (location.pathname === '/')
navigate('/invoice/mine')
setDefaultSelectedKeys([location.pathname])
if(staff.managingDepartment)
{
if (staff.managingDepartment) {
// @ts-ignore
if(staff.managingDepartment.departmentId===1)
{
if (staff.managingDepartment.departmentId === 1) {
setMenuItems(items)
} else {
setMenuItems(items.slice(0, 4))
}
else{
setMenuItems(items.slice(0,4))
}
}
else {
setMenuItems(items.slice(0,2))
} else {
setMenuItems(items.slice(0, 2))
}
setDefaultSelectedKeys([location.pathname])
}).catch(function (error) {
console.log(error)