import React, {Component} from 'react'
|
import { withRouter } from 'react-router-dom'
|
import PropTypes from 'prop-types'
|
import {connect} from 'react-redux'
|
import { is, fromJS } from 'immutable'
|
import moment from 'moment'
|
import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Button, Input, Badge } from 'antd'
|
|
import asyncComponent from '@/utils/asyncComponent'
|
import {
|
toggleCollapse,
|
modifyMenuTree,
|
modifyMainMenu,
|
modifyTabview,
|
resetState,
|
resetEditState,
|
resetEditLevel,
|
initPermission,
|
modifyDataManager,
|
initActionPermission,
|
initMenuPermission,
|
logout
|
} from '@/store/action'
|
import Api from '@/api'
|
import options from '@/store/options.js'
|
import zhCN from '@/locales/zh-CN/main.js'
|
import enUS from '@/locales/en-US/main.js'
|
import Utils from '@/utils/utils.js'
|
import avatar from '@/assets/img/avatar.jpg'
|
import Resetpwd from './resetpwd'
|
import LoginForm from './loginform'
|
import './index.scss'
|
|
const EditMenu = asyncComponent(() => import('@/templates/menuconfig/editfirstmenu'))
|
const { confirm } = Modal
|
const { Search } = Input
|
|
class Header extends Component {
|
static propTpyes = {
|
collapse: PropTypes.bool
|
}
|
state = {
|
menulist: null, // 一级菜单
|
visible: false, // 修改密码模态框
|
dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
confirmLoading: false,
|
userName: sessionStorage.getItem('User_Name'),
|
logourl: window.GLOB.mainlogo,
|
loginVisible: false,
|
loginLoading: false,
|
avatar: Utils.getrealurl(sessionStorage.getItem('avatar')),
|
systems: [],
|
searchkey: '',
|
thdMenuList: [],
|
oriVersion: '',
|
newVersion: ''
|
}
|
|
handleCollapse = () => {
|
// 展开、收起左侧菜单栏
|
if (!this.props.editState) {
|
this.props.toggleCollapse(!this.props.collapse)
|
localStorage.setItem('collapse', !this.props.collapse)
|
}
|
}
|
|
changePassword = () => {
|
// 点击修改密码,显示弹窗
|
this.setState({
|
visible: true
|
})
|
}
|
|
resetPwdSubmit = () => {
|
this.formRef.handleConfirm().then(res => {
|
this.setState({
|
confirmLoading: true
|
})
|
|
let _param = {
|
func: 's_PwdUpt',
|
LText: `select '${res.originpwd}','${res.password}'`
|
}
|
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') // 时间戳
|
_param.LText = Utils.formatOptions(_param.LText) // 关键字符替换,base64加密
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) // md5密钥
|
|
Api.getSystemConfig(_param).then(result => {
|
this.setState({
|
visible: !result.status,
|
confirmLoading: false
|
})
|
|
if (result.status) {
|
notification.success({
|
top: 92,
|
message: this.state.dict['main.password.resetsuccess'],
|
duration: 2
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
})
|
}, () => {})
|
}
|
|
handleCancel = () => {
|
// 取消时关闭修改密码模态框,清空表单数据
|
this.setState({
|
visible: false
|
})
|
}
|
|
logout = () => {
|
// 退出登录
|
let _this = this
|
confirm({
|
title: this.state.dict['main.logout.hint'],
|
content: '',
|
onOk() {
|
sessionStorage.clear()
|
_this.props.logout()
|
_this.props.history.replace('/login')
|
},
|
onCancel() {}
|
})
|
}
|
|
changeMenu (value) {
|
// 主菜单切换
|
if (this.props.editState && this.props.editLevel) {
|
// 编辑状态下,不可切换菜单
|
return
|
}
|
if (value.PageParam.OpenType === 'menu') {
|
this.props.modifyMainMenu(value)
|
} else {
|
window.open('#/' + value.PageParam.linkUrl + '/')
|
}
|
}
|
|
async loadmenu () {
|
// 获取主菜单
|
let _param = {func: 's_get_pc_menus', systemType: options.sysType}
|
if (sessionStorage.getItem('isEditState') === 'true') { // 编辑状态时,增加参数debug
|
_param.debug = 'Y'
|
}
|
if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
|
_param.linkurl = window.GLOB.linkurl
|
}
|
_param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
|
|
let result = await Api.getSystemConfig(_param)
|
|
// 登录超时
|
if (!result) return
|
|
if (result.status) {
|
let res = this.getMenulist(result)
|
|
this.setState({
|
menulist: res.menulist,
|
systems: []
|
})
|
|
this.props.modifyMenuTree(res.menulist)
|
this.props.modifyMainMenu(res.menulist[0] || null)
|
} else {
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
getRolesMenu () {
|
// 获取角色权限
|
let roledefer = new Promise(resolve => {
|
// edition_type 接口版本控制 ''、'Y'、'A'
|
Api.getSystemConfig({
|
func: 's_Get_TrdMenu_Role',
|
edition_type: 'A',
|
pro_sys: window.GLOB.systemType === 'production' ? 'Y' : ''
|
}).then(result => {
|
let _permAction = {} // 按钮权限
|
|
if (result && result.status) {
|
if (result.UserRoles_Menu) {
|
result.UserRoles_Menu.forEach(menu => {
|
if (!menu.MenuID) return
|
_permAction[menu.MenuID] = true
|
})
|
}
|
} else if (result) {
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
|
this.props.initActionPermission(_permAction)
|
resolve()
|
})
|
})
|
|
// 获取主菜单参数
|
let menudefer = new Promise(resolve => {
|
let _param = {func: 's_get_pc_menus', systemType: options.sysType}
|
if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') {
|
_param.linkurl = window.GLOB.linkurl
|
}
|
_param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
|
|
Api.getSystemConfig(_param).then(result => {
|
if (!result.status || !result.fst_menu) {
|
notification.error({
|
top: 92,
|
message: result.message || '未查询到菜单信息!',
|
duration: 10
|
})
|
return
|
}
|
|
let res = this.getMenulist(result)
|
|
this.setState({
|
menulist: res.menulist,
|
thdMenuList: res.thdMenuList,
|
systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : []
|
})
|
|
let mainMenu = res.menulist[0] || null
|
let _menu = null
|
|
if (sessionStorage.getItem('ThirdMenu')) { // 是否为打开新页面
|
let ThirdMenuId = sessionStorage.getItem('ThirdMenu')
|
_menu = res.thdMenuList.filter(item => item.MenuID === ThirdMenuId)[0] // 通过url中menuid筛选出选中的主菜单
|
|
if (_menu) {
|
mainMenu = res.menulist.filter(item => item.MenuID === _menu.FstId)[0]
|
mainMenu = fromJS(mainMenu).toJS()
|
mainMenu.openId = _menu.ParentId
|
}
|
|
sessionStorage.removeItem('ThirdMenu')
|
}
|
|
this.props.modifyMenuTree(res.menulist)
|
this.props.modifyMainMenu(mainMenu)
|
this.props.initMenuPermission(res.permMenus)
|
|
resolve(_menu)
|
})
|
})
|
|
Promise.all([roledefer, menudefer]).then(response => {
|
if (response[1]) {
|
let tabs = fromJS(this.props.tabviews).toJS()
|
let menu = fromJS(response[1]).toJS()
|
|
tabs = tabs.map(tab => {
|
tab.selected = false
|
return tab
|
})
|
|
menu.selected = true
|
tabs.push(menu)
|
this.props.modifyTabview(tabs)
|
}
|
})
|
}
|
|
getMenulist = (result) => {
|
let thdMenuList = []
|
let permMenus = {}
|
let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt']
|
let menulist = result.fst_menu.map(fst => {
|
let fstItem = {
|
MenuID: fst.MenuID,
|
MenuName: fst.MenuName,
|
PageParam: {OpenType: 'menu', linkUrl: ''},
|
children: []
|
}
|
if (fst.PageParam) {
|
try {
|
fstItem.PageParam = JSON.parse(fst.PageParam)
|
} catch (e) {
|
fstItem.PageParam = {OpenType: 'menu', linkUrl: ''}
|
}
|
}
|
|
if (fst.snd_menu) {
|
fstItem.children = fst.snd_menu.map(snd => {
|
let sndItem = {
|
ParentId: fst.MenuID,
|
MenuID: snd.MenuID,
|
MenuName: snd.MenuName,
|
PageParam: {Icon: 'folder'},
|
children: []
|
}
|
|
if (snd.PageParam) {
|
try {
|
sndItem.PageParam = JSON.parse(snd.PageParam)
|
} catch (e) {
|
sndItem.PageParam = {Icon: 'folder'}
|
}
|
}
|
|
let msg = {
|
UserID: sessionStorage.getItem('UserID'),
|
LoginUID: sessionStorage.getItem('LoginUID'),
|
User_Name: sessionStorage.getItem('User_Name'),
|
Full_Name: sessionStorage.getItem('Full_Name'),
|
Member_Level: sessionStorage.getItem('Member_Level'),
|
dataM: sessionStorage.getItem('dataM'),
|
avatar: sessionStorage.getItem('avatar'),
|
debug: sessionStorage.getItem('debug'),
|
role_id: sessionStorage.getItem('role_id'),
|
mainlogo: window.GLOB.mainlogo,
|
mstyle: window.GLOB.style
|
}
|
|
if (snd.trd_menu) {
|
sndItem.children = snd.trd_menu.map(trd => {
|
let trdItem = {
|
FstId: fst.MenuID,
|
ParentId: snd.MenuID,
|
MenuID: trd.MenuID,
|
MenuName: trd.MenuName,
|
MenuNo: trd.MenuNo,
|
EasyCode: trd.EasyCode,
|
type: 'CommonTable', // 默认值为常用表
|
OpenType: 'newtab' // 打开方式
|
}
|
|
if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) {
|
trdItem.type = 'iframe'
|
trdItem.LinkUrl = trd.LinkUrl
|
trdItem.forbidden = true
|
} else {
|
try {
|
trdItem.PageParam = trd.PageParam ? JSON.parse(trd.PageParam) : {OpenType: 'newtab'}
|
} catch (e) {
|
trdItem.PageParam = {OpenType: 'newtab'}
|
}
|
|
trdItem.type = trdItem.PageParam.Template || trdItem.type
|
trdItem.OpenType = trdItem.PageParam.OpenType || trdItem.OpenType
|
|
if (trdItem.type === 'CustomPage' && this.props.memberLevel < 20) { // 会员等级大于等于20时,有编辑权限
|
trdItem.forbidden = true
|
}
|
if (trdItem.type === 'NewPage') {
|
trdItem.src = trdItem.PageParam.url || ''
|
|
if (trdItem.src.indexOf('paramsmain/') > -1) {
|
try {
|
let _url = trdItem.src.split('paramsmain/')[0] + 'paramsmain/'
|
let _param = JSON.parse(window.decodeURIComponent(window.atob(trdItem.src.split('paramsmain/')[1])))
|
_param.UserID = sessionStorage.getItem('UserID')
|
_param.LoginUID = sessionStorage.getItem('LoginUID')
|
_param.User_Name = sessionStorage.getItem('User_Name')
|
_param.Full_Name = sessionStorage.getItem('Full_Name')
|
|
trdItem.src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
|
} catch {
|
console.warn('菜单参数解析错误!')
|
}
|
}
|
} else {
|
// 打开新页面链接
|
trdItem.src = '#/paramsmain/' + window.btoa(window.encodeURIComponent(JSON.stringify({
|
...msg,
|
ThirdMenu: trd.MenuID
|
})))
|
}
|
}
|
|
permMenus[trd.MenuID] = true
|
thdMenuList.push(trdItem)
|
|
return trdItem
|
})
|
}
|
|
return sndItem
|
})
|
}
|
|
return fstItem
|
})
|
|
return { menulist, thdMenuList, permMenus}
|
}
|
|
reload = () => {
|
this.loadmenu()
|
}
|
|
changeEditState = (state) => {
|
if (!state) { // 退出编辑,页面刷新
|
window.location.reload()
|
return
|
}
|
|
// 修改编辑状态
|
let UserID = sessionStorage.getItem('CloudUserID')
|
let LoginUID = sessionStorage.getItem('CloudLoginUID')
|
|
if (!UserID || !LoginUID) {
|
this.setState({
|
loginVisible: true
|
})
|
} else {
|
sessionStorage.setItem('isEditState', 'true')
|
this.props.modifyDataManager(sessionStorage.getItem('cloudDataM') === 'true')
|
|
if (window.GLOB.systemType === 'production') {
|
this.props.resetEditLevel('HS')
|
this.props.modifyMainMenu({
|
MenuID: 'systemManageView'
|
})
|
|
this.setState({
|
userName: sessionStorage.getItem('CloudUserName'),
|
avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar'))
|
})
|
this.props.resetEditState(state)
|
|
return
|
}
|
|
this.setState({
|
menulist: null,
|
userName: sessionStorage.getItem('CloudUserName'),
|
avatar: Utils.getrealurl(sessionStorage.getItem('CloudAvatar'))
|
})
|
this.loadmenu()
|
this.props.modifyMainMenu(null)
|
this.props.resetEditState(state)
|
}
|
|
if (window.GLOB.systemType !== 'production') {
|
Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
|
if (res.status) {
|
let _permFuncField = []
|
let _sysRoles = []
|
|
if (res.Roles && res.Roles.length > 0) {
|
_sysRoles = res.Roles.map(role => {
|
return {
|
uuid: Utils.getuuid(),
|
value: role.RoleID,
|
text: role.RoleName
|
}
|
})
|
}
|
|
if (res.sModular && res.sModular.length > 0) {
|
res.sModular.forEach(field => {
|
if (field.ModularNo) {
|
_permFuncField.push(field.ModularNo)
|
}
|
})
|
_permFuncField = _permFuncField.sort()
|
}
|
|
this.props.initPermission(_sysRoles, _permFuncField)
|
}
|
})
|
}
|
}
|
|
loginSubmit = () => {
|
this.setState({
|
loginLoading: true
|
})
|
this.loginRef.handleConfirm().then(param => {
|
Api.getusermsg(param.username, param.password, true).then(res => {
|
if (res.status) {
|
sessionStorage.setItem('CloudUserID', res.UserID)
|
sessionStorage.setItem('CloudLoginUID', res.LoginUID)
|
sessionStorage.setItem('CloudUserName', res.UserName)
|
sessionStorage.setItem('CloudFullName', res.FullName)
|
sessionStorage.setItem('CloudAvatar', res.icon)
|
sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '')
|
|
sessionStorage.setItem('isEditState', 'true')
|
|
if (res.dataM) {
|
this.props.modifyDataManager(true)
|
}
|
|
if (window.GLOB.systemType === 'production') {
|
this.props.resetEditLevel('HS')
|
this.props.modifyMainMenu({
|
MenuID: 'systemManageView'
|
})
|
|
this.setState({
|
loginVisible: false,
|
loginLoading: false,
|
userName: res.UserName,
|
avatar: res.icon
|
})
|
this.props.resetEditState(true)
|
|
return
|
}
|
|
this.setState({
|
menulist: null,
|
loginVisible: false,
|
loginLoading: false,
|
userName: res.UserName,
|
avatar: res.icon
|
})
|
this.loadmenu()
|
this.props.modifyMainMenu(null)
|
this.props.resetEditState(true)
|
} else {
|
this.setState({
|
loginLoading: false
|
})
|
notification.error({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
})
|
}
|
|
enterEdit = () => {
|
// 进入编辑状态
|
this.props.resetEditLevel('level1')
|
}
|
|
enterEditManage = () => {
|
const { editLevel } = this.props
|
|
if (editLevel === 'HS') return
|
|
this.props.resetEditLevel('HS')
|
this.props.modifyMainMenu({
|
MenuID: 'systemManageView'
|
})
|
}
|
|
/**
|
* @description 退出管理界面菜单
|
*/
|
exitManage = () => {
|
const { menulist } = this.state
|
|
if (window.GLOB.systemType === 'production') { // 正式系统版本升级后,页面刷新
|
window.location.reload()
|
return
|
}
|
|
this.props.modifyMainMenu(menulist[0] || null)
|
this.props.resetEditLevel(false)
|
}
|
|
exitEdit = () => {
|
// 退出编辑状态
|
this.props.resetEditLevel(false)
|
}
|
|
changeSystem = (system) => {
|
let href = system.LinkUrl1 + 'index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
|
UserID: sessionStorage.getItem('UserID'),
|
LoginUID: sessionStorage.getItem('LoginUID'),
|
User_Name: sessionStorage.getItem('User_Name'),
|
Full_Name: sessionStorage.getItem('Full_Name'),
|
avatar: sessionStorage.getItem('avatar'),
|
dataM: system.dataM ? 'true' : '',
|
debug: system.debug || '',
|
role_id: system.role_id || ''
|
})))
|
|
window.open(href)
|
}
|
|
dropdownMenuChange = (visible) => {
|
this.setState({searchkey: ''}, () => {
|
if (visible) {
|
setTimeout(() => {
|
let input = document.getElementById('thdMenu-search')
|
|
if (input) {
|
input.focus()
|
}
|
}, 500)
|
}
|
})
|
}
|
|
selectMenu = (item) => {
|
let tabs = fromJS(this.props.tabviews).toJS()
|
let menu = fromJS(item).toJS()
|
menu.selected = true
|
|
tabs = tabs.filter(tab => {
|
tab.selected = false
|
return tab.MenuID !== menu.MenuID
|
})
|
|
if (this.props.tabviews.length !== tabs.length) {
|
this.props.modifyTabview(fromJS(tabs).toJS())
|
}
|
|
this.setState({}, () => {
|
tabs.push(menu)
|
this.props.modifyTabview(tabs)
|
})
|
}
|
|
UNSAFE_componentWillMount () {
|
// 组件加载时,获取菜单数据
|
this.getRolesMenu()
|
}
|
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
if (!is(fromJS(this.props.menuTree), fromJS(nextProps.menuTree)) && !is(fromJS(this.state.menulist), fromJS(nextProps.menuTree))) {
|
this.setState({
|
menulist: nextProps.menuTree
|
})
|
}
|
}
|
|
componentDidMount () {
|
// 获取系统的版本信息,延时查询
|
setTimeout(() => {
|
new Promise((resolve, reject) => {
|
Api.getAppVersion(resolve, reject)
|
}).then(res => {
|
this.setState({
|
oriVersion: res.oldVersion,
|
newVersion: res.newVersion
|
})
|
}, () => {
|
console.warn('websql 初始化错误!')
|
})
|
}, 1000)
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
verup = () => {
|
const { oriVersion, newVersion } = this.state
|
const _this = this
|
|
confirm({
|
title: this.state.dict['main.verup'],
|
content: `最新版本${newVersion},当前版本${oriVersion}`,
|
onOk() {
|
return new Promise(resolve => {
|
Api.updateAppVersion(newVersion).then(res => {
|
if (res.status) {
|
notification.success({
|
top: 92,
|
message: '升级成功!',
|
duration: 2
|
})
|
_this.setState({oriVersion: newVersion})
|
} else {
|
notification.warning({
|
top: 92,
|
message: '升级失败,请刷新页面重试!',
|
duration: 2
|
})
|
}
|
resolve()
|
})
|
})
|
},
|
onCancel() {}
|
})
|
}
|
|
gotoDoc = () => {
|
if (options.sysType === 'local' && window.GLOB.mainSystemApi) {
|
let ssodomain = window.GLOB.mainSystemApi.replace('/webapi/dostars', '')
|
let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`
|
window.open(url)
|
} else if (options.sysType === 'SSO' || options.sysType === 'cloud') {
|
window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
|
}
|
}
|
|
render () {
|
const { mainMenu, collapse } = this.props
|
const { thdMenuList, searchkey, oriVersion, newVersion } = this.state
|
|
const menu = (
|
<Menu className="header-dropdown">
|
{this.props.debug && <Menu.Item key="switch">
|
{this.state.dict['main.edit']}
|
<Switch size="small" className="edit-switch" disabled={!!this.props.editLevel} checked={this.props.editState} onChange={this.changeEditState} />
|
</Menu.Item>}
|
{!this.props.editState ? <Menu.Item key="password" onClick={this.changePassword}>{this.state.dict['main.password']}</Menu.Item> : null}
|
{this.state.systems.length > 0 ? <Menu.SubMenu className="header-subSystem-box" title="切换系统">
|
{this.state.systems.map((system, index) => (
|
<Menu.Item className="header-subSystem" key={'sub' + index} onClick={() => {this.changeSystem(system)}}> {system.AppName} </Menu.Item>
|
))}
|
</Menu.SubMenu> : null}
|
<Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
|
{oriVersion ? <Menu.Item key="verup" onClick={this.verup}>
|
<Badge dot={oriVersion !== newVersion}>{this.state.dict['main.verup']}</Badge>
|
</Menu.Item> : null}
|
<Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
|
</Menu>
|
)
|
|
return (
|
<header className="header-container ant-menu-dark" id="main-header-container">
|
<div className={collapse ? "collapse header-logo" : "header-logo"}><img src={this.state.logourl} alt=""/></div>
|
<div className={collapse ? "collapse header-collapse" : "header-collapse"} onClick={this.handleCollapse}>
|
<Icon type={collapse ? 'menu-unfold' : 'menu-fold'} />
|
</div>
|
{/* 正常菜单 */}
|
{this.props.editLevel !== 'level1' && this.state.menulist ?
|
<ul className={'header-menu ' + this.props.editLevel}>{
|
this.state.menulist.map(item => {
|
return (
|
<li key={item.MenuID} onClick={() => {this.changeMenu(item)}} className={mainMenu && mainMenu.MenuID === item.MenuID ? 'active' : ''}>
|
<span>{item.MenuName}</span>
|
</li>
|
)
|
})}
|
{this.props.editState && (!this.props.editLevel || this.props.editLevel === 'HS') ?
|
<li key="HS" onClick={this.enterEditManage} className={this.props.editLevel === 'HS' ? 'active' : ''}>
|
<span>HS</span>
|
</li> : null
|
}
|
</ul> : null
|
}
|
{this.props.editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>退出</Button> : null}
|
{/* 进入编辑按钮 */}
|
{this.props.editState && !this.props.editLevel ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null}
|
{/* {this.props.editState && !this.props.editLevel && options.sysType === 'local' && window.GLOB.systemType !== 'production' ?
|
<a href="#/mobmanage" target="_blank" className="mobile" type="edit"> 应用管理 <Icon type="arrow-right" /></a> : null
|
} */}
|
{/* window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'home', MenuId: 'home_page_id', MenuName: '首页' }))) */}
|
{this.props.editState && !this.props.editLevel && window.GLOB.systemType !== 'production' && this.props.memberLevel >= 20 ?
|
<a className="home-edit" href={`#/menudesign/JTdCJTIyTWVudVR5cGUlMjIlM0ElMjJob21lJTIyJTJDJTIyTWVudUlkJTIyJTNBJTIyaG9tZV9wYWdlX2lkJTIyJTJDJTIyTWVudU5hbWUlMjIlM0ElMjIlRTklQTYlOTYlRTklQTElQjUlMjIlN0Q=`} target="_blank" rel="noopener noreferrer">
|
首页 <Icon type="arrow-right" />
|
</a> : null
|
}
|
{/* 编辑菜单 */}
|
{this.props.editLevel === 'level1' ? <EditMenu menulist={this.state.menulist} reload={this.reload} exitEdit={this.exitEdit}/> : null}
|
{/* 头像、用户名 */}
|
<Dropdown className="header-setting" overlay={menu}>
|
<div>
|
<img src={this.state.avatar || avatar} alt=""/>
|
<span>
|
<span className="username">{this.state.userName}</span> <Icon type="down" />
|
</span>
|
</div>
|
</Dropdown>
|
{/* 菜单搜索 */}
|
{!this.props.editState && thdMenuList.length > 0 ?
|
<Dropdown overlayClassName="menu-select-dropdown" getPopupContainer={() => document.getElementById('main-header-container')} overlay={
|
<div>
|
<Search
|
placeholder=""
|
id="thdMenu-search"
|
value={searchkey}
|
onChange={e => this.setState({searchkey: e.target.value})}
|
style={{ minWidth: '200px' }}
|
onSearch={(val, e) => {e.stopPropagation()}}
|
onClick={(e) => {e.stopPropagation()}}
|
/>
|
<div className="menu-select-box">
|
<Menu>
|
{thdMenuList.map(option => {
|
if (searchkey) {
|
if (
|
option.MenuName.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0 ||
|
option.MenuNo.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0 ||
|
option.EasyCode.toLowerCase().indexOf(searchkey.toLowerCase()) >= 0
|
) {
|
return <Menu.Item key={option.MenuID} onClick={() => this.selectMenu(option)}>{option.MenuName}</Menu.Item>
|
} else {
|
return null
|
}
|
}
|
return <Menu.Item key={option.MenuID} onClick={() => this.selectMenu(option)}>{option.MenuName}</Menu.Item>
|
})}
|
</Menu>
|
</div>
|
</div>
|
} trigger={['click']} className="search-menu" placement="bottomRight" onVisibleChange={this.dropdownMenuChange}>
|
<Icon className="search-menu" type="search" />
|
</Dropdown> : null
|
}
|
{/* 修改密码 */}
|
<Modal
|
title={this.state.dict['main.password']}
|
visible={this.state.visible}
|
onOk={this.resetPwdSubmit}
|
confirmLoading={this.state.confirmLoading}
|
onCancel={this.handleCancel}
|
destroyOnClose
|
>
|
<Resetpwd dict={this.state.dict} wrappedComponentRef={(inst) => this.formRef = inst} resetPwdSubmit={this.resetPwdSubmit}/>
|
</Modal>
|
{/* 编辑状态登录 */}
|
<Modal
|
title={this.state.dict['main.login.develop']}
|
visible={this.state.loginVisible}
|
onOk={this.loginSubmit}
|
width={'430px'}
|
confirmLoading={this.state.loginLoading}
|
onCancel={() => {this.setState({ loginVisible: false, loginLoading: false })}}
|
destroyOnClose
|
>
|
<LoginForm handleSubmit={() => this.loginSubmit()} wrappedComponentRef={(inst) => this.loginRef = inst}/>
|
</Modal>
|
</header>
|
)
|
}
|
}
|
|
const mapStateToProps = (state) => {
|
return {
|
tabviews: state.tabviews,
|
collapse: state.collapse,
|
menuTree: state.menuTree,
|
mainMenu: state.mainMenu,
|
debug: state.debug,
|
editState: state.editState,
|
editLevel: state.editLevel,
|
permAction: state.permAction,
|
sysRoles: state.sysRoles,
|
memberLevel: state.memberLevel,
|
permFuncField: state.permFuncField
|
}
|
}
|
|
const mapDispatchToProps = (dispatch) => {
|
return {
|
toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)),
|
modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)),
|
modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)),
|
modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)),
|
resetEditState: (state) => dispatch(resetEditState(state)),
|
resetEditLevel: (level) => dispatch(resetEditLevel(level)),
|
initActionPermission: (permAction) => dispatch(initActionPermission(permAction)),
|
initPermission: (sysRoles, permFuncField) => dispatch(initPermission(sysRoles, permFuncField)),
|
initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)),
|
modifyDataManager: (dataManager) => dispatch(modifyDataManager(dataManager)),
|
resetState: () => dispatch(resetState()),
|
logout: () => dispatch(logout())
|
}
|
}
|
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Form.create()(Header)))
|