king
2022-10-25 5891206952e2ff63e87aed2f47df5324b019d32e
src/menu/components/share/actioncomponent/index.jsx
@@ -60,17 +60,9 @@
  }
  componentDidMount () {
    MKEmitter.addListener('revert', this.revert)
    MKEmitter.addListener('addButton', this.addButton)
  }
  /**
   * @description 监听到按钮复制时,触发按钮编辑
   */
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { actionlist } = this.state
    if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
    }
    MKEmitter.addListener('submitModal', this.handleSave)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -84,7 +76,41 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('revert', this.revert)
    MKEmitter.removeListener('addButton', this.addButton)
    MKEmitter.removeListener('submitModal', this.handleSave)
  }
  revert = () => {
    this.setState({
      actionlist: fromJS(this.props.config.action).toJS()
    })
  }
  handleSave = (componentId, btnId, modal) => {
    const { config } = this.props
    if (config.uuid !== componentId) return
    const { actionlist } = this.state
    let _index = actionlist.findIndex(cell => cell.uuid === btnId)
    if (_index === -1) return
    let _actionlist = actionlist.map(cell => {
      if (cell.uuid === btnId) {
        cell.modal = modal
      }
      return cell
    })
    this.setState({
      actionlist: _actionlist
    }, () => {
      this.props.updateaction({...config, action: _actionlist})
    })
  }
  getStyle = (style) => {
@@ -323,7 +349,6 @@
      profVisible: true,
      card: element
    })
    MKEmitter.emit('modalStatus', '验证信息')
  }
  /**
@@ -351,7 +376,6 @@
      }, () => {
        this.props.updateaction({...config, action: _actionlist})
      })
      MKEmitter.emit('modalStatus', false)
    })
  }
@@ -555,11 +579,9 @@
            if (this.verifyRef.handleCancel) {
              this.verifyRef.handleCancel().then(() => {
                this.setState({ profVisible: false })
                MKEmitter.emit('modalStatus', false)
              })
            } else {
              this.setState({ profVisible: false })
              MKEmitter.emit('modalStatus', false)
            }
          }}
          destroyOnClose