| | |
| | | import React, {Component} from 'react' |
| | | import { connect } from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Menu, Popover, Modal, notification } from 'antd' |
| | | import { SwapOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons' |
| | | import { EditOutlined, PlusOutlined, SettingOutlined, ApiOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { resetEditLevel } from '@/store/action' |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | menu = fromJS(menu).toJS() |
| | | let openKey = '' |
| | | |
| | | if (menu.children[0]) { |
| | | openKey = menu.openId || menu.children[0].MenuID |
| | | // 菜单更新时,展开原二级菜单 |
| | | if (this.props.mainMenu && menu.MenuID === this.props.mainMenu.MenuID && this.state.openKeys && this.state.openKeys[0]) { |
| | | openKey = this.state.openKeys[0] |
| | | if (menu.children.filter(m => m.MenuID === openKey).length === 0) { |
| | | openKey = '' |
| | | } |
| | | } |
| | | if (!openKey && menu.children[0]) { |
| | | openKey = menu.children[0].MenuID |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | } |
| | | |
| | | editmenu = (cell) => { |
| | | if (window.GLOB.systemType === 'production') return |
| | | |
| | | if (cell.type === 'CustomPage') { |
| | | let _param = { |
| | | MenuType: 'custom', |
| | |
| | | } |
| | | _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param))) |
| | | window.open(`#/menudesign/${_param}`) |
| | | } else if (['CommonTable', 'TreePage', 'CalendarPage'].includes(cell.type)) { |
| | | } else if (cell.type === 'BaseTable') { |
| | | sessionStorage.setItem('menuTree', JSON.stringify(this.props.menuTree)) |
| | | let _param = window.btoa(window.encodeURIComponent(JSON.stringify(cell))) |
| | | |
| | | window.open(`#/tabledesign/${_param}`) |
| | | } else if (['CommonTable', 'TreePage'].includes(cell.type)) { |
| | | sessionStorage.setItem('menuTree', JSON.stringify(this.props.menuTree)) |
| | | let _param = window.btoa(window.encodeURIComponent(JSON.stringify(cell))) |
| | | |
| | |
| | | thdVisible: true, |
| | | loading: false, |
| | | sysMenu: _cell |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '当前菜单不可编辑', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | Api.getSystemConfig(param).then(res => { |
| | | Api.getCloudConfig(param).then(res => { |
| | | if (res.status) { |
| | | this.setState({ |
| | | loading: false, |
| | |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | Api.getCloudConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | loading: false, |
| | |
| | | <Popover overlayClassName="mk-popover-control-wrap mk-menu-control" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <PlusOutlined onClick={this.addSecMenu}/> |
| | | <SwapOutlined onClick={this.enterSubEdit} className={'mk-swap' + (mainMenu.children.length === 0 ? ' disabled' : '')}/> |
| | | <EditOutlined onClick={this.enterSubEdit} className={'mk-swap' + (mainMenu.children.length === 0 ? ' disabled' : '')}/> |
| | | <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId={mainMenu.MenuID} Type="20"/></div> |
| | | </div> |
| | | } trigger="hover" placement="top"> |
| | |
| | | key={item.MenuID} |
| | | title={ |
| | | <span className={!editLevel && index === 0 ? 'edit-control' : ''}> |
| | | <MkIcon type={item.PageParam.Icon} /> |
| | | <MkIcon type={item.PageParam ? item.PageParam.Icon : 'folder'} /> |
| | | <span>{item.MenuName}</span> |
| | | </span> |
| | | } |
| | |
| | | <Popover overlayClassName="mk-popover-control-wrap mk-menu-control" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <div style={{display: 'inline-block', minWidth: '32px'}}><AddThdMenu mainMenu={mainMenu} supMenu={item} menuTree={this.props.menuTree}/></div> |
| | | <SwapOutlined onClick={(e) => {this.enterThrEdit(e, item)}} className="mk-swap"/> |
| | | <EditOutlined onClick={(e) => {this.enterThrEdit(e, item)}} className="mk-swap"/> |
| | | <div style={{display: 'inline-block', minWidth: '32px'}}><ThawMenu ParentId={item.MenuID} Type="30"/></div> |
| | | </div> |
| | | } trigger="hover" placement="top"> |
| | |
| | | {item.children.map(cell => { |
| | | return ( |
| | | <Menu.Item key={cell.MenuID}> |
| | | <span className="editable-menu-item" onDoubleClick={() => this.editmenu(cell)}>{cell.MenuName}</span> |
| | | <span className={'editable-menu-item ' + (cell.up_action ? 'unupdate' : '')} onDoubleClick={() => this.editmenu(cell)}>{cell.PageParam && cell.PageParam.interfaces === 'true' ? <ApiOutlined title="菜单中使用了外部接口" /> : null}{cell.MenuName}</span> |
| | | </Menu.Item> |
| | | ) |
| | | })} |
| | |
| | | menulist={this.state.editMenu.children} |
| | | supMenuList={mainMenu.children} |
| | | supMenu={this.state.editMenu} |
| | | menuTree={this.props.menuTree} |
| | | exitEdit={this.exitEdit} |
| | | /> : null |
| | | } |
| | |
| | | <Modal |
| | | title="修改菜单" |
| | | visible={thdVisible} |
| | | width={600} |
| | | width={700} |
| | | onOk={this.thdSubmit} |
| | | confirmLoading={loading} |
| | | onCancel={() => {this.setState({thdVisible: false})}} |
| | |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | mainMenu: state.mainMenu, |
| | | menuTree: state.menuTree, |
| | | editLevel: state.editLevel |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | resetEditLevel: (level) => dispatch(resetEditLevel(level)) |
| | | } |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(Sidemenu) |
| | | export default Sidemenu |