解决了一些问题

main
wuyize 2023-01-06 15:04:11 +08:00
parent c770c86eaf
commit 586c4fa69e
4 changed files with 126 additions and 64 deletions

View File

@ -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)'
}}>
<Dropdown overlayStyle={{minWidth: '150px'}} menu={{items, onClick}} placement="bottomRight" arrow>
<Button type="text" style={{
marginRight: '12px', height: '100%',
display: 'flex', justifyContent: 'center', alignItems: 'center'
}}>
<span style={{marginRight: '12px'}}>{departmentToString(staff)}</span>
<span style={{fontWeight: "bold", marginRight: '12px'}}>{staff.staffName}</span>
<div style={{
width: '24px', height: '24px', backgroundColor: colorPrimary, borderRadius: '12px',
<div></div>
<div style={{
height: '100%',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
}}>
<Button type="text" shape="circle">
<BellOutlined />
</Button>
<Dropdown overlayStyle={{minWidth: '150px'}} menu={{items, onClick}} placement="bottomRight" arrow>
<Button type="text" style={{
marginRight: '12px', height: '100%',
display: 'flex', justifyContent: 'center', alignItems: 'center'
}}>
<span style={{color: 'white', fontSize: '10px'}}>{staff.staffName[0]}</span>
</div>
</Button>
</Dropdown>
<span style={{marginRight: '12px'}}>{departmentToString(staff)}</span>
<span style={{fontWeight: "bold", marginRight: '12px'}}>{staff.staffName}</span>
<div style={{
width: '24px', height: '24px', backgroundColor: colorPrimary, borderRadius: '12px',
display: 'flex', justifyContent: 'center', alignItems: 'center'
}}>
<span style={{color: 'white', fontSize: '10px'}}>{staff.staffName[0]}</span>
</div>
</Button>
</Dropdown>
</div>
</Header>
)
}
@ -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) {

View File

@ -98,11 +98,11 @@ function InvoiceDetailModal(props: any) {
return (
<Modal
open={props.open}
title="发票详情"
title={"发票详情"+(props.invoiceDetail?.modified ? '(发票信息经过手动修改)' : '')}
onCancel={handleCancel}
footer={
<div style={{width: '100%', display: "flex", flexDirection: "row", justifyContent: "space-between"}}>
<Text>{props.invoiceDetail?.modified ? '发票信息经过手动修改' : ''}</Text>
<Text>{props.invoiceDetail?.modified ? '' : ''}</Text>
<div>
{props.invoiceDetail?.invoiceState === 0 && <Button danger loading={loading} onClick={withDraw}
>

View File

@ -210,50 +210,48 @@ function InvoiceSearch(props: { isManagement: boolean, handleSearchData: any })
props.handleSearchData(invoiceSearchOption)
}}/>}
</div>
{complexEnabled &&
<div className="complexSearchBar" style={{
margin: '20px',
padding: '20px 20px 0px 20px',
display: "flex",
backgroundColor: colorBgContainer,
borderRadius: '20px'
}}>
<Form name="complexOption" onValuesChange={onValuesChange} style={{width: '100%'}}>
<Form.Item
name={`invoice-kind`}
label={`发票类型`}
>
<Radio.Group defaultValue="全部">
<Radio.Button value="全部"></Radio.Button>
{getInvoiceKindsRadioButtons()}
</Radio.Group>
<div className="complexSearchBar" style={{
margin: '20px',
padding: '20px 20px 0px 20px',
display: complexEnabled ? "flex" : "none",
backgroundColor: colorBgContainer,
borderRadius: '20px'
}}>
<Form name="complexOption" onValuesChange={onValuesChange} style={{width: '100%'}}>
<Form.Item
name={`invoice-kind`}
label={`发票类型`}
>
<Radio.Group defaultValue="全部">
<Radio.Button value="全部"></Radio.Button>
{getInvoiceKindsRadioButtons()}
</Radio.Group>
</Form.Item>
<div style={{marginTop: -10, display: "flex", flexDirection: "row", flexWrap: "wrap"}}>
<Form.Item name="upload-time-picker" label="上传时间" {...rangeConfig}
style={{marginRight: 100}}>
<RangePicker/>
</Form.Item>
<div style={{marginTop: -10, display: "flex", flexDirection: "row", flexWrap: "wrap"}}>
<Form.Item name="upload-time-picker" label="上传时间" {...rangeConfig}
style={{marginRight: 100}}>
<RangePicker/>
</Form.Item>
<Form.Item name="invoice-time-picker" label="开票日期" {...rangeConfig}>
<RangePicker/>
</Form.Item>
</div>
<Form.Item
name={`invoice-state`}
label={`发票状态`}
>
<Radio.Group defaultValue="全部">
<Radio.Button value="全部"></Radio.Button>
<Radio.Button value="0">使</Radio.Button>
<Radio.Button value="1"></Radio.Button>
<Radio.Button value="2"></Radio.Button>
</Radio.Group>
<Form.Item name="invoice-time-picker" label="开票日期" {...rangeConfig}>
<RangePicker/>
</Form.Item>
</Form>
</div>}
</div>
<Form.Item
name={`invoice-state`}
label={`发票状态`}
>
<Radio.Group defaultValue="全部">
<Radio.Button value="全部"></Radio.Button>
<Radio.Button value="0">使</Radio.Button>
<Radio.Button value="1"></Radio.Button>
<Radio.Button value="2"></Radio.Button>
</Radio.Group>
</Form.Item>
</Form>
</div>
</div>
)
}
@ -399,7 +397,12 @@ function InvoiceListView(props: { isManagement: boolean }) {
return (
<div style={{}}>
<InvoiceSearch isManagement={props.isManagement} handleSearchData={handleInvoiceSearchInfo}/>
<div style={{padding: '10px 30px 30px 30px', display: "flex", flexDirection: "column", alignItems: "flex-end"}}>
<div style={{
padding: '10px 30px 30px 30px',
display: "flex",
flexDirection: "column",
alignItems: "flex-end"
}}>
<div style={{display: "flex", flexWrap: "wrap", justifyContent: 'center', width: '100%'}}>
{invoices.map((item: Invoice, index: number) =>
<InvoiceItem showUploader={props.isManagement} onClick={onItemClick} invoice={item}

View File

@ -666,7 +666,7 @@ function StatView() {
trigger: 'item',
formatter: function (params: any) {
let returnStr = '';
if (params.componentSubType == 'lines') {
if (params.componentSubType === 'lines') {
returnStr += params.marker;
returnStr += params.data.fromName + ' → ' + params.data.toName;
returnStr += '' + params.data.value;