| | |
| | | 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' |
| | |
| | | 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 = '' |
| | |
| | | } 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) { |
| | |
| | | _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}> |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | 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 ( |
| | |
| | | <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> |
| | | ) |
| | |
| | | } |
| | | |
| | | 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 ( |
| | |
| | | |
| | | 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 |
| | |
| | | <NormalButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | <Col key={card.uuid} className="mk-cell-btn" span={card.width}> |
| | | <ExcelInButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | <Col key={card.uuid} className="mk-cell-btn" span={card.width}> |
| | | <ExcelOutButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | <PopupButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | return ( |
| | | <Col key={card.uuid} className="mk-cell-btn" span={card.width}> |
| | | <TabButton |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | return ( |
| | | <Col key={card.uuid} className="mk-cell-btn" span={card.width}> |
| | | <NewPageButton |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | <Col key={card.uuid} className="mk-cell-btn" span={card.width}> |
| | | <ChangeUserButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | <PrintButton |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |