From 54d01e6ef9ac31f10de4a0e92824eba50b77eda6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 27 九月 2021 18:40:51 +0800 Subject: [PATCH] 2021-09-27 --- src/templates/sharecomponent/columncomponent/index.jsx | 37 +++++++++++++++++++++++++------------ 1 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index 50d7df2..63a0a8d 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/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() { -- Gitblit v1.8.0