king
2021-08-26 966ff7fb84181f0fa86a56569a8492453c3ae80a
src/views/menudesign/index.jsx
@@ -8,7 +8,7 @@
import Api from '@/api'
import options from '@/store/options.js'
import Utils from '@/utils/utils.js'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
import antdEnUS from 'antd/es/locale/en_US'
@@ -34,6 +34,7 @@
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent'))
const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
@@ -47,6 +48,7 @@
sessionStorage.setItem('appType', '')          // 应用类型
document.body.className = ''
window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件
window.GLOB.TabsMap = new Map()          // 缓存用户操作的标签页
window.GLOB.urlFields = []               // url变量
window.GLOB.customMenu = null            // 保存菜单信息
@@ -67,7 +69,8 @@
    config: null,
    popBtn: null,             // 弹窗标签页
    visible: false,
    customComponents: []
    customComponents: [],
    comloading: false
  }
  UNSAFE_componentWillMount() {
@@ -101,11 +104,13 @@
    MKEmitter.addListener('thawButtons', this.thawButtons)
    MKEmitter.addListener('copyButtons', this.copyButtons)
    MKEmitter.addListener('changePopview', this.initPopview)
    MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
    setTimeout(() => {
      this.updateCustomComponent()
      this.getAppPictures()
      setGLOBFuncs()
    }, 1000)
  }
@@ -120,8 +125,15 @@
    MKEmitter.removeListener('thawButtons', this.thawButtons)
    MKEmitter.removeListener('copyButtons', this.copyButtons)
    MKEmitter.removeListener('changePopview', this.initPopview)
    MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
    MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
  }
  triggerMenuSave = () => {
    if (this.state.visible) return
    this.submitConfig()
  }
  getAppPictures = () => {
@@ -201,21 +213,17 @@
    })
    this.setState({
      config: {...config, components: []}
      config: {...config, components},
      comloading: true
    }, () => {
      this.setState({
        config: {...config, components: components}
        comloading: false
      })
    })
  }
  delButtons = (items) => {
    const { copyButtons } = this.state
    this.setState({
      delButtons: [...this.state.delButtons, ...items],
      copyButtons: copyButtons.filter(item => !items.includes(item.uuid))
    })
    this.setState({ delButtons: [...this.state.delButtons, ...items] })
  }
  copyButtons = (items) => {
@@ -396,6 +404,13 @@
              _sort++
            })
          })
        } else if (item.type === 'balcony') {
          item.elements && item.elements.forEach(cell => {
            if (cell.eleType !== 'button') return
            this.checkBtn(cell)
            buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`)
            _sort++
          })
        } else if (item.type === 'line' || item.type === 'bar') {
          item.action && item.action.forEach(btn => {
            this.checkBtn(btn)
@@ -510,7 +525,7 @@
        EasyCode: config.easyCode || '',
        Template: 'CustomPage',
        MenuName: config.MenuName || '',
        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab'}),
        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}),
        LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))),
        open_edition: config.open_edition,
        LText: '',
@@ -647,7 +662,8 @@
        if (res.status) {
          config.open_edition = res.open_edition || ''
          this.setState({
            oriConfig: fromJS(config).toJS()
            config,
            oriConfig: fromJS(config).toJS(),
          })
          if (btnParam.LText) {
@@ -764,12 +780,7 @@
            delButtons: [],
            copyButtons: [],
            thawButtons: [],
            menuloading: false,
            config: {...config, components: []}
          }, () => {
            this.setState({
              config: {...this.state.config, components: this.state.oriConfig.components}
            })
            menuloading: false
          })
          notification.success({
            top: 92,
@@ -781,6 +792,7 @@
            menuloading: false
          })
        }
        MKEmitter.emit('completeSave')
      })
    }, 300)
  }
@@ -844,7 +856,8 @@
          check(item.components)
          return
        }
        if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && item.wrap.datatype === 'static') return
        if (['propcard', 'brafteditor', 'sandbox', 'stepform', 'tabform'].includes(item.subtype) && item.wrap.datatype === 'static') return
        if (['balcony'].includes(item.type) && item.wrap.datatype === 'static') return
  
        if (item.setting) {
          if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) {
@@ -890,6 +903,18 @@
    window.GLOB.customMenu = config
  }
  resetConfig = (config) => {
    this.setState({
      config,
      comloading: true
    }, () => {
      this.setState({
        comloading: false
      })
    })
    window.GLOB.customMenu = config
  }
  insert = (item) => {
    let config = fromJS(this.state.config).toJS()
@@ -900,7 +925,7 @@
  }
  render () {
    const { activeKey, MenuType, popBtn, visible, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading, customComponents } = this.state
    const { activeKey, comloading, MenuType, popBtn, visible, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading, customComponents } = this.state
    return (
      <ConfigProvider locale={_locale}>
@@ -959,6 +984,7 @@
                  <div> {config && config.MenuName} </div>
                } bordered={false} extra={
                  <div>
                    <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                    <SysInterface config={config} updateConfig={this.updateConfig}/>
                    <PictureController/>
                    <StyleCombControlButton menu={config} />
@@ -968,7 +994,7 @@
                    <Button type="default" onClick={this.closeView}>关闭</Button>
                  </div>
                } style={{ width: '100%' }}>
                  {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null}
                  {config && !comloading ? <MenuShell menu={config} handleList={this.updateConfig} /> : null}
                </Card>
              </div>
            </div>