king
2021-01-07 696d85238a734a4b691f486fde05c93fc5dba3ab
src/menu/popview/index.jsx
@@ -24,7 +24,9 @@
const SourceWrap = asyncComponent(() => import('@/menu/modelsource'))
const MenuShell = asyncComponent(() => import('@/menu/menushell'))
const BgController = asyncComponent(() => import('@/menu/bgcontroller'))
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
sessionStorage.setItem('isEditState', 'true')
@@ -61,6 +63,7 @@
  componentDidMount () {
    MKEmitter.addListener('delButtons', this.delButtons)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -75,6 +78,28 @@
      return
    }
    MKEmitter.removeListener('delButtons', this.delButtons)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
  }
  updateComponentStyle = (parentId, keys, style) => {
    const { config } = this.state
    if (config.uuid !== parentId) return
    let components = config.components.map(item => {
      if (keys.includes(item.uuid)) {
        item.style = {...item.style, ...style}
      }
      return item
    })
    this.setState({
      config: {...config, components: []}
    }, () => {
      this.setState({
        config: {...config, components: components}
      })
    })
  }
  delButtons = (items) => {
@@ -154,6 +179,8 @@
          config: fromJS(config).toJS(),
          openEdition: result.open_edition || '',
        })
        this.props.modifyCustomMenu(config)
      } else {
        notification.warning({
          top: 92,
@@ -241,6 +268,7 @@
  }
  submitConfig = () => {
    const { btn } = this.props
    const { openEdition, delButtons } = this.state
    let config = fromJS(this.state.config).toJS()
@@ -262,14 +290,15 @@
    let _config = fromJS(config).toJS()
    delete _config.tableFields
    let _name = (btn.component.name ? btn.component.name + '-' : '') + btn.label
    let param = {
      func: 'sPC_Tab_AddUpt',
      func: 'sPC_ButtonParam_AddUpt',
      ParentID: btn.config.uuid,
      MenuID: _config.uuid,
      MenuNo: _config.MenuNo,
      MenuNo: _config.MenuNo || '',
      Template: 'CustomPage',
      MenuName: _config.MenuName,
      Remark: '',
      Sort: 0,
      MenuName: _name,
      PageParam: JSON.stringify({Template: 'CustomPage'}),
      LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
    }
@@ -459,6 +488,15 @@
    this.props.modifyCustomMenu(config)
  }
  insert = (item) => {
    let config = fromJS(this.state.config).toJS()
    config.components.push(item)
    this.setState({config})
    this.props.modifyCustomMenu(config)
  }
  render () {
    const { btn } = this.props
    const { activeKey, MenuType, dict, config, menuloading } = this.state
@@ -492,6 +530,8 @@
              <div> {config && config.MenuName} </div>
            } bordered={false} extra={
              <div>
                <StyleCombControlButton menu={config} />
                <PasteController type="menu" Tab={null} insert={this.insert} />
                {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button>