| | |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Menu, Icon, notification } from 'antd' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import {modifyTabview, resetEditLevel} from '@/store/action' |
| | | import zhCN from '@/locales/zh-CN/header.js' |
| | | import enUS from '@/locales/en-US/header.js' |
| | | import { modifyTabview, resetEditLevel } from '@/store/action' |
| | | import { SySMenuList } from './config' |
| | | import options from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | const EditSecMenu = asyncComponent(() => import('./editsecmenu')) |
| | | const EditThdMenu = asyncComponent(() => import('./editthdmenu')) |
| | | const EditSecMenu = asyncComponent(() => import('@/templates/menuconfig/editsecmenu')) |
| | | const EditThdMenu = asyncComponent(() => import('@/templates/menuconfig/editthdmenu')) |
| | | const { SubMenu } = Menu |
| | | |
| | | class Sidemenu extends Component { |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | mainMenuList: null, // 一级菜单,编辑调整上级菜单时获取 |
| | | subMenulist: null, // 二级菜单 |
| | | subMenulist: [], // 二级菜单 |
| | | editMenu: null, // 编辑三级菜单时设置 |
| | | rootSubmenuKeys: null, |
| | | createThirdMenu: false, |
| | |
| | | return |
| | | } |
| | | |
| | | let _param = {func: 'sPC_Get_FunMenu', ParentID: menu.MenuID} |
| | | let _param = {func: 'sPC_Get_FunMenu', ParentID: menu.MenuID, systemType: options.sysType} |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { // 编辑状态时,获取菜单,增加参数debug |
| | | _param.debug = 'Y' |
| | |
| | | |
| | | let result = await Api.getSystemConfig(_param) |
| | | if (result.status) { |
| | | if (this.props.editState && this.props.editLevel === 'HS') return |
| | | |
| | | if (result.data.length === 0) { // 查询菜单为空 |
| | | this.setState({ |
| | | subMenulist: [], |
| | | rootSubmenuKeys: [], |
| | | openKeys: [], |
| | | editMenu: null |
| | | openKeys: [] |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let SubMenuId = sessionStorage.getItem('SubMenu') // 是否为打开新页面 |
| | | let ThirdMenuId = sessionStorage.getItem('ThirdMenu') // 是否为打开新页面 |
| | | let msg = sessionStorage.getItem('UserID') + '&sd=' + sessionStorage.getItem('SessionUid') + '&ld=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') |
| | | let msg = sessionStorage.getItem('UserID') + '&ld=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') |
| | | let submenuId = '' // 展开二级菜单ID |
| | | let tabId = '' // 打开的tab页id |
| | | |
| | |
| | | |
| | | if (item.FunMenu) { |
| | | _smenu.children = item.FunMenu.map(child => { |
| | | let _tmenu = {} |
| | | let _tmenu = { |
| | | ParentId: item.ParentID |
| | | } |
| | | |
| | | // 打开新页面链接 |
| | | _tmenu.src = '#/main/' + window.btoa('mm=' + menu.MenuID + '&sm=' + _smenu.MenuID + '&tm=' + child.MenuID + '&ud=' + msg) |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | enterManageView = (type) => { |
| | | let menulist = SySMenuList[type] |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | | menulist.forEach(menu => { |
| | | menu.children = menu.children.filter(item => item.systems && item.systems.includes(window.GLOB.systemType)) |
| | | }) |
| | | |
| | | menulist = menulist.filter(menu => menu.children.length > 0) |
| | | } else { |
| | | menulist.forEach(menu => { |
| | | menu.children = menu.children.filter(item => !item.systems || item.systems.includes(options.sysType)) |
| | | }) |
| | | |
| | | menulist = menulist.filter(menu => menu.children.length > 0) |
| | | } |
| | | |
| | | this.setState({ |
| | | subMenulist: menulist, |
| | | rootSubmenuKeys: menulist.map(item => item.MenuID), |
| | | openKeys: this.props.collapse ? [] : [menulist[0].MenuID] |
| | | }) |
| | | } |
| | | |
| | | changemenu(e) { |
| | | if (this.props.editState) { |
| | | if (this.props.editState && this.props.editLevel !== 'HS') { |
| | | e.preventDefault() |
| | | return |
| | | } |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu))) { |
| | | if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu)) && nextProps.mainMenu && nextProps.mainMenu.MenuID === 'systemManageView') { |
| | | this.enterManageView(nextProps.mainMenu.MenuID) |
| | | } else if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu))) { |
| | | // 主菜单切换,请求2、3级菜单数据 |
| | | this.loadsubmenu(nextProps.mainMenu) |
| | | } else if (nextProps.collapse && this.props.collapse !== nextProps.collapse) { |
| | |
| | | const editShow = (this.props.editState && !this.props.editLevel) || false |
| | | |
| | | return ( |
| | | <aside className={"side-menu ant-menu-dark" + (this.props.collapse ? ' side-menu-collapsed' : '') + (this.props.isiframe ? ' iframe' : '')}> |
| | | {this.state.subMenulist && !(this.props.editLevel === 'level2' || this.props.editLevel === 'level3') && |
| | | <aside className={"side-menu ant-menu-dark" + (this.props.collapse ? ' side-menu-collapsed' : '') + (this.props.isiframe ? ' iframe' : '') + (this.props.editState ? ' edit' : '')}> |
| | | {!(this.props.editLevel === 'level2' || this.props.editLevel === 'level3') && |
| | | <Menu openKeys={this.state.openKeys} onOpenChange={this.onOpenChange} mode="inline" theme="dark" inlineCollapsed={this.props.collapse}> |
| | | {editShow && <li className="sup-menu"><Icon onClick={this.enterSubEdit} className="edit-check" type="edit" /></li>} |
| | | {this.state.subMenulist.map((item, index) => { |
| | | {this.state.subMenulist && this.state.subMenulist.map((item, index) => { |
| | | return ( |
| | | <SubMenu |
| | | key={item.MenuID} |
| | |
| | | </span> |
| | | } |
| | | > |
| | | {editShow && <li className={'ant-menu-item ' + (item.children.length > 0 ? 'sub-menu' : '')}> |
| | | {editShow ? <li className={'ant-menu-item ' + (item.children.length > 0 ? 'sub-menu' : '')}> |
| | | <Icon onClick={(e) => {this.enterThrEdit(e, item)}} className="edit-check" type="edit" /> |
| | | </li>} |
| | | </li> : null} |
| | | {item.children.map(cell => { |
| | | return ( |
| | | <Menu.Item key={cell.MenuID}> |
| | |
| | | ) |
| | | })} |
| | | </Menu>} |
| | | {this.props.editLevel === 'level2' && |
| | | {this.props.editLevel === 'level2' ? |
| | | <EditSecMenu |
| | | menulist={this.state.subMenulist} |
| | | supMenuList={this.state.mainMenuList} |
| | | supMenu={this.props.mainMenu} |
| | | reload={this.reload} |
| | | exitEdit={this.exitEdit} |
| | | /> |
| | | /> : null |
| | | } |
| | | {this.props.editLevel === 'level3' && this.state.subMenulist && |
| | | {this.props.editLevel === 'level3' && this.state.subMenulist && this.state.editMenu ? |
| | | <EditThdMenu |
| | | menulist={this.state.editMenu.children} |
| | | supMenuList={this.state.subMenulist} |
| | | supMenu={this.state.editMenu} |
| | | reload={this.reload} |
| | | exitEdit={this.exitEdit} |
| | | /> |
| | | /> : null |
| | | } |
| | | </aside> |
| | | ) |