diff --git a/src/pages/HomeView.tsx b/src/pages/HomeView.tsx index 61dd0f8..fadd67c 100644 --- a/src/pages/HomeView.tsx +++ b/src/pages/HomeView.tsx @@ -1,5 +1,5 @@ import React, {useState, useEffect} from 'react'; -import {UploadOutlined, UserOutlined, VideoCameraOutlined} from '@ant-design/icons'; +import {UploadOutlined, UserOutlined, BellOutlined} from '@ant-design/icons'; import {Layout, Menu, theme, Typography, Button, Dropdown, MenuProps} from 'antd'; import {useAppDispatch, useAppSelector} from "../models/hooks"; import {getStaff, getToken, setStaff, setToken, store} from "../models/store"; @@ -69,7 +69,7 @@ function HeaderBar(props: any) { ]; const departmentToString = (staff: Staff) => { - if(token.staffId==='manager') + if (token.staffId === 'manager') return '总经理' let result = staff.managingDepartment === null ? '' : staff.managingDepartment.departmentName + '主管' for (const department of staff.staffDepartments) { @@ -84,26 +84,39 @@ function HeaderBar(props: any) { padding: 0, background: colorBgContainer, display: 'flex', - flexDirection: 'row-reverse', + flexDirection: 'row', + justifyContent: "space-between", alignItems: 'center', zIndex: 100, boxShadow: '0px 6px 16px 0px rgba(0, 0, 0, 0.08)' }}> - - + + - + {departmentToString(staff)} + {staff.staffName} +
+ {staff.staffName[0]} +
+ +
+ + ) } @@ -129,6 +142,53 @@ function HomeView() { const location = useLocation() const dispatch = useAppDispatch() + const [messageCount, setMessageCount] = useState([]) + + // 新建Sse连接 + const createSseConnect = () => { + if (window.EventSource) { + + let source = new EventSource('http://localhost:3000/api1/sse/createConnect?clientId=001') + + // 监听打开事件 + source.addEventListener('open', (e) => { + console.log("打开连接 onopen==>", e) + }) + + // 监听消息事件 + source.addEventListener("message", (e) => { + + }) + + // 监听错误事件 + source.addEventListener("error", (e) => { + + }) + + // 关闭连接 + source.close = () => { + console.log("source.close") + } + + } else { + alert("该浏览器不支持SSE") + } + } + + // 获取系统消息 + const getSystemMessage = () => { + // 发送网络请求 + axiosInstance.post(`http://localhost:3000/api1/sse/broadcast`).then( + response => { + + }, + error => { + + } + ) + } + + let items = [{ key: "/invoice/mine", //icon: React.createElement(UserOutlined), @@ -170,15 +230,14 @@ function HomeView() { const staff: Staff = response.data dispatch(setStaff(staff)) - if (location.pathname === '/') - { - if(token.staffId==='manager') + if (location.pathname === '/') { + if (token.staffId === 'manager') navigate('/reimbursement/approval') else navigate('/invoice/mine') } - if(token.staffId==='manager') { + if (token.staffId === 'manager') { setMenuItems(items.slice(3, 6)) } else if (staff.managingDepartment) { if (staff.managingDepartment.departmentId === 1) { diff --git a/src/pages/Invoice/InvoiceDetailModal.tsx b/src/pages/Invoice/InvoiceDetailModal.tsx index 974bb06..44d03c9 100644 --- a/src/pages/Invoice/InvoiceDetailModal.tsx +++ b/src/pages/Invoice/InvoiceDetailModal.tsx @@ -98,11 +98,11 @@ function InvoiceDetailModal(props: any) { return ( - {props.invoiceDetail?.modified ? '发票信息经过手动修改' : ''} + {props.invoiceDetail?.modified ? '' : ''}
{props.invoiceDetail?.invoiceState === 0 &&
- {complexEnabled && -
-
- - - 全部 - {getInvoiceKindsRadioButtons()} - +
+ + + + 全部 + {getInvoiceKindsRadioButtons()} + + + +
+ + -
- - - - - - - -
- - - 全部 - 未使用 - 报销中 - 已报销 - + + - - -
} +
+ + + 全部 + 未使用 + 报销中 + 已报销 + + + +
) } @@ -399,7 +397,12 @@ function InvoiceListView(props: { isManagement: boolean }) { return (
-
+
{invoices.map((item: Invoice, index: number) =>