king
2021-12-22 bd1dfc9e6c9b9f8076ca2783ce598e0936b4c664
src/templates/menuconfig/editthdmenu/index.jsx
@@ -5,7 +5,8 @@
import { DndProvider } from 'react-dnd'
import { withRouter } from 'react-router-dom'
import HTML5Backend from 'react-dnd-html5-backend'
import { notification, Modal, Button, Spin, Icon, Col, Card, Tabs, Row, Input } from 'antd'
import { notification, Modal, Button, Spin, Col, Card, Tabs, Row, Input } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
@@ -16,11 +17,12 @@
import treepage from '@/assets/img/treepage.jpg'
import calendar from '@/assets/img/calendar.jpg'
import customImg from '@/assets/img/custom.jpg'
import MkIcon from '@/components/mk-icon'
import Preview from './preview'
import MenuForm from './menuform'
import TransferForm from '@/templates/zshare/basetransferform'
import Utils from '@/utils/utils.js'
import MenuUtils from '@/utils/utils-custom.js'
import DragElement from '../menuelement'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import './index.scss'
@@ -52,7 +54,7 @@
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    thawmenulist: null,     // 已冻结的二级菜单
    type: '',               // 操作类型,新建或编辑菜单
    thawMvisible: false,    // 解除冻结模态框
