From 66cc7818cf5e13c44f4372e7d47fb72df7d2f752 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 16 九月 2022 10:30:14 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/card/cardcellcomponent/index.jsx | 95 ++++++++++++++++++++++++++--------------------- 1 files changed, 52 insertions(+), 43 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index b2d12a3..20e37de 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -68,19 +68,16 @@ componentDidMount () { MKEmitter.addListener('submitModal', this.handleSave) MKEmitter.addListener('cardAddElement', this.cardAddElement) + MKEmitter.addListener('cardDelElement', this.cardDelElement) MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.cards), fromJS(nextProps.cards)) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props.cards), fromJS(nextProps.cards)) } UNSAFE_componentWillReceiveProps(nextProps) { if (this.props.side !== nextProps.side) { - this.setState({ - elements: fromJS(nextProps.elements).toJS() - }) - } else if (!is(fromJS(this.props.elements), fromJS(nextProps.elements)) && nextProps.elements.length !== this.state.elements.length) { this.setState({ elements: fromJS(nextProps.elements).toJS() }) @@ -96,13 +93,14 @@ } MKEmitter.removeListener('submitModal', this.handleSave) MKEmitter.removeListener('cardAddElement', this.cardAddElement) + MKEmitter.removeListener('cardDelElement', this.cardDelElement) MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) } updateComponentStyle = (parentId, keys, style) => { const { cardCell } = this.props - if (!cardCell || cardCell.uuid !== parentId) return + if (cardCell.uuid !== parentId) return const { elements } = this.state @@ -120,10 +118,18 @@ }) } - cardAddElement = (ids, element) => { - const { cards, cardCell } = this.props + cardDelElement = (id, eleId) => { + const { cardCell } = this.props - if (!ids || ids.length !== 2 || ids[0] !== cards.uuid || ids[1] !== cardCell.uuid) return + if (id !== cardCell.uuid) return + + this.setState({elements: this.state.elements.filter(item => item.uuid !== eleId)}) + } + + cardAddElement = (id, element) => { + const { cardCell } = this.props + + if (id !== cardCell.uuid) return if (window.GLOB.$lock) return window.GLOB.$lock = true @@ -193,35 +199,30 @@ resetCardStyle = (card, style) => { let _card = fromJS(card).toJS() - - if (['text', 'number', 'formula'].includes(_card.eleType)) { - _card.style = style - let fontSize = 14 - let lineHeight = 1.5 + if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(_card.eleType)) { + _card.style = style let line = _card.height || null - if (_card.style.fontSize) { - fontSize = parseInt(_card.style.fontSize) - } - if (_card.style.lineHeight) { - lineHeight = parseFloat(_card.style.lineHeight) + if (['currentDate', 'sequence', 'icon'].includes(_card.eleType)) { + line = 1 } if (line) { + let fontSize = 14 + let lineHeight = 1.5 + + if (_card.style.fontSize) { + fontSize = parseInt(_card.style.fontSize) + } + if (_card.style.lineHeight) { + lineHeight = parseFloat(_card.style.lineHeight) + } + _card.innerHeight = fontSize * lineHeight * line + } else { + _card.innerHeight = 'auto' } - } else if (_card.eleType === 'sequence') { - _card.style = style - - let fontSize = 14 - let lineHeight = 1.5 - - if (_card.style.fontSize) { - fontSize = parseInt(_card.style.fontSize) - } - - _card.innerHeight = fontSize * lineHeight } else if (_card.eleType === 'barcode') { _card.style = style @@ -323,7 +324,7 @@ this.setState({ actvisible: true, card: card, - formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules, anchors) + formlist: getActionForm(card, functip, cards, usefulFields, menulist, modules, anchors) }) } @@ -364,23 +365,30 @@ let _elements = elements.map(cell => { if (cell.uuid === res.uuid) { res.style = cell.style || {} - if (res.eleType === 'splitline' && cell.eleType !== 'splitline') { + if (res.eleType === 'splitline' && (cell.eleType !== 'splitline' || cell.focus)) { res.style.paddingTop = '5px' res.style.paddingBottom = '5px' - } else if (['text', 'number', 'formula'].includes(res.eleType)) { - let fontSize = 14 - let lineHeight = 1.5 + } else if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(res.eleType)) { let line = res.height || null - - if (res.style && res.style.fontSize) { - fontSize = parseInt(res.style.fontSize) - } - if (res.style && res.style.lineHeight) { - lineHeight = parseFloat(res.style.lineHeight) + + if (['currentDate', 'sequence', 'icon'].includes(res.eleType)) { + line = 1 } if (line) { + let fontSize = 14 + let lineHeight = 1.5 + + if (res.style && res.style.fontSize) { + fontSize = parseInt(res.style.fontSize) + } + if (res.style && res.style.lineHeight) { + lineHeight = parseFloat(res.style.lineHeight) + } + res.innerHeight = fontSize * lineHeight * line + } else { + res.innerHeight = 'auto' } if (res.eleType === 'text' && res.link && !res.style.color) { @@ -605,9 +613,10 @@ } dropButton = (id) => { - const { cards } = this.props + const { cards, cardCell } = this.props if (!cards.action) return + if (cardCell.type === 'custom') return let index = cards.action.findIndex(item => item.uuid === id) @@ -690,7 +699,7 @@ <div className="model-menu-card-cell-list"> <DragElement list={elements} - parent={{...cardCell, components: elements}} + parent={cardCell} fields={cards.columns} updateMarks={this.updateMarks} handleList={this.handleList} -- Gitblit v1.8.0