diff --git a/src/components/GlobalHeader/RightContent.tsx b/src/components/GlobalHeader/RightContent.tsx index b78fa5f..070cf13 100644 --- a/src/components/GlobalHeader/RightContent.tsx +++ b/src/components/GlobalHeader/RightContent.tsx @@ -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([]); - 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 = ( - + {data?.authorityList != undefined ? - data?.authorityList?.map((item: any,index:any) => ( + data?.authorityList?.map((item: any, index: any) => ( - handelRole(item)}>{item.roleName} - + handelRole(item)}>{item.roleName} + )) : null} - {data?.roleIds == "ebtp-expert" ? ( - <> + <> - toLogin()}>退出登录 + toLogout()}>退出登录 - - ) : null} + ); return (
- 中国联通智慧供应链平台 | 招标采购中心 + 中国联通智慧供应链平台 | 招标采购中心
- +
); }; diff --git a/src/components/GlobalHeader/index.less b/src/components/GlobalHeader/index.less index 21e9fe9..72eeb15 100644 --- a/src/components/GlobalHeader/index.less +++ b/src/components/GlobalHeader/index.less @@ -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%; +} \ No newline at end of file