| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Col, Tooltip, notification, Typography } from 'antd' |
| | | import { Col, Tooltip, notification, Typography, message } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | // import Api from '@/api' |
| | | import asyncComponent from './asyncButtonComponent' |
| | | import asyncElementComponent from '@/utils/asyncComponent' |
| | | import asyncComponent 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 Encrypts from '@/components/encrypts' |
| | | import './index.scss' |
| | | |
| | | moment.suppressDeprecationWarnings = true |
| | | const { Paragraph } = Typography |
| | | const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton')) |
| | | const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton')) |
| | |
| | | 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')) |
| | | const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine')) |
| | | const BarCode = asyncComponent(() => import('@/components/barcode')) |
| | | const QrCode = asyncComponent(() => import('@/components/qrcode')) |
| | | const MkProgress = asyncComponent(() => import('@/components/mkProgress')) |
| | | const Video = asyncComponent(() => import('@/components/video')) |
| | | const MkPicture = asyncComponent(() => import('@/components/mkPicture')) |
| | | const PicRadio = { |
| | | '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%', |
| | | '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%', |
| | | '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%' |
| | | } |
| | | |
| | | class TextCell extends Component { |
| | | componentDidMount() { |
| | | if (this.node && this.node.scrollHeight > this.node.offsetHeight) { |
| | | this.node.style.display = 'block' |
| | | } |
| | | } |
| | | |
| | | componentDidUpdate() { |
| | | if (this.node) { |
| | | if (this.node.scrollHeight > this.node.offsetHeight) { |
| | | this.node.style.display = 'block' |
| | | } else { |
| | | this.node.style.display = 'flex' |
| | | } |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { card, className, value } = this.props |
| | | |
| | | let lineStyle = {height: card.innerHeight} |
| | | lineStyle.display = 'flex' |
| | | lineStyle.alignItems = card.alignItems |
| | | lineStyle.justifyContent = card.style.textAlign || 'left' |
| | | |
| | | return ( |
| | | <div ref={ref => this.node = ref} className={className} style={lineStyle}>{value}</div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class CardCellComponent extends Component { |
| | |
| | | elements: PropTypes.array, // 元素集 |
| | | } |
| | | |
| | | state = {} |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps)) |
| | | return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false) |
| | | } |
| | | |
| | | /** |
| | |
| | | node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'}) |
| | | } |
| | | |
| | | if (!card.link) return |
| | | if (!card.link || (card.linkType === 'qywx' || card.linkType === 'linkmenu')) return |
| | | e.stopPropagation() |
| | | |
| | | let url = '' |
| | |
| | | _url = _url + `?subject=来自${fullName}的邮件` |
| | | } |
| | | window.open(_url) |
| | | return |
| | | } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) { |
| | | return |
| | | } |
| | | |
| | |
| | | // } |
| | | |
| | | let Id = '' |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(url)) { |
| | | con = '&' |
| | | } |
| | | |
| | | if (cards.subtype === 'propcard' && cardCell) { |
| | | Id = cardCell.setting.primaryId || '' |
| | |
| | | } |
| | | |
| | | if (card.joint === 'true') { |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(url)) { |
| | | con = '&' |
| | | } |
| | | |
| | | url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` |
| | | } |
| | | |
| | |
| | | let contents = [] |
| | | |
| | | elements.forEach(card => { |
| | | let _style_ = null |
| | | |
| | | if (card.style && card.style.clear === 'left') { |
| | | _style_ = {clear: 'left'} |
| | | } else if (card.style && card.style.clear === 'right') { |
| | | _style_ = {float: 'right'} |
| | | } |
| | | |
| | | if (card.eleType === 'sequence') { |
| | | let _style = {} |
| | | let className = '' |
| | | if (card.marks) { |
| | | _style.width = card.innerHeight |
| | | _style.height = card.innerHeight |
| | |
| | | let mark = getMark(card.marks, data, _style) |
| | | |
| | | _style = mark.style |
| | | className = mark.signType |
| | | } |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | <div className="ant-mk-text line1" style={{height: card.innerHeight || 'auto'}}><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div> |
| | | <div className={'ant-mk-text line1' + className} style={{height: card.innerHeight || 'auto'}}><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'text') { |
| | | let val = '' |
| | | let _style = card.style ? {...card.style} : {} |
| | | let _style = {...card.style} |
| | | |
| | | if (card.datatype === 'static') { |
| | | val = card.value || '' |
| | |
| | | let city = sessionStorage.getItem('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 (/@month@/ig.test(val)) { |
| | | val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' })) |
| | | } else if (/@week@/ig.test(val)) { |
| | | val = val.replace(/@week@/ig, (() => { |
| | | let day = new Date().getDay() |
| | | let weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'] |
| | | return weeks[day] |
| | | })()) |
| | | } else if (/@day@/ig.test(val)) { |
| | | val = val.replace(/@day@/ig, (() => { |
| | | let day = new Date().getDate() |
| | | return day < 10 ? '0' + day : day |
| | | })()) |
| | | } |
| | | } else if (data.hasOwnProperty(card.field)) { |
| | | val = data[card.field] |
| | | } |
| | | |
| | | if (val === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | if (!val && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | |
| | | val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph> |
| | | } |
| | | } |
| | | } else if (card.fixStyle === 'alone') { |
| | | let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} |
| | | val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span> |
| | | } |
| | | |
| | | let className = '' |
| | | if (card.marks) { |
| | | let mark = getMark(card.marks, data, _style) |
| | | |
| | |
| | | val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> |
| | | } |
| | | } |
| | | className = mark.signType |
| | | } |
| | | |
| | | if (card.link || (card.anchors && card.anchors.length > 0)) { |
| | |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} 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> |
| | | {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'number') { |
| | | let val = '' |
| | | let _style = card.style ? {...card.style} : {} |
| | | let _style = {...card.style} |
| | | |
| | | if (card.datatype === 'static') { |
| | | val = card.value |
| | |
| | | return null |
| | | } |
| | | |
| | | if (typeof(val) === 'number') { |
| | | if (!isNaN(val) && val !== '') { |
| | | val = +val |
| | | if (card.round) { |
| | | val = Math.round(val * card.round) / card.round |
| | | } |
| | |
| | | } else { |
| | | val = `${card.prefix || ''}${val}${card.postfix || ''}` |
| | | } |
| | | } else if (card.fixStyle === 'alone') { |
| | | let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} |
| | | val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span> |
| | | } |
| | | |
| | | let className = '' |
| | | if (card.marks) { |
| | | let mark = getMark(card.marks, data, _style) |
| | | |
| | |
| | | val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> |
| | | } |
| | | } |
| | | className = mark.signType |
| | | } |
| | | |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | | {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'icon') { |
| | | let val = '' |
| | | let height = card.innerHeight |
| | | let icon = '' |
| | | |
| | | if (!height) { // 兼容 |
| | | let fontSize = 14 |
| | | let lineHeight = 1.5 |
| | | |
| | | if (card.style.fontSize) { |
| | | fontSize = parseInt(card.style.fontSize) |
| | | } |
| | | if (card.style.lineHeight) { |
| | | lineHeight = parseFloat(card.style.lineHeight) |
| | | } |
| | | |
| | | height = fontSize * lineHeight |
| | | if (card.datatype === 'dynamic') { |
| | | icon = data[card.field] || '' |
| | | } else if (card.tipType === 'text') { |
| | | icon = card.value |
| | | } else { |
| | | icon = card.icon |
| | | } |
| | | |
| | | if (!icon && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | if (card.datatype === 'static') { |
| | | if (data.hasOwnProperty(card.tooltip)) { |
| | | val = data[card.tooltip] |
| | | } else { |
| | | val = card.tooltip |
| | | } else if (data.hasOwnProperty(card.field)) { |
| | | val = data[card.field] |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div style={card.style}> |
| | | {val ? <Tooltip title={val}> |
| | | <MkIcon className="ant-mk-icon" style={{height: height}} type={card.icon}/> |
| | | </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: height}} type={card.icon}/>} |
| | | |
| | | if (/\\n|\n/.test(val)) { |
| | | val = val.replace(/(\\n|\n)$/, '') |
| | | |
| | | if (val) { |
| | | val = val.split(/\\n|\n/) |
| | | |
| | | val = <div>{val.map((cell, i) => <div style={{marginBottom: 2}} key={i}>{cell}</div>)}</div> |
| | | } |
| | | } |
| | | |
| | | if (card.tipType === 'text') { |
| | | contents.push( |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | {val ? <Tooltip title={val}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div> |
| | | </Tooltip> : <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>} |
| | | </div> |
| | | </div> |
| | | </Col> |
| | | ) |
| | | ) |
| | | } else { |
| | | contents.push( |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | {val ? <Tooltip title={val}> |
| | | <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/> |
| | | </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>} |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | } else if (card.eleType === 'slider') { |
| | | let val = 0 |
| | | let color = card.color |
| | |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | <MkProgress value={val} config={card} color={color}/> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'picture') { |
| | | let _imagestyle = {} |
| | | let _style = card.style ? {margin: '0 auto', ...card.style} : {} |
| | | let _style = {margin: '0 auto', ...card.style} |
| | | let url = '' |
| | | if (card.maxWidth) { |
| | | _style.maxWidth = card.maxWidth |
| | |
| | | if (url === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | if (_style.borderRadius) { |
| | | _imagestyle.borderRadius = _style.borderRadius |
| | | } |
| | | |
| | | if (PicRadio[card.lenWidRadio]) { |
| | | _imagestyle.paddingTop = PicRadio[card.lenWidRadio] |
| | | } else { |
| | | _imagestyle.paddingTop = '100%' |
| | | } |
| | | |
| | | _imagestyle.borderRadius = _style.borderRadius || 0 |
| | | _imagestyle.backgroundSize = _style.backgroundSize || 'cover' |
| | | _imagestyle.backgroundPosition = _style.backgroundPosition || 'center' |
| | | _imagestyle.backgroundRepeat = _style.backgroundRepeat || 'no-repeat' |
| | | |
| | | if (card.link) { |
| | | _style.cursor = 'pointer' |
| | | } |
| | | |
| | | let scale = url && card.scale === 'true' |
| | | let urls = url ? url.split(',').filter(Boolean) : [LostPng] |
| | | |
| | | if (!url) { |
| | | _imagestyle = {backgroundSize: 'contain'} |
| | | } |
| | | let urls = url ? url.split(',').filter(Boolean) : [''] |
| | | |
| | | urls.forEach((u, i) => { |
| | | contents.push(<Col key={card.uuid + i} span={card.width}> |
| | | contents.push(<div className={'ant-col ant-col-' + card.width} key={card.uuid + i} style={_style_} span={card.width}> |
| | | <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> |
| | | <div |
| | | className={'ant-mk-picture' + (scale ? ' scale' : '')} |
| | | onClick={(e) => { |
| | | if (!scale) return |
| | | |
| | | e.stopPropagation() |
| | | |
| | | MKEmitter.emit('mkImageScale', url, urls) |
| | | }} |
| | | style={{..._imagestyle, backgroundImage: `url('${u}')`}} |
| | | ></div> |
| | | <MkPicture style={_imagestyle} scale={scale} url={u} urls={urls}/> |
| | | </div> |
| | | </Col>) |
| | | </div>) |
| | | }) |
| | | } else if (card.eleType === 'splitline') { |
| | | let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth |
| | | _style_ = _style_ || {} |
| | | _style_.minHeight = _borderWidth |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width} style={{minHeight: _borderWidth}}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} span={card.width} style={_style_}> |
| | | <div style={card.style}> |
| | | <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'barcode') { |
| | | let val = '' |
| | |
| | | val = data[card.field] || '' |
| | | } |
| | | |
| | | if (val === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | if (!val && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | <div style={{height: card.innerHeight || 25}}> |
| | | {val ? <BarCode card={card} value={val}/> : null} |
| | | </div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'video') { |
| | | let url = '' |
| | |
| | | url = data[card.field] || '' |
| | | } |
| | | |
| | | if (url === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | if (!url && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | |
| | | |
| | | urls.forEach((u, i) => { |
| | | contents.push( |
| | | <Col key={card.uuid + i} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid + i} style={_style_} span={card.width}> |
| | | <div className="video-wrap" style={card.style}> |
| | | <Video card={card} poster={poster} value={u}/> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | }) |
| | | } else if (card.eleType === 'qrcode') { |
| | |
| | | val = data[card.field] || '' |
| | | } |
| | | |
| | | if (val === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | if (!val && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | <div style={{minHeight: card.qrWidth || 50}}> |
| | | {val ? <QrCode card={card} value={val}/> : null} |
| | | </div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'currentDate') { |
| | | let val = moment().format(card.dateFormat || 'YYYY-MM-DD') |
| | |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} span={card.width}> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={card.style}> |
| | | <div className="ant-mk-text line1" style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'formula') { |
| | | let val = 0 |
| | | let _style = card.style ? {...card.style} : {} |
| | | |
| | | if (card.$sync) { |
| | | let _style = {...card.style} |
| | | |
| | | if (card.eval === 'func') { |
| | | let _data = [] |
| | | if (card.$sync) { |
| | | _data = this.props.syncData |
| | | } else if (data && !data.$$empty) { |
| | | _data = [data] |
| | | } |
| | | |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('data', card.formula) |
| | | val = func(_data) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | val = '' |
| | | } |
| | | } else if (card.$sync) { |
| | | if (card.eval === 'false') { |
| | | val = '' |
| | | } |
| | |
| | | // eslint-disable-next-line |
| | | _val = eval(_val) |
| | | } catch (e) { |
| | | console.info(_val) |
| | | console.warn(e) |
| | | _val = 0 |
| | | } |
| | | } |
| | |
| | | |
| | | val += _val |
| | | }) |
| | | } else if (data && data.$$empty) { |
| | | val = '' |
| | | } else if (data) { |
| | | let _val = card.formula |
| | | Object.keys(data).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | _val = _val.replace(reg, data[key]) |
| | | }) |
| | | |
| | | |
| | | if (card.eval !== 'false') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | _val = eval(_val) |
| | | } catch (e) { |
| | | console.info(_val) |
| | | console.warn(e) |
| | | _val = '' |
| | | } |
| | | } |
| | | |
| | | val = _val === undefined ? '' : _val |
| | | } |
| | | |
| | | if (val === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | |
| | | if (!val && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } else if (card.eval === 'func') { |
| | | contents.push( |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}} dangerouslySetInnerHTML={{__html: val}}></div> |
| | | </div> |
| | | </div> |
| | | ) |
| | | return |
| | | } |
| | | |
| | | if (card.round && typeof(val) === 'number') { |
| | | val = Math.round(val * card.round) / card.round |
| | | val = val.toFixed(card.decimal) |
| | | } |
| | | |
| | | if (val !== '') { |
| | | if (val && typeof(val) === 'string') { |
| | | val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') |
| | | val = val.replace(/\n/ig, '<br/>') |
| | | if (!/<(span|div|p|a|img)\s/g.test(val)) { |
| | | val = val.replace(/\s/ig, ' ') |
| | | } |
| | | |
| | | val = <span dangerouslySetInnerHTML={{__html: val}}></span> |
| | | } |
| | | |
| | |
| | | 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 = <>{card.prefix || ''}{val}{card.postfix || ''}</> |
| | | } |
| | | } else if (card.fixStyle === 'alone') { |
| | | let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} |
| | | val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span> |
| | | } |
| | | |
| | | |
| | | let className = '' |
| | | if (card.marks) { |
| | | let mark = getMark(card.marks, data, _style) |
| | | |
| | |
| | | val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> |
| | | } |
| | | } |
| | | className = mark.signType |
| | | } |
| | | |
| | | contents.push( |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={_style}> |
| | | {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>} |
| | | </div> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'color') { |
| | | let color = '' |
| | | |
| | | if (card.datatype === 'static') { |
| | | color = card.value |
| | | } else { |
| | | color = data[card.field] || '' |
| | | } |
| | | |
| | | if (!color && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | let _bgstyle = {backgroundColor: color} |
| | | |
| | | if (PicRadio[card.lenWidRadio]) { |
| | | _bgstyle.paddingTop = PicRadio[card.lenWidRadio] |
| | | } else { |
| | | _bgstyle.paddingTop = '100%' |
| | | } |
| | | |
| | | if (card.copyable === 'true') { |
| | | _bgstyle.cursor = 'pointer' |
| | | } |
| | | |
| | | 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> |
| | | <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <div className="ant-mk-color" style={card.style}> |
| | | <div style={_bgstyle} onClick={(e) => { |
| | | if (card.copyable === 'true') { |
| | | e.stopPropagation() |
| | | |
| | | let oInput = document.createElement('input') |
| | | oInput.value = color |
| | | document.body.appendChild(oInput) |
| | | oInput.select() |
| | | document.execCommand('Copy') |
| | | document.body.removeChild(oInput) |
| | | |
| | | message.success('复制成功。') |
| | | } |
| | | }}></div> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.eleType === 'button') { |
| | | let _disabled = data.$disabled |
| | | if (card.control === 'hidden') { |
| | | 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 = data.$$selectedData || [] |
| | | if (card.Ot === 'notRequired' && _data.length === 0) { |
| | | _data = [data] |
| | | } |
| | | } else if (card.$sync) { |
| | | _data = this.props.syncData |
| | | _data = this.props.syncData || [] |
| | | } else if (data.$$empty) { |
| | | _data = [] |
| | | } |
| | | |
| | | _style_ = _style_ || {} |
| | | if (card.wrapStyle) { |
| | | _style_ = {..._style_, ...card.wrapStyle} |
| | | } |
| | | |
| | | if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <NormalButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | columns={cards.columns} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'excelIn') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <ExcelInButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'excelOut') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <ExcelOutButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'popview') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <PopupButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'tab') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <TabButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={_disabled} |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'innerpage') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <NewPageButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={_disabled} |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.OpenType === 'funcbutton') { |
| | | if (card.funcType === 'changeuser' || card.funcType === 'closetab') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <ChangeUserButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.funcType === 'print') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <PrintButton |
| | | btn={card} |
| | | BID={data.$$BID} |
| | | BData={data.$$BData || ''} |
| | | disabled={_disabled} |
| | | setting={cards.setting} |
| | | columns={cards.columns} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.funcType === 'megvii') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <FuncMegvii |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.funcType === 'filezip') { |
| | | contents.push( |
| | | <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <FuncZip |
| | | btn={card} |
| | | BID={data.$$BID} |
| | |
| | | setting={cards.setting} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | | </div> |
| | | ) |
| | | } else if (card.funcType === 'addline' || card.funcType === 'delline') { |
| | | contents.push( |
| | | <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> |
| | | <EditLine |
| | | btn={card} |
| | | disabled={_disabled} |
| | | selectedData={_data} |
| | | /> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { cardCell } = this.props |
| | | |
| | | return ( |
| | | <div className="card-cell-list"> |
| | | <div className={'card-cell-list ' + (cardCell && cardCell.setting && cardCell.setting.layout === 'flex' ? 'mk-flex' : '')}> |
| | | {this.getContent()} |
| | | <Col style={{display: 'none'}} span={24}></Col> |
| | | </div> |
| | | ) |
| | | } |