| | |
| | | import React, {Component} from 'react' |
| | | import { withRouter } from 'react-router-dom' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Dropdown, Menu, Modal, notification, Switch, Button, Popover } from 'antd' |
| | | import { MenuFoldOutlined, SettingOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons' |
| | | |
| | |
| | | |
| | | changeMenu (value) { |
| | | // 主菜单切换 |
| | | if (this.props.editLevel) { |
| | | // 编辑状态下,不可切换菜单 |
| | | return |
| | | } |
| | | if (value.PageParam.OpenType === 'menu') { |
| | | this.props.modifyMainMenu(value) |
| | | } else if (value.PageParam.OpenType === 'outpage') { |
| | |
| | | |
| | | this.setState({ menulist }) |
| | | |
| | | this.props.modifyMenuTree(menulist) |
| | | if (window.GLOB.systemType !== 'production') { // 非正式系统选择第一项 |
| | | this.props.modifyMainMenu(menulist[0] || null) |
| | | } else { |
| | | let mainMenu = menulist[0] || null |
| | | |
| | | if (this.props.editLevel === 'level1') { |
| | | mainMenu = null |
| | | } else if (this.props.mainMenu && this.props.mainMenu.MenuID) { |
| | | let _menu = menulist.filter(item => item.MenuID === this.props.mainMenu.MenuID)[0] |
| | | mainMenu = _menu || mainMenu |
| | | |
| | | if (!_menu && (this.props.editLevel === 'level2' || this.props.editLevel === 'level3')) { |
| | | this.props.resetEditLevel(false) |
| | | } |
| | | } |
| | | |
| | | this.props.modifyMenuTree(menulist) |
| | | this.props.modifyMainMenu(mainMenu) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | |
| | | MenuID: snd.MenuID, |
| | | MenuName: snd.MenuName, |
| | | PageParam: {Icon: 'folder'}, |
| | | children: [] |
| | | children: [], |
| | | level: 'second' |
| | | } |
| | | |
| | | if (snd.PageParam) { |
| | |
| | | MenuNo: trd.MenuNo, |
| | | EasyCode: trd.EasyCode, |
| | | type: 'CommonTable', // 默认值为常用表 |
| | | OpenType: 'newtab' // 打开方式 |
| | | OpenType: 'newtab', // 打开方式 |
| | | level: 'third' |
| | | } |
| | | |
| | | if (trd.LinkUrl && iframes.includes(trd.LinkUrl.split('?')[0])) { |
| | |
| | | enterEdit = () => { |
| | | // 进入编辑状态 |
| | | this.props.resetEditLevel('level1') |
| | | this.props.modifyMainMenu(null) |
| | | } |
| | | |
| | | exitEdit = () => { |
| | | // 退出编辑状态 |
| | | this.props.resetEditLevel(false) |
| | | this.props.modifyMainMenu(this.state.menulist[0] || null) |
| | | } |
| | | |
| | | |
| | |
| | | this.loadmenu() |
| | | } |
| | | |
| | | 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 () { |
| | | if (window.GLOB.systemType !== 'production') { |
| | | setTimeout(() => { |
| | |
| | | this.reload() |
| | | }) |
| | | MKEmitter.addListener('mkUpdateMenuList', this.reload) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | {/* 进入编辑按钮 */} |
| | | {!editLevel && window.GLOB.systemType !== 'production' && menulist ? <Popover overlayClassName="mk-popover-control-wrap mk-menu-control" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <PlusOutlined onClick={() => this.setState({visible: true, loading: false})} className="mk-edit-menu"/> |
| | | <SwapOutlined onClick={this.enterEdit} className="mk-edit-menu"/> |
| | | <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId="0" Type="10" className="mk-edit-menu"/></div> |
| | | <PlusOutlined onClick={() => this.setState({visible: true, loading: false})}/> |
| | | <SwapOutlined onClick={this.enterEdit}/> |
| | | <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId="0" Type="10"/></div> |
| | | </div> |
| | | } trigger="hover"> |
| | | <SettingOutlined className="edit-check"/> |