| | |
| | | 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() |
| | | }) |
| | |
| | | } |
| | | 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 |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 |
| | |
| | | resetCardStyle = (card, style) => { |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | if (['text', 'number', 'formula'].includes(_card.eleType)) { |
| | | if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(_card.eleType)) { |
| | | _card.style = style |
| | | let line = _card.height || null |
| | | |
| | | if (['currentDate', 'sequence', 'icon'].includes(_card.eleType)) { |
| | | line = 1 |
| | | } |
| | | |
| | | if (line) { |
| | | let fontSize = 14 |
| | | let lineHeight = 1.5 |
| | | let line = _card.height || null |
| | | |
| | | if (_card.style.fontSize) { |
| | | fontSize = parseInt(_card.style.fontSize) |
| | |
| | | lineHeight = parseFloat(_card.style.lineHeight) |
| | | } |
| | | |
| | | if (line) { |
| | | _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 |
| | | |
| | |
| | | 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) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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)) { |
| | | } else if (['text', 'number', 'formula', 'currentDate', 'sequence', 'icon'].includes(res.eleType)) { |
| | | let line = res.height || null |
| | | |
| | | if (['currentDate', 'sequence', 'icon'].includes(res.eleType)) { |
| | | line = 1 |
| | | } |
| | | |
| | | if (line) { |
| | | let fontSize = 14 |
| | | let lineHeight = 1.5 |
| | | let line = res.height || null |
| | | |
| | | if (res.style && res.style.fontSize) { |
| | | fontSize = parseInt(res.style.fontSize) |
| | |
| | | lineHeight = parseFloat(res.style.lineHeight) |
| | | } |
| | | |
| | | if (line) { |
| | | res.innerHeight = fontSize * lineHeight * line |
| | | } else { |
| | | res.innerHeight = 'auto' |
| | | } |
| | | |
| | | if (res.eleType === 'text' && res.link && !res.style.color) { |
| | |
| | | } |
| | | |
| | | 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) |
| | | |
| | |
| | | <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} |