Merge branch '20230210-为登录至招标采购中心的用户,增加退出功能。' into 'release_20230210'
2.10 为登录至招标采购中心的用户,增加退出功能。 See merge request eshop/fe_service_ebtp_frontend!151
This commit is contained in:
@ -1,86 +1,100 @@
|
||||
import { Avatar, Dropdown, Menu, message } from 'antd';
|
||||
import { DownOutlined, UserOutlined, UserSwitchOutlined, CarryOutOutlined, HomeOutlined,ImportOutlined } from '@ant-design/icons';
|
||||
import { Avatar, Dropdown, Menu, message, Modal } from 'antd';
|
||||
import { DownOutlined, UserOutlined, UserSwitchOutlined, CarryOutOutlined, HomeOutlined, ImportOutlined } from '@ant-design/icons';
|
||||
import React, { useEffect } from 'react';
|
||||
import moment from 'moment'
|
||||
import { connect, history } from 'umi';
|
||||
import { ConnectState } from '@/models/connect';
|
||||
import logo from '../../assets/logo.svg';
|
||||
import './index.less';
|
||||
import { getMenu, getLogout } from './services'
|
||||
import { getMenu, getLogout } from './services'
|
||||
import { getSessionUserData } from "@/utils/session";
|
||||
|
||||
const GlobalHeaderRight: React.FC<{}> = (props) => {
|
||||
// let className = styles.right;
|
||||
let data = getSessionUserData();
|
||||
const [dataMenu, setDataMenu] = React.useState<any>([]);
|
||||
const handelRole = (item: any)=> {
|
||||
const handelRole = (item: any) => {
|
||||
sessionStorage.setItem('roleData', JSON.stringify(item));
|
||||
sessionStorage.setItem('roleAuthority', JSON.stringify([item.roleCode]));
|
||||
let params = {
|
||||
roleIdList:[item.roleId]
|
||||
roleIdList: [item.roleId]
|
||||
}
|
||||
history.push('/Dashboard')
|
||||
window.location.reload()
|
||||
getMenu(params).then(res=>{
|
||||
if(res?.code == 1){
|
||||
getMenu(params).then(res => {
|
||||
if (res?.code == 1) {
|
||||
setDataMenu(res?.data)
|
||||
}else {
|
||||
} else {
|
||||
message.error("数据错误请联系管理员")
|
||||
}
|
||||
})
|
||||
}
|
||||
//专家角色退出登录
|
||||
const toLogin = () => {
|
||||
let date = {
|
||||
//角色退出登录
|
||||
const toLogout = () => {
|
||||
let _data = {
|
||||
mall3_token: sessionStorage.getItem('Authorization')
|
||||
}
|
||||
getLogout({ ...date }).then((res) => {
|
||||
if (res.success) {
|
||||
window.location.href = "/userformal/login"
|
||||
}
|
||||
})
|
||||
Modal.info({
|
||||
title: '请确认是否退出?',
|
||||
content: false,
|
||||
onOk() {
|
||||
getLogout({ ..._data }).then((res) => {
|
||||
if (res?.success) {
|
||||
if (data?.userType == "0") {//联通智慧门户
|
||||
window.close();
|
||||
} else if (data?.userType == "1") {//合作方
|
||||
window.close();
|
||||
} else if (data?.userType == "2") {//专家
|
||||
window.location.href = "/userformal/login"
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
closable: true,
|
||||
centered: true,
|
||||
okText: "确认退出",
|
||||
className: "layout-modal-logout",
|
||||
});
|
||||
}
|
||||
|
||||
const droMenu = (
|
||||
<Menu style={{top:"17px"}}>
|
||||
<Menu style={{ top: "17px" }}>
|
||||
{data?.authorityList != undefined ?
|
||||
data?.authorityList?.map((item: any,index:any) => (
|
||||
data?.authorityList?.map((item: any, index: any) => (
|
||||
<Menu.Item key={index}>
|
||||
<a target="_blank" rel="noopener noreferrer" onClick={()=>handelRole(item)}>{item.roleName}</a>
|
||||
</Menu.Item>
|
||||
<a target="_blank" rel="noopener noreferrer" onClick={() => handelRole(item)}>{item.roleName}</a>
|
||||
</Menu.Item>
|
||||
)) : null}
|
||||
{data?.roleIds == "ebtp-expert" ? (
|
||||
<>
|
||||
<>
|
||||
<Menu.Divider />
|
||||
<Menu.Item key="exit">
|
||||
<a key="1" onClick={() => toLogin()}>退出登录</a>
|
||||
<a key="1" onClick={() => toLogout()}>退出登录</a>
|
||||
</Menu.Item>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
</Menu>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="top-menu">
|
||||
<div className="left-logo">
|
||||
<img src={logo} alt=""/>中国联通智慧供应链平台 | 招标采购中心
|
||||
<img src={logo} alt="" />中国联通智慧供应链平台 | 招标采购中心
|
||||
</div>
|
||||
<ul className="right-btns">
|
||||
{/* <li><ImportOutlined /><a onClick={()=>window.open(REACT_APP_MALL_V2_URL)}>交易平台2.0</a></li> */}
|
||||
<li><HomeOutlined /><a onClick={()=>history.push('/Dashboard')}>首页</a></li>
|
||||
<li><HomeOutlined /><a onClick={() => history.push('/Dashboard')}>首页</a></li>
|
||||
<li><CarryOutOutlined />{moment().format("YYYY-MM-DD")}</li>
|
||||
{data?.organizationName == null ? null : (<li><UserSwitchOutlined />{data?.organizationName}</li>)}
|
||||
<li>
|
||||
<Avatar size="small" src="https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png" style={{width: '30px'}}/>
|
||||
<Avatar size="small" src="https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png" style={{ width: '30px' }} />
|
||||
<Dropdown overlay={droMenu}>
|
||||
<a className="antd-dropdown-link" style={{color:"#fff"}}>
|
||||
{data?.fullName} <DownOutlined/>
|
||||
<a className="antd-dropdown-link" style={{ color: "#fff" }}>
|
||||
{data?.fullName} <DownOutlined />
|
||||
</a>
|
||||
</Dropdown>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
.top-menu {
|
||||
.left-logo {
|
||||
position:absolute;
|
||||
position: absolute;
|
||||
float: left;
|
||||
left: 0;
|
||||
top: 4px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
|
||||
img {
|
||||
height: 30px;
|
||||
margin-left: 20px;
|
||||
@ -16,8 +17,10 @@
|
||||
top: -2px;
|
||||
}
|
||||
}
|
||||
|
||||
.right-btns {
|
||||
float: right;
|
||||
|
||||
li {
|
||||
float: left;
|
||||
line-height: 56px;
|
||||
@ -25,13 +28,20 @@
|
||||
color: #fff;
|
||||
padding: 0 14px;
|
||||
list-style: none;
|
||||
|
||||
span {
|
||||
padding-right: 6px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.layout-modal-logout .ant-modal-confirm-btns {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
Reference in New Issue
Block a user