king
2023-10-04 ae46c8e640ed64abd7605b289554377e0cdc0cb7
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -5,8 +5,7 @@
import moment from 'moment'
// import Api from '@/api'
import asyncComponent from './asyncButtonComponent'
import asyncElementComponent from '@/utils/asyncComponent'
import asyncComponent from '@/utils/asyncComponent'
import { getMark } from '@/utils/utils.js'
import MkIcon from '@/components/mk-icon'
import Encrypts from '@/components/encrypts'
@@ -24,15 +23,47 @@
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 BarCode = asyncElementComponent(() => import('@/components/barcode'))
const QrCode = asyncElementComponent(() => import('@/components/qrcode'))
const MkProgress = asyncElementComponent(() => import('@/components/mkProgress'))
const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine'))
const BarCode = asyncComponent(() => import('@/components/barcode'))
const QrCode = asyncComponent(() => import('@/components/qrcode'))
const MkProgress = asyncComponent(() => import('@/components/mkProgress'))
const Video = asyncComponent(() => import('@/components/video'))
const MkPicture = asyncComponent(() => import('@/components/mkPicture'))
const PicRadio = {
  '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 {
@@ -44,10 +75,8 @@
    elements: PropTypes.array,       // 元素集
  }
  state = {}
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps))
    return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false)
  }
  /**
@@ -70,7 +99,7 @@
      node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'})
    }
    if (!card.link) return
    if (!card.link || (card.linkType === 'qywx' || card.linkType === 'linkmenu')) return
    e.stopPropagation()
    
    let url = ''
@@ -100,6 +129,8 @@
        _url = _url + `?subject=来自${fullName}的邮件`
      }
      window.open(_url)
      return
    } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) {
      return
    }
@@ -168,11 +199,6 @@
    // }
    let Id = ''
    let con = '?'
    if (/\?/ig.test(url)) {
      con = '&'
    }
    if (cards.subtype === 'propcard' && cardCell) {
      Id = cardCell.setting.primaryId || ''
@@ -181,6 +207,12 @@
    }
    
    if (card.joint === 'true') {
      let con = '?'
      if (/\?/ig.test(url)) {
        con = '&'
      }
      url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
    }
@@ -233,6 +265,8 @@
      if (card.style && card.style.clear === 'left') {
        _style_ = {clear: 'left'}
      } else if (card.style && card.style.clear === 'right') {
        _style_ = {float: 'right'}
      }
      if (card.eleType === 'sequence') {
@@ -257,7 +291,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 +319,7 @@
          val = data[card.field]
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -375,6 +409,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 +437,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 +491,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,27 +512,22 @@
          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] || ''
        } else if (card.tipType === 'text') {
          icon = card.value
        } else {
          icon = card.icon
        }
@@ -506,36 +535,44 @@
        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)) {
          val = data[card.tooltip]
        } else {
          val = card.tooltip
        }
        contents.push(
          <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}/>}
        if (/\\n|\n/.test(val)) {
          val = val.replace(/(\\n|\n)$/, '')
          if (val) {
            val = val.split(/\\n|\n/)
            val = <div>{val.map((cell, i) => <div style={{marginBottom: 2}} key={i}>{cell}</div>)}</div>
          }
        }
        if (card.tipType === 'text') {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={card.style}>
                {val ? <Tooltip title={val}>
                  <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>
                </Tooltip> : <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>}
              </div>
            </div>
          </div>
        )
          )
        } else {
          contents.push(
            <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: card.innerHeight}} type={icon}/>
                </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>}
              </div>
            </div>
          )
        }
      } else if (card.eleType === 'slider') {
        let val = 0
        let color = card.color
@@ -566,7 +603,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 +673,7 @@
          val = data[card.field] || ''
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -658,7 +695,7 @@
          url = data[card.field] || ''
        }
  
        if (url === '' && card.noValue === 'hide') { // 空值隐藏
        if (!url && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -690,7 +727,7 @@
          val = data[card.field] || ''
        }
  
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
@@ -722,9 +759,25 @@
        )
      } else if (card.eleType === 'formula') {
        let val = 0
        let _style = card.style ? {...card.style} : {}
        let _style = {...card.style}
        if (card.eval === 'func') {
          let _data = []
          if (card.$sync) {
            _data = this.props.syncData
          } else if (data && !data.$$empty) {
            _data = [data]
          }
        if (card.$sync) {
          try {
            // eslint-disable-next-line
            let func = new Function('data', card.formula)
            val = func(_data)
          } catch (e) {
            console.warn(e)
            val = ''
          }
        } else if (card.$sync) {
          if (card.eval === 'false') {
            val = ''
          }
@@ -739,6 +792,8 @@
                // eslint-disable-next-line
                _val = eval(_val)
              } catch (e) {
                console.info(_val)
                console.warn(e)
                _val = 0
              }
            }
@@ -747,6 +802,8 @@
  
            val += _val
          })
        } else if (data && data.$$empty) {
          val = ''
        } else if (data) {
          let _val = card.formula
          Object.keys(data).forEach(key => {
@@ -759,6 +816,8 @@
              // eslint-disable-next-line
              _val = eval(_val)
            } catch (e) {
              console.info(_val)
              console.warn(e)
              _val = ''
            }
          }
@@ -766,8 +825,22 @@
          val = _val === undefined ? '' : _val
        }
        if (val === '' && card.noValue === 'hide') { // 空值隐藏
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        } else if (card.eval === 'func') {
          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 || '')} style={{height: card.innerHeight}} dangerouslySetInnerHTML={{__html: val}}></div>
              </div>
            </div>
          )
          return
        }
        if (card.round && typeof(val) === 'number') {
          val = Math.round(val * card.round) / card.round
          val = val.toFixed(card.decimal)
        }
  
        if (val !== '') {
@@ -786,6 +859,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 +880,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 +897,7 @@
          color = data[card.field] || ''
        }
  
        if (color === '' && card.noValue === 'hide') { // 空值隐藏
        if (!color && card.noValue === 'hide') { // 空值隐藏
          return null
        }
@@ -869,6 +939,9 @@
  
        if (data.$$type === 'extendCard') {
          _data = data.$$selectedData || []
          if (card.Ot === 'notRequired' && _data.length === 0) {
            _data = [data]
          }
        } else if (card.$sync) {
          _data = this.props.syncData || []
        } else if (data.$$empty) {
@@ -950,6 +1023,7 @@
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <NewPageButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                selectedData={_data}
@@ -1008,6 +1082,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>
            )
          }
        }
      }