| | |
| | | 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' |
| | |
| | | return |
| | | } |
| | | |
| | | if (card.linkType === 'tel') { |
| | | window.open('tel:' + url) |
| | | return |
| | | } else if (card.linkType === 'email') { |
| | | let _url = 'mailto:' + url |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | if (fullName) { |
| | | _url = _url + `?subject=来自${fullName}的邮件` |
| | | } |
| | | window.open(_url) |
| | | return |
| | | } |
| | | |
| | | if (/^sso$/ig.test(url)) { |
| | | if (!data.LinkUrl1) { |
| | | notification.warning({ |
| | |
| | | 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 (val !== '' && card.format) { |
| | | if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) { |
| | | val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}` |
| | | let _val = null |
| | | |
| | | if (card.format === 'calendar1') { |
| | | _val = moment(val).calendar(null, { |
| | | sameDay: '[今天] ahh:mm', |
| | | nextDay: '[明天] ahh:mm', |
| | | nextWeek: 'MM月DD日 ahh:mm', |
| | | lastDay: '[昨天] ahh:mm', |
| | | lastWeek: 'dddd ahh:mm', |
| | | sameElse: 'MM月DD日 ahh:mm' |
| | | }) |
| | | } else if (card.format === 'calendar2') { |
| | | let time = new Date(val).getTime() |
| | | if (!isNaN(time)) { |
| | | time = parseInt(time / 60000) // 时间值 |
| | | let now = parseInt(new Date().getTime() / 60000) // 当前时间值 |
| | | let start = new Date(new Date().toDateString()).getTime() / 60000 // 今天零点时间值 |
| | | let split = now - time |
| | | |
| | | if (split < 0) { // 时间值在当前时间之后 |
| | | _val = moment(val).format('MM月DD日 HH:mm') |
| | | } else if (split < 3) { |
| | | _val = '刚刚' |
| | | } else if (split < 5) { |
| | | _val = '3分钟前' |
| | | } else if (split < 10) { |
| | | _val = '5分钟前' |
| | | } else if (split < 20) { |
| | | _val = '10分钟前' |
| | | } else if (split < 30) { |
| | | _val = '20分钟前' |
| | | } else if (split < 60) { |
| | | _val = '30分钟前' |
| | | } else if (split < 420 || time > start) { // 7小时内或时间值在今天零点后 |
| | | _val = parseInt(split / 60) + '小时前' |
| | | } else { // 时间值在今天零点之前 |
| | | let _day = parseInt((start - time) / (24 * 60)) + 1 |
| | | if (_day === 1) { |
| | | _val = '昨天' |
| | | } else if (_day <= 30) { |
| | | _val = _day + '天前' |
| | | } else { |
| | | _val = moment(val).format('MM月DD日 HH:mm') |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | _val = moment(val).format(card.format) |
| | | } |
| | | |
| | | // if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) { |
| | | // val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}` |
| | | // } |
| | | if (_val && _val !== 'Invalid date') { |
| | | val = _val |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | val = data[card.field] |
| | | } |
| | | |
| | | if (val !== '' && typeof(val) === 'number') { |
| | | 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') { |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | |
| | | 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |
| | |
| | | ) |
| | | } 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={data.$disabled} |
| | | lineId={data.$$key || ''} |
| | | btn={card} |
| | | show={card.show} |
| | | style={card.style} |