From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/menu/components/group/normal-group/index.jsx | 71 ++++++++--------------------------- 1 files changed, 16 insertions(+), 55 deletions(-) diff --git a/src/menu/components/group/normal-group/index.jsx b/src/menu/components/group/normal-group/index.jsx index 509829e..0544f9d 100644 --- a/src/menu/components/group/normal-group/index.jsx +++ b/src/menu/components/group/normal-group/index.jsx @@ -13,6 +13,7 @@ const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) +const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) const PasteComponent = asyncIconComponent(() => import('../paste')) const GroupComponents = asyncComponent(() => import('../groupcomponents')) @@ -35,8 +36,6 @@ let _group = { uuid: group.uuid, type: group.type, - tabId: group.tabId || '', - parentId: group.parentId || '', subtype: group.subtype, width: 24, name: group.name, @@ -59,12 +58,6 @@ return !is(fromJS(this.state), fromJS(nextState)) } - componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) - MKEmitter.addListener('tabsChange', this.handleTabsChange) - MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) - } - /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -72,42 +65,16 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) - 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 = () => { const { group } = this.state - MKEmitter.emit('changeStyle', [group.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], group.style) + MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow', 'clear'], group.style, this.getStyle) } - getStyle = (comIds, style) => { - const { group } = this.state - - if (comIds.length !== 1 || comIds[0] !== group.uuid) return - - let _card = {...group, style} + getStyle = (style) => { + let _card = {...this.state.group, style} this.setState({ group: _card @@ -116,20 +83,16 @@ 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 @@ -144,8 +107,6 @@ insert = (item) => { let group = fromJS(this.state.group).toJS() - item.parentId = group.parentId - group.components.push(item) this.setState({group}) @@ -159,14 +120,13 @@ } updateWrap = (res) => { - this.updateComponent({...this.state.group, setting: res}) - } + let group = {...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) + if (res.title && !group.headerStyle) { + group.headerStyle = { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' } } + + this.updateComponent(group) } render() { @@ -179,7 +139,8 @@ } 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}> + <NormalHeader hideSearch="true" config={group} updateComponent={this.updateComponent}/> <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}> -- Gitblit v1.8.0