完善了路由
parent
e005d48d56
commit
08b5f2b0a2
|
@ -3,7 +3,7 @@ import {UploadOutlined, UserOutlined, VideoCameraOutlined} from '@ant-design/ico
|
|||
import {Layout, Menu, theme, Typography, Button, Dropdown, MenuProps} from 'antd';
|
||||
import {useAppDispatch, useAppSelector} from "../models/hooks";
|
||||
import {getToken, setToken, store} from "../models/store";
|
||||
import {Link, Outlet, useNavigate} from "react-router-dom";
|
||||
import {Link, Outlet, useLocation, useNavigate} from "react-router-dom";
|
||||
import Icon from '@ant-design/icons';
|
||||
import {Logo} from "../assets/icons";
|
||||
import axiosInstance from "../utils/axiosInstance";
|
||||
|
@ -105,11 +105,11 @@ function HeaderBar(props: any) {
|
|||
}
|
||||
|
||||
function MyMenu(props: any) {
|
||||
|
||||
console.log(props)
|
||||
return (
|
||||
<Menu
|
||||
mode="inline"
|
||||
defaultSelectedKeys={['0']}
|
||||
defaultSelectedKeys={props.defaultSelectedKeys}
|
||||
items={props.items}
|
||||
/>
|
||||
)
|
||||
|
@ -118,28 +118,29 @@ function MyMenu(props: any) {
|
|||
function HomeView() {
|
||||
const token = useAppSelector(getToken);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation()
|
||||
console.log(store.getState())
|
||||
|
||||
let items = [{
|
||||
key: "0",
|
||||
key: "/invoice/mine",
|
||||
//icon: React.createElement(UserOutlined),
|
||||
label: <Link to="/invoice/mine">我的发票</Link>
|
||||
}, {
|
||||
key: "1",
|
||||
key: "/reimbursement/mine",
|
||||
//icon: React.createElement(UserOutlined),
|
||||
label: <Link to="/reimbursement/mine">我的报销</Link>,
|
||||
}, {
|
||||
key: "2",
|
||||
key: "/invoice/management",
|
||||
//icon: React.createElement(UserOutlined),
|
||||
label: <Link to="/reimbursement/mine">报销审批</Link>,
|
||||
label: <Link to="/invoice/management">发票管理</Link>,
|
||||
}, {
|
||||
key: "3",
|
||||
key: "/reimbursement/approval",
|
||||
//icon: React.createElement(UserOutlined),
|
||||
label: <Link to="/reimbursement/mine">发票管理</Link>,
|
||||
label: <Link to="/reimbursement/approval">报销审批</Link>,
|
||||
}, {
|
||||
key: "4",
|
||||
key: "/stat",
|
||||
//icon: React.createElement(UserOutlined),
|
||||
label: <Link to="/reimbursement/mine">财务统计</Link>,
|
||||
label: <Link to="/stat">财务统计</Link>,
|
||||
}]
|
||||
|
||||
const {
|
||||
|
@ -154,6 +155,7 @@ function HomeView() {
|
|||
})
|
||||
|
||||
const [menuItems, setMenuItems] = useState(items.slice(0,2))
|
||||
const [defaultSelectedKeys, setDefaultSelectedKeys] = useState(['/invoice/mine'])
|
||||
|
||||
const getStaffInfo = () => {
|
||||
axiosInstance({
|
||||
|
@ -163,23 +165,24 @@ function HomeView() {
|
|||
console.log(response.data)
|
||||
const staff = response.data
|
||||
setStaff( response.data)
|
||||
if(location.pathname==='/')
|
||||
navigate('/invoice/mine')
|
||||
|
||||
setDefaultSelectedKeys([location.pathname])
|
||||
if(staff.managingDepartment)
|
||||
{
|
||||
// @ts-ignore
|
||||
if(staff.managingDepartment.departmentName==='财务部')
|
||||
if(staff.managingDepartment.departmentId===1)
|
||||
{
|
||||
setMenuItems(items)
|
||||
}
|
||||
else{
|
||||
console.log('aaaaaaaaaaa')
|
||||
setMenuItems(items.slice(0,3))
|
||||
setMenuItems(items.slice(0,4))
|
||||
}
|
||||
}
|
||||
else {
|
||||
setMenuItems(items.slice(0,2))
|
||||
}
|
||||
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
@ -221,7 +224,7 @@ function HomeView() {
|
|||
marginLeft: '4px'
|
||||
}}>智能财务报销系统</span>
|
||||
</div>
|
||||
<MyMenu items={menuItems}/>
|
||||
<MyMenu items={menuItems} defaultSelectedKeys={defaultSelectedKeys}/>
|
||||
</Sider>
|
||||
<Layout>
|
||||
<HeaderBar staff={staff}/>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
function InvoiceManagement() {
|
||||
return(
|
||||
<div>发票管理</div>
|
||||
)
|
||||
}
|
||||
export default InvoiceManagement
|
|
@ -0,0 +1,6 @@
|
|||
function ReimbursementApproval() {
|
||||
return(
|
||||
<div>报销审批</div>
|
||||
)
|
||||
}
|
||||
export default ReimbursementApproval
|
|
@ -0,0 +1,6 @@
|
|||
function StatView() {
|
||||
return(
|
||||
<div>财务统计</div>
|
||||
)
|
||||
}
|
||||
export default StatView
|
|
@ -5,6 +5,9 @@ import HomeView from "../pages/HomeView";
|
|||
import InvoiceListView from "../pages/Invoice/mine/InvoiceListView";
|
||||
import MyReimbursement from "../pages/reimbursement/mine/MyReimbursement";
|
||||
import {BrowserRouter} from "./BrowserRouter"
|
||||
import InvoiceManagement from "../pages/Invoice/management/InvoiceManagement";
|
||||
import ReimbursementApproval from "../pages/reimbursement/approval/ReimbursementApproval";
|
||||
import StatView from "../pages/stat/StatView";
|
||||
|
||||
export const history = createBrowserHistory()
|
||||
|
||||
|
@ -15,6 +18,9 @@ function CustomRouter() {
|
|||
<Route path="/" element={<HomeView/>}>
|
||||
<Route path="invoice/mine" element={<InvoiceListView/>}></Route>
|
||||
<Route path="reimbursement/mine" element={<MyReimbursement/>}></Route>
|
||||
<Route path="invoice/management" element={<InvoiceManagement/>}></Route>
|
||||
<Route path="reimbursement/approval" element={<ReimbursementApproval/>}></Route>
|
||||
<Route path="stat" element={<StatView/>}></Route>
|
||||
</Route>
|
||||
<Route path="/login" element={<LoginView/>}></Route>
|
||||
</Routes>
|
||||
|
|
Loading…
Reference in New Issue