更新了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},
@ -67,11 +66,10 @@ 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,13 +104,16 @@ function HeaderBar(props: any) {
function MyMenu(props: any) { function MyMenu(props: any) {
console.log(props) console.log(props)
return ( if (props.defaultSelectedKeys[0] === '')
<Menu return null
mode="inline" else
defaultSelectedKeys={props.defaultSelectedKeys} return (
items={props.items} <Menu
/> mode="inline"
) defaultSelectedKeys={props.defaultSelectedKeys}
items={props.items}
/>
)
} }
function HomeView() { function HomeView() {
@ -154,34 +155,31 @@ function HomeView() {
staffDepartments: [] staffDepartments: []
}) })
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)
const staff = response.data const staff = response.data
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 {
setMenuItems(items.slice(0, 4))
} }
else{ } else {
setMenuItems(items.slice(0,4)) setMenuItems(items.slice(0, 2))
}
}
else {
setMenuItems(items.slice(0,2))
} }
setDefaultSelectedKeys([location.pathname])
}).catch(function (error) { }).catch(function (error) {
console.log(error) console.log(error)