king
2022-03-23 151f90d6aa701be749ff2fc80b3599b88ece3844
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -1,12 +1,13 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Col, Tooltip, notification } from 'antd'
import { Col, Tooltip, notification } from 'antd'
import moment from 'moment'
import asyncComponent from './asyncButtonComponent'
import asyncElementComponent from '@/utils/asyncComponent'
import { getMark } from '@/utils/utils.js'
import MkIcon from '@/components/mk-icon'
import MKEmitter from '@/utils/events.js'
import LostPng from '@/assets/img/lost.png'
import './index.scss'
@@ -152,79 +153,6 @@
    window.open(url)
  }
  getMark = (marks, style, content) => {
    const { data } = this.props
    marks.some(mark => {
      let originVal = data[mark.field[0]] + ''
      let contrastVal = ''
      let result = false
      if (mark.field[1] === 'static') {
        contrastVal = mark.contrastValue + ''
      } else {
        contrastVal = data[mark.field[2]] + ''
      }
      if (mark.match === '=') {
        result = originVal === contrastVal
      } else if (mark.match === '!=') {
        result = originVal !== contrastVal
      } else if (mark.match === 'like') {
        result = originVal.indexOf(contrastVal) > -1
      } else if (mark.match === '>') {
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch (e) {
          originVal = NaN
        }
        if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) {
          result = true
        }
      } else if (mark.match === '<') {
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch (e) {
          originVal = NaN
        }
        if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) {
          result = true
        }
      }
      if (result && mark.signType) {
        if (mark.signType[0] === 'font') {
          style.color = mark.color
        } else if (mark.signType[0] === 'background') {
          style.background = mark.color
          if (mark.fontColor) {
            style.color = mark.fontColor
          }
        } else if (mark.signType[0] === 'underline') {
          style.textDecoration = 'underline'
          style.color = mark.color
        } else if (mark.signType[0] === 'line-through') {
          style.textDecoration = 'line-through'
          style.color = mark.color
        } else if (mark.signType[0] === 'icon') {
          let icon = (<Icon style={{color: mark.color}} type={mark.signType[3]} />)
          if (mark.signType[1] === 'front') {
            content = <span>{icon} {content}</span>
          } else {
            content = <span>{content} {icon}</span>
          }
        }
      }
      return result
    })
    return content
  }
  getColor = (marks) => {
    const { data } = this.props
    let color = ''
@@ -247,27 +175,9 @@
      } else if (mark.match === 'like') {
        result = originVal.indexOf(contrastVal) > -1
      } else if (mark.match === '>') {
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch (e) {
          originVal = NaN
        }
        if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) {
          result = true
        }
        result = parseFloat(originVal) > parseFloat(contrastVal)
      } else if (mark.match === '<') {
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch (e) {
          originVal = NaN
        }
        if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) {
          result = true
        }
        result = parseFloat(originVal) < parseFloat(contrastVal)
      }
      if (result) {
@@ -288,7 +198,10 @@
        _style.width = card.innerHeight
        _style.height = card.innerHeight
        _style.lineHeight = card.innerHeight + 'px'
        this.getMark(card.marks, _style)
        let mark = getMark(card.marks, data, _style)
        _style = mark.style
      }
      return (
        <Col key={card.uuid} span={card.width}>
@@ -381,7 +294,17 @@
      }
      if (card.marks) {
        val = this.getMark(card.marks, _style, val)
        let mark = getMark(card.marks, data, _style)
        _style = mark.style
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
          }
        }
      }
      if (card.link) {
@@ -405,13 +328,19 @@
        val = data[card.field]
      }
      if (val !== '' && typeof(val) === 'number') {
      if (val === '' && card.noValue === 'hide') { // 空值隐藏
        return null
      }
      if (typeof(val) === 'number') {
        if (card.format === 'percent') {
          val = val * 100
        } else if (card.format === 'abs') {
          val = Math.abs(val)
        }
        if (card.col && card.col.type === 'number') {
          let decimal = card.col.decimal || 0
        if (typeof(card.decimal) === 'number') {
          let decimal = card.decimal
          if (card.format === 'percent') {
            decimal = decimal - 2
@@ -437,7 +366,17 @@
      }
      
      if (card.marks) {
        val = this.getMark(card.marks, _style, val)
        let mark = getMark(card.marks, data, _style)
        _style = mark.style
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
          }
        }
      }
      return (
@@ -460,8 +399,8 @@
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            {val ? <Tooltip title={val}>
              <Icon type={card.icon}/>
            </Tooltip> : <Icon type={card.icon}/>}
              <MkIcon type={card.icon}/>
            </Tooltip> : <MkIcon type={card.icon}/>}
          </div>
        </Col>
      )
@@ -687,14 +626,24 @@
      if (val !== '') {
        val = `${card.prefix || ''}${val}${card.postfix || ''}`
        if (card.eval === 'false' && /\s/ig.test(val)) {
          val = val.replace(/\s/ig, '&nbsp;')
        if (card.eval === 'false') {
          val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
          val = <span dangerouslySetInnerHTML={{__html: val}}></span>
        }
      }
      if (card.marks) {
        val = this.getMark(card.marks, _style, val)
        let mark = getMark(card.marks, data, _style)
        _style = mark.style
        if (mark.icon) {
          if (mark.position === 'front') {
            val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span>
          } else {
            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
          }
        }
      }
      return (
@@ -705,27 +654,37 @@
        </Col>
      )
    } else if (card.eleType === 'button') {
      let _disabled = data.$disabled
      if (card.control === 'hidden') {
        let s = data[card.controlField]
        let s = data[card.controlField] !== undefined ? data[card.controlField] + '' : ''
        if (s === card.controlVal || (card.controlVal && card.controlVal.split(',').includes(s))) {
          return null
        }
      } else if (card.control === 'disabled') {
        let s = data[card.controlField] !== undefined ? data[card.controlField] + '' : ''
        if (s === card.controlVal || (card.controlVal && card.controlVal.split(',').includes(s))) {
          _disabled = true
        }
      }
      
      let _data = [data]
      if (data.$$type === 'extendCard' || data.$$empty) {
      if (data.$$type === 'extendCard') {
        _data = data.$$selectedData || []
      } else if (data.$$empty) {
        _data = []
      } else if (card.$sync) {
        _data = this.props.syncData
      }
      if (['exec', 'prompt', 'pop'].includes(card.OpenType)) {
      if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <NormalButton
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
@@ -737,9 +696,12 @@
        )
      } else if (card.OpenType === 'excelIn') {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <ExcelInButton
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
@@ -750,9 +712,12 @@
        )
      } else if (card.OpenType === 'excelOut') {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <ExcelOutButton
              BID={data.$$BID}
              BData={data.$$BData || ''}
              lineId={data.$$key || ''}
              disabled={_disabled}
              btn={card}
              show={card.show}
              style={card.style}
@@ -762,10 +727,12 @@
        )
      } else if (card.OpenType === 'popview') {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <PopupButton
              BID={data.$$BID}
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
@@ -776,8 +743,11 @@
        )
      } else if (card.OpenType === 'tab') {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <TabButton
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
@@ -788,8 +758,11 @@
        )
      } else if (card.OpenType === 'innerpage') {
        return (
          <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
          <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
            <NewPageButton
              BData={data.$$BData || ''}
              disabled={_disabled}
              lineId={data.$$key || ''}
              btn={card}
              show={card.show}
              style={card.style}
@@ -801,9 +774,12 @@
      } else if (card.OpenType === 'funcbutton') {
        if (card.funcType === 'changeuser' || card.funcType === 'closetab') {
          return (
            <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <ChangeUserButton
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                lineId={data.$$key || ''}
                btn={card}
                show={card.show}
                style={card.style}
@@ -814,10 +790,12 @@
          )
        } else if (card.funcType === 'print') {
          return (
            <Col key={card.uuid} className="mk-cell-btn" span={card.width}>
            <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}>
              <PrintButton
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                lineId={data.$$key || ''}
                btn={card}
                show={card.show}
                style={card.style}