@@ -78,6 +80,7 @@
    btnTabConfig: null,     // 打开新标签按钮配置
    handleMVisible: false,  // 添加或修改菜单模态框(角色权限分配等)
    sysMenu: false,         // 添加或编辑菜单(角色权限分配等)
    targetKeys: []          // 解冻菜单列表
  }
  /**
@@ -190,7 +193,7 @@
          if (_Template.length === 0) {
            notification.warning({
              top: 92,
              message: this.state.dict['model.menu.template.empty'],
              message: '菜单模板丢失,请重新选择模板!',
              duration: 5
            })
@@ -267,7 +270,8 @@
        return
      }
      this.setState({
        thawMvisible: true
        thawMvisible: true,
        targetKeys: []
      })
      Api.getSystemConfig({
        func: 'sPC_Get_FrozenMenu',
@@ -346,8 +350,9 @@
  }
  thawMemuSubmit = () => {
    const { targetKeys } = this.state
    // 三级菜单解除冻结
    if (this.refs.trawmenu.state.targetKeys.length === 0) {
    if (targetKeys.length === 0) {
      notification.warning({
        top: 92,
        message: this.state.dict['form.required.select'] + this.state.dict['model.menu'],
@@ -357,7 +362,7 @@
      this.setState({
        confirmLoading: true
      })
      let defers = this.refs.trawmenu.state.targetKeys.map(item => {
      let defers = targetKeys.map(item => {
        return new Promise((resolve) => {
          Api.getSystemConfig({
            func: 'sPC_MainMenu_ReDel',
@@ -383,6 +388,7 @@
          this.setState({
            confirmLoading: false,
            thawMvisible: false,
            targetKeys: [],
            thawmenulist: null
          })
          this.props.reload()
@@ -395,7 +401,8 @@
    // 解除冻结-取消
    this.setState({
      thawMvisible: false,
      thawmenulist: null
      thawmenulist: null,
      targetKeys: []
    })
  }
@@ -559,7 +566,7 @@
        } else if (temp.Template === 'CustomPage' && memberLevel < 20) {
          return
        }
        _templates.push({
          uuid: temp.MenuID,
          title: temp.MenuName,
@@ -611,7 +618,7 @@
    let sysTemplates = fromJS(this.state.sysTemplates).toJS()
    // 角色权限分配模板,只可以添加一次
    if (sysMenu.isSystem && sysMenu.Template === 'RolePermission') {
    if (sysMenu.isSystem && (sysMenu.Template === 'RolePermission')) {
      sysTemplates = sysTemplates.map(temp => {
        if (temp.type === sysMenu.type) {
          temp.hidden = true
@@ -627,9 +634,7 @@
        OpenType: 'newtab'
      }
      if (sysMenu.OriginMenuId && sysMenu.Template === 'CustomPage') {
        PageParam.originMenuId = sysMenu.OriginMenuId
      } else if (sysMenu.Template === 'NewPage') {
      if (sysMenu.Template === 'NewPage') {
        PageParam.OpenType = 'NewPage'
        PageParam.url = res.url
      }
@@ -660,28 +665,96 @@
        confirmLoading: true
      })
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          this.setState({
            sysTemplates: sysTemplates,
            confirmLoading: false,
            handleMVisible: false,
            sysMenu: '',
            tabview: ''
          })
      if (sysMenu.Template === 'CustomPage' && sysMenu.OriginMenuId) {
        this.copyMenu(param, sysMenu.OriginMenuId)
      } else {
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
              sysTemplates: sysTemplates,
              confirmLoading: false,
              handleMVisible: false,
              sysMenu: '',
              tabview: ''
            })
            this.props.reload()
            document.getElementById('root').style.overflowY = 'unset'
          } else {
            this.setState({
              confirmLoading: false
            })
            notification.warning({
              top: 92,
              message: response.message,
              duration: 5
            })
          }
        })
      }
    })
  }
          this.props.reload()
        } else {
          this.setState({
            confirmLoading: false
          })
          notification.warning({
            top: 92,
            message: response.message,
            duration: 5
          })
  copyMenu = (param, MenuId) => {
    Api.getSystemConfig({
      func: 'sPC_Get_LongParam',
      MenuID: MenuId
    }).then(result => {
      if (result.status) {
        let config = null
        try {
          config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null
        } catch (e) {
          console.warn('Parse Failure')
          config = null
        }
      })
        if (config) {
          config.uuid = param.MenuID
          config.MenuID = param.MenuID
          config.parentId = param.ParentID
          config.MenuName = param.MenuName
          config.MenuNo = param.MenuNo
          config.easyCode = ''
          config.components = MenuUtils.resetConfig(config.components)
          config.enabled = false
          param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(config)))
        }
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
              confirmLoading: false,
              handleMVisible: false,
              sysMenu: '',
              tabview: ''
            })
            this.props.reload()
            document.getElementById('root').style.overflowY = 'unset'
          } else {
            this.setState({
              confirmLoading: false
            })
            notification.warning({
              top: 92,
              message: response.message,
              duration: 5
            })
          }
        })
      } else {
        this.setState({
          confirmLoading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
      }
    })
  }
@@ -722,13 +795,13 @@
            <div className="tipcard card5" style={{backgroundImage: 'url(' + card5 + ')'}}>
              <p>编辑状态中,菜单之外区域会锁定,查看系统数据请点击。</p>
              <div>
                <a target="blank" href="#/main" >新页面</a>
                <span className="new-view" onClick={() => {window.open('#/main')}} >新页面</span>
              </div>
            </div>
          </div> : null
        }
        <div className="cus-submenu-title">
          <Icon type={this.props.supMenu.PageParam.Icon} />
          <MkIcon type={this.props.supMenu.PageParam.Icon} />
          <span>{this.props.supMenu.MenuName}</span>
        </div>
        <DndProvider backend={HTML5Backend}>
@@ -739,7 +812,7 @@
          />
        </DndProvider>
        <div className="menu-add" onClick={() => {this.handleSubBtn('add')}}>
          <Icon type="plus" />
          <PlusOutlined />
        </div>
        <div className="menu-btn">
          <Button type="primary" onClick={() => {this.handleSubBtn('thaw')}}>{dict['model.thaw'] + dict['model.menu']}</Button>
@@ -868,7 +941,7 @@
          destroyOnClose
        >
          {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
          {this.state.thawmenulist && <TransferForm ref="trawmenu" menulist={this.state.thawmenulist}/>}
          {this.state.thawmenulist && <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>}
        </Modal>
        {/* 添加系统菜单 */}
        <Modal