king
2023-05-18 e9e8b1c7b481415714fff9a0d83099fd5a7d6ff0
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -24,6 +24,7 @@
const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton'))
const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii'))
const FuncZip = asyncComponent(() => import('@/tabviews/zshare/actionList/funczip'))
const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine'))
const BarCode = asyncElementComponent(() => import('@/components/barcode'))
const QrCode = asyncElementComponent(() => import('@/components/qrcode'))
const MkProgress = asyncElementComponent(() => import('@/components/mkProgress'))
@@ -33,6 +34,37 @@
  '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%',
  '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%',
  '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 {
@@ -100,6 +132,13 @@
        _url = _url + `?subject=来自${fullName}的邮件`
      }
      window.open(_url)
      return
    } else if (card.linkType === 'qywx') {
      notification.warning({
        top: 92,
        message: 'PC不支持打开企业微信!',
        duration: 5
      })
      return
    }
@@ -257,7 +296,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 || ''
@@ -285,7 +324,7 @@
          val = data[card.field]
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -375,6 +414,9 @@
              val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph>
            }
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
  
        let className = ''
@@ -400,24 +442,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
@@ -460,6 +496,9 @@
          } else {
            val = `${card.prefix || ''}${val}${card.postfix || ''}`
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
        
        let className = ''
@@ -478,24 +517,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 +537,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 +549,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 +584,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
@@ -636,7 +654,7 @@
          val = data[card.field] || ''
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -658,7 +676,7 @@
          url = data[card.field] || ''
        }
  
        if (url === '' && card.noValue === 'hide') { // 空值隐藏
        if (!url && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -690,7 +708,7 @@
          val = data[card.field] || ''
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -722,7 +740,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') {
@@ -739,6 +757,10 @@
                // eslint-disable-next-line
                _val = eval(_val)
              } catch (e) {
                if (window.debugger) {
                  console.info(_val)
                  console.warn(e)
                }
                _val = 0
              }
            }
@@ -747,6 +769,8 @@
  
            val += _val
          })
        } else if (data && data.$$empty) {
          val = ''
        } else if (data) {
          let _val = card.formula
          Object.keys(data).forEach(key => {
@@ -759,6 +783,10 @@
              // eslint-disable-next-line
              _val = eval(_val)
            } catch (e) {
              if (window.debugger) {
                console.info(_val)
                console.warn(e)
              }
              _val = ''
            }
          }
@@ -766,8 +794,13 @@
          val = _val === undefined ? '' : _val
        }
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
        if (card.round && typeof(val) === 'number') {
          val = Math.round(val * card.round) / card.round
          val = val.toFixed(card.decimal)
        }
  
        if (val !== '') {
@@ -786,6 +819,9 @@
          } else {
            val = <>{card.prefix || ''}{val}{card.postfix || ''}</>
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
        let className = ''
@@ -804,17 +840,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>
        )
@@ -827,7 +857,7 @@
          color = data[card.field] || ''
        }
  
        if (color === '' && card.noValue === 'hide') { // 空值隐藏
        if (!color && card.noValue === 'hide') { // 空值隐藏
          return null
        }
@@ -1008,6 +1038,16 @@
                />
              </div>
            )
          } else if (card.funcType === 'addline' || card.funcType === 'delline') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <EditLine
                  btn={card}
                  disabled={_disabled}
                  selectedData={_data}
                />
              </div>
            )
          }
        }
      }