king
2020-11-10 a9ac16fecc0cf9bc66dfaefe4e9b35fa3c722812
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -2,10 +2,12 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Col, Tooltip, notification } from 'antd'
import moment from 'moment'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import asyncComponent from './asyncButtonComponent'
import asyncElementComponent from '@/utils/asyncComponent'
import './index.scss'
@@ -17,10 +19,13 @@
const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton'))
const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton'))
const BarCode = asyncElementComponent(() => import('@/components/barcode'))
const QrCode = asyncElementComponent(() => import('@/components/qrcode'))
class CardCellComponent extends Component {
  static propTpyes = {
    BID: PropTypes.any,              // 上级ID
    seq: PropTypes.any,              // 序号
    cards: PropTypes.object,         // 菜单配置信息
    cardCell: PropTypes.object,
    data: PropTypes.object,
@@ -46,7 +51,7 @@
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
    return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps))
  }
  /**
@@ -89,9 +94,17 @@
  }
  getContent = (card) => {
    const { data, BID, cards } = this.props
    const { data, BID, cards, seq } = this.props
    if (card.eleType === 'text') {
    if (card.eleType === 'sequence') {
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div className={'ant-mk-text'}>{seq}</div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'text') {
      let val = ''
      if (card.datatype === 'static') {
@@ -257,10 +270,55 @@
        </Col>
      )
    } else if (card.eleType === 'splitline') {
      let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div className="ant-mk-splitline" style={{borderColor: card.color}}></div>
            <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'barcode') {
      let val = ''
      if (card.datatype === 'static') {
        val = card.value
      } else if (data.hasOwnProperty(card.field)) {
        val = data[card.field]
      }
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div style={{height: card.innerHeight || 25}}>
              {val ? <BarCode card={card} value={val}/> : null}
            </div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'qrcode') {
      let val = ''
      if (card.datatype === 'static') {
        val = card.value
      } else if (data.hasOwnProperty(card.field)) {
        val = data[card.field]
      }
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div style={{minHeight: card.qrWidth || 50}}>
              {val ? <QrCode card={card} value={val}/> : null}
            </div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'currentDate') {
      return (
        <Col key={card.uuid} span={card.width}>
          <div className="ant-mk-date" style={card.style}>
            {card.dateFormat ? `${card.prefix || ''}${moment().format(card.dateFormat)}${card.postfix || ''}` : null}
          </div>
        </Col>
      )