king
2024-02-04 0bbaa727cdfc65622e33e91c4bf694c83f184535
src/views/design/sidemenu/index.jsx
@@ -1,12 +1,10 @@
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'
@@ -46,8 +44,15 @@
    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({
@@ -102,6 +107,8 @@
  }
  editmenu = (cell) => {
    if (window.GLOB.systemType === 'production') return
    if (cell.type === 'CustomPage') {
      let _param = {
        MenuType: 'custom',
@@ -112,7 +119,12 @@
      }
      _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)))
@@ -130,6 +142,12 @@
        thdVisible: true,
        loading: false,
        sysMenu: _cell
      })
    } else {
      notification.warning({
        top: 92,
        message: '当前菜单不可编辑',
        duration: 5
      })
    }
  }
@@ -182,7 +200,7 @@
      this.setState({
        loading: true
      })
      Api.getSystemConfig(param).then(res => {
      Api.getCloudConfig(param).then(res => {
        if (res.status) {
          this.setState({
            loading: false,
@@ -236,13 +254,13 @@
      }
      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,
@@ -276,7 +294,7 @@
            <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">
@@ -289,7 +307,7 @@
                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>
                }
@@ -298,7 +316,7 @@
                  <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">
@@ -308,7 +326,7 @@
                {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>
                  )
                })}
@@ -329,6 +347,7 @@
            menulist={this.state.editMenu.children}
            supMenuList={mainMenu.children}
            supMenu={this.state.editMenu}
            menuTree={this.props.menuTree}
            exitEdit={this.exitEdit}
          /> : null
        }
@@ -349,7 +368,7 @@
        <Modal
          title="修改菜单"
          visible={thdVisible}
          width={600}
          width={700}
          onOk={this.thdSubmit}
          confirmLoading={loading}
          onCancel={() => {this.setState({thdVisible: false})}}
@@ -366,18 +385,4 @@
  }
}
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