king
2022-10-26 fb64bcf1fab18b33d21470c83f28d4cda8d309ce
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) => {
@@ -290,7 +316,6 @@
   */
  deleteElement = (card) => {
    const { config } = this.props
    const { appType } = this.state
    let _this = this
    confirm({
@@ -305,11 +330,6 @@
        }, () => {
          _this.props.updateaction({...config, action: _actionlist})
        })
        if (card.origin || appType === 'mob') return
        if (appType === 'pc' && card.OpenType !== 'popview') return
        MKEmitter.emit('delButtons', [card.uuid])
      },
      onCancel() {}
    })
@@ -323,7 +343,6 @@
      profVisible: true,
      card: element
    })
    MKEmitter.emit('modalStatus', '验证信息')
  }
  /**
@@ -351,7 +370,6 @@
      }, () => {
        this.props.updateaction({...config, action: _actionlist})
      })
      MKEmitter.emit('modalStatus', false)
    })
  }
@@ -437,7 +455,7 @@
    let btn = null
    let _col = null
    if (config.subtype === 'normaltable' || config.subtype === 'editable' || config.subtype === 'basetable') {
    if (config.type === 'table') {
      config.cols.forEach(col => {
        if (col.type !== 'action') return
@@ -555,11 +573,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