king
2022-09-06 fa381753ef2a2b25b1c0722549ac17e333da79be
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Col, Tooltip, notification } from 'antd'
import { Col, Tooltip, notification, Typography } from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -11,8 +11,10 @@
import MkIcon from '@/components/mk-icon'
import MKEmitter from '@/utils/events.js'
import LostPng from '@/assets/img/lost.png'
import Encrypts from '@/components/encrypts'
import './index.scss'
const { Paragraph } = Typography
const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton'))
const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton'))
const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton'))
@@ -22,6 +24,7 @@
const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton'))
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'))
@@ -41,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))
@@ -234,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) {
@@ -248,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>
@@ -261,11 +253,12 @@
      if (card.datatype === 'static') {
        val = card.value || ''
        if (/@username@|@fullName@|@login_city@/ig.test(val)) {
          if (/@username@|@fullName@|@mk_city@|@bid@/ig.test(val)) {
          let userName = sessionStorage.getItem('User_Name') || ''
          let fullName = sessionStorage.getItem('Full_Name') || ''
          let city = sessionStorage.getItem('city') || ''
          val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@login_city@/ig, city)
            let bid = data.$$BID || ''
            val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@bid@/ig, bid)
        }
      } else if (data.hasOwnProperty(card.field)) {
        val = data[card.field]
@@ -335,11 +328,18 @@
      }
      if (val !== '') {
          let orival = val
          if (card.format === 'encryption') {
            val = <Encrypts value={val} />
          }
        if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></>
        } else {
          val = `${card.prefix || ''}${val}${card.postfix || ''}`
            val = <span>{card.prefix || ''}{val}{card.postfix || ''}</span>
          }
          if (card.copyable === 'true') {
            val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph>
        }
      }
@@ -350,9 +350,9 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        }
      }
@@ -365,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>
@@ -387,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
        }
@@ -431,14 +425,14 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        }
      }
      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>
@@ -454,12 +448,12 @@
        val = data[card.field]
      }
      return (
        contents.push(
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            {val ? <Tooltip title={val}>
              <MkIcon type={card.icon}/>
            </Tooltip> : <MkIcon type={card.icon}/>}
                <MkIcon className="ant-mk-icon" style={{height: card.innerHeight || 'auto'}} type={card.icon}/>
              </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight || 'auto'}} type={card.icon}/>}
          </div>
        </Col>
      )
@@ -484,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}/>
@@ -507,18 +501,15 @@
      if (card.datatype === 'static') {
        url = card.url || ''
          if (url === '@icon@') {
            url = sessionStorage.getItem('avatar') || ''
          }
      } else {
        url = data[card.field] || ''
      }
      if (url === '' && card.noValue === 'hide') { // 空值隐藏
        return null
      }
      if (url) {
        _imagestyle = {backgroundImage: `url('${url}')`}
      } else {
        _imagestyle = {backgroundImage: `url(${LostPng})`, backgroundSize: 'contain'}
      }
      if (_style.borderRadius) {
@@ -536,30 +527,33 @@
      }
      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 (
        <Col key={card.uuid} span={card.width}>
        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>
          </div>
@@ -578,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}}>
@@ -600,13 +594,25 @@
        return null
      }
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <Video card={card} value={url}/>
        let poster = ''
        if (card.posterType === 'dynamic') {
          poster = data[card.posterField] || ''
        } else {
          poster = card.posterUrl || ''
        }
        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={u}/>
          </div>
        </Col>
      )
        })
    } else if (card.eleType === 'qrcode') {
      let val = ''
@@ -620,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}}>
@@ -639,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}
@@ -717,14 +723,14 @@
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
          }
        }
      }
      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>
@@ -756,16 +762,13 @@
      }
      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}
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
              columns={cards.columns}
              selectedData={_data}
@@ -773,77 +776,63 @@
          </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}
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
              selectedData={_data}
            />
          </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}
              BID={data.$$BID}
              BData={data.$$BData || ''}
              lineId={data.$$key || ''}
              disabled={_disabled}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
                selectedData={_data}
            />
          </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}
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
              selectedData={_data}
            />
          </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}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
              selectedData={_data}
            />
          </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}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
              setting={cards.setting}
              selectedData={_data}
            />
@@ -851,47 +840,50 @@
        )
      } 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}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                lineId={data.$$key || ''}
                btn={card}
                show={card.show}
                style={card.style}
                setting={cards.setting}
                selectedData={_data}
              />
            </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}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                lineId={data.$$key || ''}
                btn={card}
                show={card.show}
                style={card.style}
                setting={cards.setting}
                selectedData={_data}
              />
            </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}
                BID={data.$$BID}
                disabled={_disabled}
                lineId={data.$$key || ''}
                  setting={cards.setting}
                  selectedData={_data}
                />
              </Col>
            )
          } else if (card.funcType === 'filezip') {
            contents.push(
              <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
                <FuncZip
                btn={card}
                show={card.show}
                style={card.style}
                  BID={data.$$BID}
                  disabled={_disabled}
                setting={cards.setting}
                selectedData={_data}
              />
@@ -900,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>
    )
  }