|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
import React, { useState, useEffect } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Layout, Notification } from '@douyinfe/semi-ui'; |
|
|
|
import { Layout, Notification, Spin, Toast } from '@douyinfe/semi-ui'; |
|
|
|
import Sider from '../../components/sider'; |
|
|
|
import Header from '../../components/header'; |
|
|
|
import Footer from '../../components/footer'; |
|
|
@ -95,6 +95,7 @@ const LayoutContainer = props => { |
|
|
|
const [leftItems, setLeftItems] = useState([]) |
|
|
|
const [leftChange, setLeftChange] = useState(true) |
|
|
|
const [leftShow, setLeftShow] = useState(false) |
|
|
|
const [loading, setLoading] = useState(false) |
|
|
|
useEffect(() => { |
|
|
|
let topItems = []//头部导航 |
|
|
|
const lastSelectedKeys = localStorage.getItem('poms_selected_sider') |
|
|
@ -146,7 +147,7 @@ const LayoutContainer = props => { |
|
|
|
return () => { |
|
|
|
window.removeEventListener('resize', resize_); |
|
|
|
} |
|
|
|
}, []) |
|
|
|
}, [user.authorized]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
let pathnameArr = location.pathname.split('/') |
|
|
@ -176,6 +177,7 @@ const LayoutContainer = props => { |
|
|
|
NProgress.done(); |
|
|
|
if ((!user || !user.authorized)) { |
|
|
|
// history.push('/signin'); |
|
|
|
setLoading(true); |
|
|
|
getUserInfoByToken() |
|
|
|
} |
|
|
|
if (msg) { |
|
|
@ -205,7 +207,6 @@ const LayoutContainer = props => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const getUserInfoByToken = () => { |
|
|
|
if (requestUser) { |
|
|
|
requestUser = false; |
|
|
@ -214,25 +215,43 @@ const LayoutContainer = props => { |
|
|
|
dispatch(login({ token })).then(res => { |
|
|
|
if (res.type == 'LOGIN_SUCCESS') { |
|
|
|
const data = res.payload?.user || {} |
|
|
|
localStorage.setItem('poms_open_sider', JSON.stringify(["archivesCenter"])) |
|
|
|
localStorage.setItem('poms_selected_sider', JSON.stringify(["humanAffairs"])) |
|
|
|
if (data.codes && data.codes.length) { |
|
|
|
dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) |
|
|
|
dispatch(actions.humanAffairs.getUserResource(res.payload.user.id)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
sessionStorage.setItem('userResource', JSON.stringify(res.payload.data)) |
|
|
|
history.push('/humanAffairs/archivesCenter/personnelArchives/personnelFiles') |
|
|
|
window.location.reload() |
|
|
|
} |
|
|
|
localStorage.setItem('poms_open_sider', JSON.stringify(["archivesCenter"])) |
|
|
|
localStorage.setItem('poms_selected_sider', JSON.stringify(["humanAffairs"])) |
|
|
|
setLoading(false); |
|
|
|
} else { |
|
|
|
setLoading(false); |
|
|
|
Toast.warning({ |
|
|
|
content: '用户无模块权限', duration: 2, onClose: () => { |
|
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
setLoading(false); |
|
|
|
Toast.warning({ |
|
|
|
content: '鉴权失败', duration: 2, onClose: () => { |
|
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, error => { |
|
|
|
setLoading(false); |
|
|
|
Toast.warning({ |
|
|
|
content: '鉴权失败', duration: 2, onClose: () => { |
|
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, error => { |
|
|
|
message.error('鉴权失败', 5); |
|
|
|
setLoading(false); |
|
|
|
Toast.warning({ |
|
|
|
content: '鉴权失败', duration: 2, onClose: () => { |
|
|
|
window.location.href = `${webPepUrl}/signin` |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -269,7 +288,7 @@ const LayoutContainer = props => { |
|
|
|
return ( |
|
|
|
<Layout id="layout" style={{ height: '100%' }}> |
|
|
|
{ |
|
|
|
<> |
|
|
|
<Spin spinning={loading}> |
|
|
|
<Layout.Header> |
|
|
|
<Header |
|
|
|
// headerItems={headerItems} //菜单重新分类规整 |
|
|
@ -310,7 +329,7 @@ const LayoutContainer = props => { |
|
|
|
/> |
|
|
|
</Layout.Header> |
|
|
|
<Layout style={{ height: 'calc(100% - 50px)' }}> |
|
|
|
{leftShow ? (<Layout.Sider> |
|
|
|
{user && user.authorized ? (<Layout.Sider> |
|
|
|
<Sider |
|
|
|
sections={sections} |
|
|
|
leftItems={leftItems} |
|
|
@ -321,7 +340,7 @@ const LayoutContainer = props => { |
|
|
|
collapsed={collapsed} |
|
|
|
/> |
|
|
|
</Layout.Sider>) : ('')} |
|
|
|
<Layout.Content> |
|
|
|
{user && user.authorized ? <Layout.Content> |
|
|
|
<div style={{ |
|
|
|
background: "#F2F3F5", |
|
|
|
}}> |
|
|
@ -342,9 +361,9 @@ const LayoutContainer = props => { |
|
|
|
</Layout.Footer> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Layout.Content> |
|
|
|
</Layout.Content> : ''} |
|
|
|
</Layout> |
|
|
|
</> |
|
|
|
</Spin> |
|
|
|
} |
|
|
|
</Layout > |
|
|
|
) |
|
|
|