From e48aea038c964573854c6479999d7838830f1f26 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 11 四月 2023 15:01:38 +0800 Subject: [PATCH] 2023-04-11 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 88 +++++++++++++++++++++---------------------- 1 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index d997633..fb48b4b 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -35,6 +35,37 @@ '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%' } +class TextCell extends Component { + componentDidMount() { + if (this.node && this.node.scrollHeight > this.node.offsetHeight) { + this.node.style.display = 'block' + } + } + + componentDidUpdate() { + if (this.node) { + if (this.node.scrollHeight > this.node.offsetHeight) { + this.node.style.display = 'block' + } else { + this.node.style.display = 'flex' + } + } + } + + render() { + const { card, className, value } = this.props + + let lineStyle = {height: card.innerHeight} + lineStyle.display = 'flex' + lineStyle.alignItems = card.alignItems + lineStyle.justifyContent = card.style.textAlign || 'left' + + return ( + <div ref={ref => this.node = ref} className={className} style={lineStyle}>{value}</div> + ) + } +} + class CardCellComponent extends Component { static propTpyes = { cards: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 @@ -257,7 +288,7 @@ ) } else if (card.eleType === 'text') { let val = '' - let _style = card.style ? {...card.style} : {} + let _style = {...card.style} if (card.datatype === 'static') { val = card.value || '' @@ -400,24 +431,18 @@ if (card.bgImage && data[card.bgImage]) { _style.backgroundImage = `url('${data[card.bgImage]}')` } - - let lineStyle = {height: card.innerHeight || 'auto'} - if (card.alignItems) { - lineStyle.display = 'flex' - lineStyle.alignItems = card.alignItems - lineStyle.justifyContent = _style.textAlign || 'left' - } contents.push( <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> - <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> + {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : + <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} </div> </div> ) } else if (card.eleType === 'number') { let val = '' - let _style = card.style ? {...card.style} : {} + let _style = {...card.style} if (card.datatype === 'static') { val = card.value @@ -478,24 +503,17 @@ className = mark.signType } - let lineStyle = {height: card.innerHeight || 'auto'} - if (card.alignItems) { - lineStyle.display = 'flex' - lineStyle.alignItems = card.alignItems - lineStyle.justifyContent = _style.textAlign || 'left' - } - contents.push( <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> <div style={_style}> - <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> + {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : + <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} </div> </div> ) } else if (card.eleType === 'icon') { let val = '' let icon = '' - let height = card.innerHeight if (card.datatype === 'dynamic') { icon = data[card.field] || '' @@ -505,20 +523,6 @@ if (!icon && card.noValue === 'hide') { // 绌哄�奸殣钘� return null - } - - if (!height) { // 鍏煎 - 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) - } - - height = fontSize * lineHeight } if (data.hasOwnProperty(card.tooltip)) { @@ -531,8 +535,8 @@ <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> <div style={card.style}> {val ? <Tooltip title={val}> - <MkIcon className="ant-mk-icon" style={{height: height}} type={icon}/> - </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: height}} type={icon}/>} + <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/> + </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>} </div> </div> ) @@ -566,7 +570,7 @@ ) } else if (card.eleType === 'picture') { let _imagestyle = {} - let _style = card.style ? {margin: '0 auto', ...card.style} : {} + let _style = {margin: '0 auto', ...card.style} let url = '' if (card.maxWidth) { _style.maxWidth = card.maxWidth @@ -722,7 +726,7 @@ ) } else if (card.eleType === 'formula') { let val = 0 - let _style = card.style ? {...card.style} : {} + let _style = {...card.style} if (card.$sync) { if (card.eval === 'false') { @@ -804,17 +808,11 @@ className = mark.signType } - let lineStyle = {height: card.innerHeight || 'auto'} - if (card.alignItems) { - lineStyle.display = 'flex' - lineStyle.alignItems = card.alignItems - lineStyle.justifyContent = _style.textAlign || 'left' - } - contents.push( <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> <div style={_style}> - <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> + {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : + <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} </div> </div> ) -- Gitblit v1.8.0