"use strict";
import React from "react";
import { connect } from "react-redux";
import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui';
import { IconTreeTriangleDown } from '@douyinfe/semi-icons';
import "./index.less";
const Header = (props) => {
const { dispatch, history, user, actions, socket, headerItems, tochange } = props;
let userRole = user?.pomsUserInfo?.role
let modalRole = []
if (userRole) {
let modal = []
userRole?.map(v => {
if (v == 'data_analyst') ['analysis', 'data', 'workOrder', 'means'].map(u => modal.push(u))
if (v == 'after_sale') ['problem', 'facility', 'workOrder', 'means'].map(u => modal.push(u))
if (v == 'resource_manage') ['facility', 'workOrder', 'means'].map(u => modal.push(u))
if (v == 'customer_service') ['service', 'workOrder', 'means'].map(u => modal.push(u))
})
modal.push('console')
modal = [...new Set(modal)]
modalRole = headerItems?.filter(v => modal.includes(v.itemKey))
if (userRole?.includes('SuperAdmin') || userRole?.includes('admin')) modalRole = headerItems
}
return (
<>
}
>
{user?.name?.substr(0, 1)}
{user.name}
v.name + '、')} style={{ width: 60, overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis', color: '#969799', fontSize: 12 }}>{user?.department?.map(v => v.name + '、')}
{
history.push(`/userCenter`);
}}>
用户中心
{
dispatch(actions.auth.logout(user));
if (socket) {
socket.disconnect();
}
history.push(`/signin`);
}}>
退出
{/* */}
{/* collapseButton collapseText */}
>
}
/>
>
);
};
function mapStateToProps (state) {
const { global, auth, webSocket } = state;
return {
actions: global.actions,
user: auth.user,
socket: webSocket.socket,
};
}
export default connect(mapStateToProps)(Header);