king
2022-09-06 b8e1395f02c929eaa96b949cf6027ee2a43856a6
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -44,21 +44,7 @@
    elements: PropTypes.array,       // 元素集
  }
  state = {
    card: null,          // 编辑中元素
    elements: null,      // 按钮组
  }
  /**
   * @description 搜索条件初始化
   */
  UNSAFE_componentWillMount () {
    const { elements } = this.props
    this.setState({
      elements: fromJS(elements).toJS()
    })
  }
  state = {}
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps))
@@ -237,9 +223,12 @@
    return color
  }
  getContent = (card) => {
    const { data, cards } = this.props
  getContent = () => {
    const { data, cards, elements } = this.props
    let contents = []
    elements.forEach(card => {
    if (card.eleType === 'sequence') {
      let _style = {}
      if (card.marks) {
@@ -251,7 +240,7 @@
        _style = mark.style
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div className="ant-mk-text"><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div>
@@ -376,7 +365,7 @@
        _style.backgroundImage = `url('${data[card.bgImage]}')`
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={_style} onClick={(e) => {this.openNewView(e, card)}}>
            <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
@@ -398,23 +387,17 @@
      }
      if (typeof(val) === 'number') {
          if (card.round) {
            val = Math.round(val * card.round) / card.round
          }
        if (card.format === 'percent') {
          val = val * 100
        } else if (card.format === 'abs') {
          val = Math.abs(val)
        }
        if (typeof(card.decimal) === 'number') {
          let decimal = card.decimal
          if (card.format === 'percent') {
            decimal = decimal - 2
          }
          if (decimal < 0) {
            decimal = 0
          }
          val = val.toFixed(decimal)
          if (card.round) {
            val = val.toFixed(card.decimal)
        } else {
          val = '' + val
        }
@@ -449,7 +432,7 @@
        }
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={_style}>
            <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
@@ -465,7 +448,7 @@
        val = data[card.field]
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            {val ? <Tooltip title={val}>
@@ -495,7 +478,7 @@
        color = _color ? _color : color
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <MkProgress value={val} config={card} color={color}/>
@@ -529,12 +512,6 @@
        return null
      }
      
      if (url) {
        _imagestyle = {backgroundImage: `url('${url}')`}
      } else {
        _imagestyle = {backgroundImage: `url(${LostPng})`, backgroundSize: 'contain'}
      }
      if (_style.borderRadius) {
        _imagestyle.borderRadius = _style.borderRadius
      }
@@ -550,29 +527,32 @@
      }
      let scale = url && card.scale === 'true'
        let urls = url ? url.split(',').filter(Boolean) : [LostPng]
      
      return (
        <Col key={card.uuid} span={card.width}>
        if (!url) {
          _imagestyle = {backgroundSize: 'contain'}
        }
        urls.forEach((u, i) => {
          contents.push(<Col key={card.uuid + i} span={card.width}>
          <div style={_style} onClick={(e) => {this.openNewView(e, card)}}>
            <div
              className={'ant-mk-picture' + (scale ? ' scale' : '')}
              onClick={(e) => {
                if (scale) {
                  e.stopPropagation()
                } else {
                  return
                }
                  if (!scale) return
                MKEmitter.emit('mkImageScale', url)
                  e.stopPropagation()
                  MKEmitter.emit('mkImageScale', url, urls)
              }}
              style={_imagestyle}
                style={{..._imagestyle, backgroundImage: `url('${u}')`}}
            ></div>
          </div>
        </Col>
      )
          </Col>)
        })
    } else if (card.eleType === 'splitline') {
      let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth
      return (
        contents.push(
        <Col key={card.uuid} span={card.width} style={{minHeight: _borderWidth}}>
          <div style={card.style}>
            <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div>
@@ -592,7 +572,7 @@
        return null
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div style={{height: card.innerHeight || 25}}>
@@ -622,13 +602,17 @@
        poster = card.posterUrl || ''
      }
      return (
        <Col key={card.uuid} span={card.width}>
        let urls = url.split(',').filter(Boolean)
        urls.forEach((u, i) => {
          contents.push(
            <Col key={card.uuid + i} span={card.width}>
          <div className="video-wrap" style={card.style}>
            <Video card={card} poster={poster} value={url}/>
                <Video card={card} poster={poster} value={u}/>
          </div>
        </Col>
      )
        })
    } else if (card.eleType === 'qrcode') {
      let val = ''
@@ -642,7 +626,7 @@
        return null
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div style={{minHeight: card.qrWidth || 50}}>
@@ -661,7 +645,7 @@
        val = `${card.prefix || ''}${val}${card.postfix || ''}`
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div className="ant-mk-date" style={card.style}>
            {val}
@@ -746,7 +730,7 @@
        }
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={_style}>
            <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
@@ -778,7 +762,7 @@
      }
      if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <NormalButton
              btn={card}
@@ -792,7 +776,7 @@
          </Col>
        )
      } else if (card.OpenType === 'excelIn') {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <ExcelInButton
              btn={card}
@@ -805,7 +789,7 @@
          </Col>
        )
      } else if (card.OpenType === 'excelOut') {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <ExcelOutButton
              btn={card}
@@ -818,7 +802,7 @@
          </Col>
        )
      } else if (card.OpenType === 'popview') {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <PopupButton
              btn={card}
@@ -831,7 +815,7 @@
          </Col>
        )
      } else if (card.OpenType === 'tab') {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <TabButton
              btn={card}
@@ -843,7 +827,7 @@
          </Col>
        )
      } else if (card.OpenType === 'innerpage') {
        return (
          contents.push(
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <NewPageButton
              btn={card}
@@ -856,7 +840,7 @@
        )
      } else if (card.OpenType === 'funcbutton') {
        if (card.funcType === 'changeuser' || card.funcType === 'closetab') {
          return (
            contents.push(
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <ChangeUserButton
                btn={card}
@@ -869,7 +853,7 @@
            </Col>
          )
        } else if (card.funcType === 'print') {
          return (
            contents.push(
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <PrintButton
                btn={card}
@@ -882,7 +866,7 @@
            </Col>
          )
        } else if (card.funcType === 'megvii') {
          return (
            contents.push(
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <FuncMegvii
                btn={card}
@@ -894,7 +878,7 @@
            </Col>
          )
        } else if (card.funcType === 'filezip') {
          return (
            contents.push(
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <FuncZip
                btn={card}
@@ -908,16 +892,15 @@
        }
      }
    }
    })
    return null
    return contents
  }
  render() {
    const { elements } = this.state
    return (
      <div className="card-cell-list">
        {elements.map(item => this.getContent(item))}
        {this.getContent()}
      </div>
    )
  }