king
2022-07-28 fce4de633059cb57ab89ede8f6d63c77afa19cda
src/views/design/sidemenu/editthdmenu/index.jsx
@@ -10,8 +10,6 @@
import Api from '@/api'
import MKEmitter from '@/utils/events.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import MkIcon from '@/components/mk-icon'
import Utils from '@/utils/utils.js'
import MenuUtils from '@/utils/utils-custom.js'
@@ -20,12 +18,6 @@
import './index.scss'
const MenuForm = asyncLoadComponent(() => import('../thdmenuform'))
const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig'))
const TreePageConfig = asyncLoadComponent(() => import('@/templates/treepageconfig'))
const CalendarPageConfig = asyncLoadComponent(() => import('@/templates/calendarconfig'))
const FormTabConfig = asyncLoadComponent(() => import('@/templates/formtabconfig'))
const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig'))
const SubTable = asyncLoadComponent(() => import('@/templates/subtableconfig'))
const { confirm } = Modal
@@ -38,21 +30,9 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    confirmLoading: false,  // 提交中。。。
    loading: false,         // 编辑菜单或使用已使用模板时,获取配置信息
    btnParam: null,         // 编辑按钮的配置信息
    menulist: null,         // 编辑中的菜单
    tabview: '',            // 选择模板窗口(template)、基础表格配置(CommonTable)、表单(Modal)、子表(SubTable)
    editMenu: null,         // 编辑菜单
    editAction: null,       // 编辑按钮
    editTab: null,          // 编辑标签
    tabConfig: null,        // 标签配置信息
    editSubTab: null,       // 编辑子标签(标签中的标签)
    subTabConfig: null,     // 子标签配置信息
    subConfig: null,        // 子配置信息
    btnTab: null,           // 打开新标签或当前页面刷新的按钮
    btnTabConfig: null,     // 打开新标签按钮配置
    handleMVisible: false,  // 添加或修改菜单模态框(角色权限分配等)
    sysMenu: null,          // 添加或编辑菜单(角色权限分配等)
    change: false
@@ -87,7 +67,7 @@
    if (this.state.change) {
      notification.warning({
        top: 92,
        message: this.state.dict['model.menu.presave'],
        message: '菜单顺序已调整,请保存!',
        duration: 5
      })
      return
@@ -131,69 +111,24 @@
          handleMVisible: true,
          sysMenu: _menu
        })
      } else if (['CommonTable', 'TreePage', 'CalendarPage'].includes(_menu.PageParam.Template)) {
        sessionStorage.setItem('menuTree', JSON.stringify(this.props.menuTree))
        let _param = window.btoa(window.encodeURIComponent(JSON.stringify(_menu)))
        return
        window.open(`#/basedesign/${_param}`)
      } else if (_menu.PageParam.Template === 'CustomPage') {
        let _param = {
          MenuType: 'custom',
          MenuId: _menu.MenuID,
          ParentId: _menu.ParentId,
          MenuName: _menu.MenuName,
          MenuNo: _menu.MenuNo
        }
        _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
        window.open(`#/menudesign/${_param}`)
      }
      // let _param = ''
      // if (card.type === 'CustomPage') {
      //   _param = {
      //     MenuType: 'custom',
      //     MenuId: card.MenuID,
      //     ParentId: card.ParentId,
      //     MenuName: card.MenuName,
      //     MenuNo: card.MenuNo
      //   }
      //   _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
      // }
      // window.open(`#/menudesign/${_param}`)}
      // let param = {
      //   func: 'sPC_Get_LongParam',
      //   MenuID: _menu.MenuID
      // }
      // this.setState({
      //   loading: true
      // })
      // Api.getSystemConfig(param).then(res => {
      //   if (res.status) {
      //     let _LongParam = ''
      //     if (res.LongParam) {
      //       try {
      //         _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
      //       } catch (e) {
      //         console.warn('Parse Failure')
      //         _LongParam = ''
      //       }
      //     }
      //     _menu.LongParam = _LongParam
      //     _menu.fstMenuId = _menu.FstId
      //     _menu.supMenuList = this.props.supMenuList
      //     _menu.fstMenuList = this.props.menuTree
      //     _menu.open_edition = res.open_edition || ''
      //     this.setState({
      //       editMenu: _menu,
      //       loading: false,
      //       tabview: _menu.PageParam.Template
      //     }, () => {
      //       document.getElementById('root').style.overflowY = 'hidden'
      //     })
      //   } else {
      //     this.setState({
      //       loading: false
      //     })
      //     notification.warning({
      //       top: 92,
      //       message: res.message,
      //       duration: 5
      //     })
      //   }
      // })
    }
  }
