From 0a0372f158b7a4c786c67be6a6e3c84ff7608904 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 07 一月 2021 10:35:10 +0800 Subject: [PATCH] 2021-01-07 --- src/menu/stylecombcontrolbutton/index.jsx | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/menu/stylecombcontrolbutton/index.jsx b/src/menu/stylecombcontrolbutton/index.jsx index d8c6c16..eee97c5 100644 --- a/src/menu/stylecombcontrolbutton/index.jsx +++ b/src/menu/stylecombcontrolbutton/index.jsx @@ -18,6 +18,7 @@ } componentDidMount () { + sessionStorage.setItem('style-control', 'false') MKEmitter.addListener('clickComponent', this.clickComponent) MKEmitter.addListener('submitCombineStyle', this.submitCombineStyle) } @@ -34,13 +35,50 @@ } submitCombineStyle = (style) => { - const { components } = this.state + const { menu } = this.props + const { components, parent } = this.state - components.forEach((item, i) => { - setTimeout(() => { - MKEmitter.emit('submitStyle', [item.uuid], {...item.style, ...style}) - }, i * 5) + let _parent = null + let getParents = (box) => { + box.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.uuid === parent.uuid) { + _parent = tab + } else { + getParents(tab) + } + }) + } else if (item.type === 'group') { + if (item.uuid === parent.uuid) { + _parent = item + } + } + }) + } + + if (menu.uuid === parent.uuid) { + _parent = menu + } else { + getParents(menu) + } + + let keys = components.map(item => item.uuid) + + _parent.components = _parent.components.map(item => { + if (keys.includes(item.uuid)) { + item.style = {...item.style, ...style} + } + return item }) + + MKEmitter.emit('submitComponentStyle', _parent) + + setTimeout(() => { + keys.forEach(key => { + document.getElementById(key).classList.add('selected-control-element') + }) + }, 100) } clickComponent = (card) => { @@ -90,6 +128,10 @@ document.getElementById(card.uuid).classList.add('selected-control-element') } + if (components.length === 0) { + MKEmitter.emit('closeCombineStyle') + } + this.setState({ components: components, parent: components.length ? parent : null -- Gitblit v1.8.0