Browse Source

(*)相关故障修改

master
zmh 1 year ago
parent
commit
eb632e5dcc
  1. 51
      web/client/src/layout/containers/layout/index.jsx
  2. 4
      web/client/src/sections/humanAffairs/containers/employeeAuth.jsx
  3. 11
      web/client/src/utils/func.js

51
web/client/src/layout/containers/layout/index.jsx

@ -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 >
)

4
web/client/src/sections/humanAffairs/containers/employeeAuth.jsx

@ -239,7 +239,7 @@ const EmployeeAuth = (props) => {
resourceId.push(parseInt(item));
}
}
resourceId = [...checkedList, ...resourceId]
resourceId = [...resourceId]
if (roleId == undefined || resourceId.length == 0) {
Toast.error('请选择角色和权限!')
} else {
@ -273,7 +273,7 @@ const EmployeeAuth = (props) => {
</div>
<div className='authorityAdminList'>
{
hrUser && hrUser.adminHr && hrUser.adminHr.map(e => {
hrUser && hrUser.adminHr && hrUser.adminHr.filter(admin => admin.id != 1).map(e => {
return (
<div >
<span>人力资源部</span>

11
web/client/src/utils/func.js

@ -1,10 +1,9 @@
'use strict';
const userData = JSON.parse(sessionStorage.getItem('hrUser'));
export const isAuthorized = (authcode) => {
if (JSON.parse(sessionStorage.getItem('userResource'))) {
const resources = JSON.parse(sessionStorage.getItem('userResource'));
return resources.includes(authcode);
} else {
return false;
let userInfo = userData || JSON.parse(sessionStorage.getItem('hrUser'));
if (userInfo) {
const { codes } = userInfo
return codes && codes.includes(authcode);
}
}
Loading…
Cancel
Save