@@ -248,30 +183,11 @@
    }
  }
  exittabview = () => {
    this.setState({tabview: ''})
    document.getElementById('root').style.overflowY = 'unset'
  }
  handleView = (param) => {
    this.setState({
      tabview: ''
    }, () => {
      if (param) {
        this.setState(param)
        document.getElementById('root').style.overflowY = 'hidden'
      } else {
        document.getElementById('root').style.overflowY = 'unset'
      }
    })
  }
  /**
   * @description 三级菜单添加或修改
   */
  memuSubmit = () => {
    const { sysMenu } = this.state
    let sysTemplates = fromJS(this.state.sysTemplates).toJS()
    this.menuFormRef.handleConfirm().then(res => {
      let PageParam = {
@@ -309,11 +225,9 @@
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          this.setState({
            sysTemplates: sysTemplates,
            confirmLoading: false,
            handleMVisible: false,
            sysMenu: '',
            tabview: ''
            sysMenu: null
          })
          MKEmitter.emit('mkUpdateMenuList')
@@ -365,8 +279,7 @@
            this.setState({
              confirmLoading: false,
              handleMVisible: false,
              sysMenu: '',
              tabview: ''
              sysMenu: null
            })
  
            MKEmitter.emit('mkUpdateMenuList')
@@ -430,62 +343,6 @@
          <Button type="primary" className="mk-save-menu" disabled={!change} onClick={() => {this.handleSubBtn('confirm')}}>保存</Button>
          <Button onClick={() => {this.handleSubBtn('close')}}>关闭</Button>
        </div>
        {this.state.tabview === 'TreePage' ?
          <TreePageConfig
            menu={this.state.editMenu}
            reloadmenu={() => {MKEmitter.emit('mkUpdateMenuList')}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'CalendarPage' ?
          <CalendarPageConfig
            menu={this.state.editMenu}
            reloadmenu={() => {MKEmitter.emit('mkUpdateMenuList')}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'CommonTable' ?
          <ComTableConfig
            menu={this.state.editMenu}
            reloadmenu={() => {MKEmitter.emit('mkUpdateMenuList')}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'Modal' ?
          <ModalConfig
            menu={this.state.editMenu}
            editTab={this.state.editTab}
            tabConfig={this.state.tabConfig}
            editSubTab={this.state.editSubTab}
            subTabConfig={this.state.subTabConfig}
            btnTab={this.state.btnTab}
            btnTabConfig={this.state.btnTabConfig}
            editAction={this.state.editAction}
            subConfig={this.state.subConfig}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'SubTable' ?
          <SubTable
            menu={this.state.editMenu}
            editTab={this.state.editTab}
            editSubTab={this.state.editSubTab}
            tabConfig={this.state.tabConfig}
            btnTab={this.state.btnTab}
            btnTabConfig={this.state.btnTabConfig}
            config={this.state.subConfig}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'FormTab' ?
          <FormTabConfig
            menu={this.state.editMenu}
            btnTab={this.state.btnTab}
            config={this.state.subConfig}
            handleView={this.handleView}
          /> : null
        }
        {/* 添加系统菜单 */}
        <Modal
          title="修改菜单"