From fa381753ef2a2b25b1c0722549ac17e333da79be Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 22:50:54 +0800 Subject: [PATCH] 2022-09-06 --- src/menu/components/module/voucher/index.jsx | 52 +++++++++++++--------------------------------------- 1 files changed, 13 insertions(+), 39 deletions(-) diff --git a/src/menu/components/module/voucher/index.jsx b/src/menu/components/module/voucher/index.jsx index e150d22..ccc29e7 100644 --- a/src/menu/components/module/voucher/index.jsx +++ b/src/menu/components/module/voucher/index.jsx @@ -42,27 +42,20 @@ width: card.width || 12, name: '鍑瘉', subtype: card.subtype, - // setting: { interType: 'system' }, + setting: { interType: 'system' }, wrap: { name: '鍑瘉', title: '', width: card.width || 12, type: 'edit' }, style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, headerStyle: {}, columns: [], scripts: [], } - - this.setState({ - card: _card - }) - this.props.updateConfig(_card) + + this.updateComponent(_card) } else { this.setState({ card: fromJS(card).toJS() }) } - } - - componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) } shouldComponentUpdate (nextProps, nextState) { @@ -76,51 +69,32 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) } /** * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級 */ - updateComponent = (component) => { + updateComponent = (card) => { + card.width = card.wrap.width + card.name = card.wrap.name + this.setState({ - card: component + card: card }) - component.width = component.wrap.width - component.name = component.wrap.name - - this.props.updateConfig(component) + this.props.updateConfig(card) } changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], card.style) + MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle) } - getStyle = (comIds, style) => { - const { card } = this.state - - if (comIds[0] !== card.uuid || comIds.length !== 1) return - - let _card = {...card, style} - - this.setState({ - card: _card - }) + getStyle = (style) => { + let _card = {...this.state.card, style} - this.props.updateConfig(_card) - } - - /** - * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 - */ - updateconfig = (config) => { - this.setState({ - card: config - }) - this.props.updateConfig(config) + this.updateComponent(_card) } getWrapForms = () => { -- Gitblit v1.8.0