| | |
| | | let _group = { |
| | | uuid: group.uuid, |
| | | type: group.type, |
| | | tabId: group.tabId || '', |
| | | parentId: group.parentId || '', |
| | | subtype: group.subtype, |
| | | width: 24, |
| | | name: group.name, |
| | |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新,清除快捷键设置 |
| | | */ |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { group } = this.state |
| | | |
| | | if (group.uuid !== parentId) return |
| | | |
| | | let components = group.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | group: {...group, components: []} |
| | | }, () => { |
| | | this.updateComponent({...group, components: components}) |
| | | }) |
| | | } |
| | | |
| | | changeStyle = () => { |
| | |
| | | this.props.updateConfig(_card) |
| | | } |
| | | |
| | | handleTabsChange = (parentId) => { |
| | | const { group } = this.state |
| | | |
| | | if (parentId === group.parentId) { |
| | | MKEmitter.emit('tabsChange', group.uuid) |
| | | } |
| | | } |
| | | |
| | | updateComponent = (component) => { |
| | | const { group } = this.state |
| | | |
| | | if (!is(fromJS(group.setting), fromJS(component.setting)) || !is(fromJS(group.style), fromJS(component.style))) { |
| | | // 注册事件-标签变化,通知组内元素 |
| | | MKEmitter.emit('tabsChange', group.uuid) |
| | | let ids = [] |
| | | group.components.forEach(item => { |
| | | ids.push(item.uuid) |
| | | }) |
| | | MKEmitter.emit('tabsChange', ids.join(',')) |
| | | } |
| | | |
| | | component.width = component.setting.width |
| | |
| | | |
| | | insert = (item) => { |
| | | let group = fromJS(this.state.group).toJS() |
| | | |
| | | item.parentId = group.parentId |
| | | |
| | | group.components.push(item) |
| | | |
| | |
| | | this.updateComponent({...this.state.group, setting: res}) |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.group) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { group } = this.state |
| | | let _style = resetStyle(group.style) |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className={'menu-group-edit-box ' + (paddingTop ? 'padding ' : '') + (group.setting.layout || '')} style={_style} onClick={this.clickComponent} id={group.uuid}> |
| | | <div className={'menu-group-edit-box ' + (paddingTop ? 'padding ' : '') + (group.setting.layout || '')} style={_style} id={group.uuid}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <NormalForm title="分组设置" width={700} update={this.updateWrap} getForms={this.getWrapForms}> |