king
2021-09-27 54d01e6ef9ac31f10de4a0e92824eba50b77eda6
src/templates/sharecomponent/columncomponent/index.jsx
@@ -12,6 +12,7 @@
import GridBtnForm from './gridbtnform'
import DragElement from './dragcolumn'
import MarkColumn from './markcolumn'
import MKEmitter from '@/utils/events.js'
import './index.scss'
const { confirm } = Modal
@@ -38,18 +39,6 @@
    this.setState({
      columnlist: fromJS(this.props.config.columns).toJS()
    })
  }
  /**
   * @description 监听到显示列复制时,触发显示列编辑
   */
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { config } = this.props
    const { columnlist } = this.state
    if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) {
      this.setState({columnlist: fromJS(nextProps.config.columns).toJS()})
    }
  }
  /**
@@ -460,8 +449,31 @@
    })
  }
  plusColumns = (MenuId, items) => {
    const { config } = this.props
    const { columnlist } = this.state
    if (MenuId !== config.uuid) return
    let list = [...columnlist, ...items]
    if (list[0] && list[0].origin) {
      list = list.filter(col => !col.origin)
    }
    this.setState({
      columnlist: list
    }, () => {
      this.props.updatecolumn({...config, columns: list})
    })
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
  componentDidMount () {
    MKEmitter.addListener('plusColumns', this.plusColumns)
  }
  /**
@@ -471,6 +483,7 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('plusColumns', this.plusColumns)
  }
  render() {