From d7534812c8199bf1e9faa0279b63e434737d6374 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 16 四月 2021 16:06:27 +0800 Subject: [PATCH] 2021-04-16 --- src/menu/components/card/cardcellcomponent/index.jsx | 71 +++++++++-------------------------- 1 files changed, 19 insertions(+), 52 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 1dc901b..ceed38c 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -47,9 +47,18 @@ */ UNSAFE_componentWillMount () { const { elements } = this.props + let _elements = fromJS(elements).toJS() this.setState({ - elements: fromJS(elements).toJS() + elements: _elements.map(item => { + if (item.btnstyle) { // 鍏煎 + item.style = item.style || {} + item.style = {...item.style, ...item.btnstyle} + delete item.btnstyle + } + + return item + }) }) } @@ -129,9 +138,7 @@ let options = ['font', 'border', 'padding', 'margin', 'backgroundColor'] if (element.eleType === 'button') { - if (element.btnstyle) { - _style = {..._style, ...element.btnstyle} - } + } else if (element.eleType === 'picture') { options = ['border', 'margin'] } else if (element.eleType === 'slider') { @@ -198,47 +205,7 @@ _card.innerHeight = _card.barHeight + (_card.displayValue === 'true' ? fontSize + 2 : 0) } else if (_card.eleType === 'button') { // 鎷嗗垎style - let _style = fromJS(style).toJS() - _card.style = {} - - if (_style.marginTop) { - _card.style.marginTop = _style.marginTop - delete _style.marginTop - } - if (_style.marginBottom) { - _card.style.marginBottom = _style.marginBottom - delete _style.marginBottom - } - if (_style.marginLeft) { - _card.style.marginLeft = _style.marginLeft - delete _style.marginLeft - } - if (_style.marginRight) { - _card.style.marginRight = _style.marginRight - delete _style.marginRight - } - if (_style.paddingTop) { - _card.style.paddingTop = _style.paddingTop - delete _style.paddingTop - } - if (_style.paddingBottom) { - _card.style.paddingBottom = _style.paddingBottom - delete _style.paddingBottom - } - if (_style.paddingLeft) { - _card.style.paddingLeft = _style.paddingLeft - delete _style.paddingLeft - } - if (_style.paddingRight) { - _card.style.paddingRight = _style.paddingRight - delete _style.paddingRight - } - if (_style.textAlign) { - _card.style.textAlign = _style.textAlign - delete _style.textAlign - } - - _card.btnstyle = _style + _card.style = style } else { _card.style = style } @@ -404,18 +371,18 @@ if (cell.uuid === res.uuid) { res = {...cell, ...res} delete res.focus - let btnstyle = {} + let style = {} - if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) { + if (res.class !== cell.class || res.show !== cell.show || !res.style) { if (res.show === 'link' || res.show === 'icon') { - btnstyle.color = color[res.class] - btnstyle.backgroundColor = 'transparent' + style.color = color[res.class] + style.backgroundColor = 'transparent' } else { - btnstyle.color = '#ffffff' - btnstyle.backgroundColor = color[res.class] + style.color = '#ffffff' + style.backgroundColor = color[res.class] } } - res.btnstyle = {...res.btnstyle, ...btnstyle} + res.style = {...res.style, ...style} return res } -- Gitblit v1.8.0