| | |
| | | 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 (card.bgImage && data[card.bgImage]) { |
| | | _style.backgroundImage = `url('${data[card.bgImage]}')` |
| | | } |
| | | |
| | | let lineStyle = {height: card.innerHeight || 'auto'} |
| | | if (card.alignItems) { |
| | | lineStyle.display = 'flex' |
| | | lineStyle.alignItems = card.alignItems |
| | | lineStyle.justifyContent = _style.textAlign || 'left' |
| | | } |
| | | |
| | | contents.push( |
| | | <Col 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 || '') + className} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> |
| | | </div> |
| | | </Col> |
| | | ) |
| | |
| | | return null |
| | | } |
| | | |
| | | if (typeof(val) === 'number') { |
| | | if (!isNaN(val) && val !== '') { |
| | | val = +val |
| | | if (card.round) { |
| | | val = Math.round(val * card.round) / card.round |
| | | } |
| | |
| | | } |
| | | className = mark.signType |
| | | } |
| | | |
| | | let lineStyle = {height: card.innerHeight || 'auto'} |
| | | if (card.alignItems) { |
| | | lineStyle.display = 'flex' |
| | | lineStyle.alignItems = card.alignItems |
| | | lineStyle.justifyContent = _style.textAlign || 'left' |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> |
| | | </div> |
| | | </Col> |
| | | ) |
| | |
| | | icon = data[card.field] || '' |
| | | } else { |
| | | icon = card.icon |
| | | } |
| | | |
| | | if (!icon && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | if (!height) { // 兼容 |
| | |
| | | if (url === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | if (_style.borderRadius) { |
| | | _imagestyle.borderRadius = _style.borderRadius |
| | | } |
| | | |
| | | if (PicRadio[card.lenWidRadio]) { |
| | | _imagestyle.paddingTop = PicRadio[card.lenWidRadio] |
| | |
| | | _imagestyle.paddingTop = '100%' |
| | | } |
| | | |
| | | _imagestyle.backgroundSize = card.backgroundSize || 'cover' |
| | | _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' |
| | |
| | | } else if (card.eleType === 'formula') { |
| | | let val = 0 |
| | | let _style = card.style ? {...card.style} : {} |
| | | |
| | | |
| | | if (card.$sync) { |
| | | if (card.eval === 'false') { |
| | | val = '' |
| | |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | _val = _val.replace(reg, data[key]) |
| | | }) |
| | | |
| | | |
| | | if (card.eval !== 'false') { |
| | | try { |
| | | // eslint-disable-next-line |
| | |
| | | |
| | | val = _val === undefined ? '' : _val |
| | | } |
| | | |
| | | |
| | | if (val === '' && card.noValue === 'hide') { // 空值隐藏 |
| | | return null |
| | | } |
| | | |
| | | 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 || ''}</> |
| | | } |
| | | } |
| | | |
| | | |
| | | let className = '' |
| | | if (card.marks) { |
| | | let mark = getMark(card.marks, data, _style) |
| | |
| | | } |
| | | className = mark.signType |
| | | } |
| | | |
| | | let lineStyle = {height: card.innerHeight || 'auto'} |
| | | if (card.alignItems) { |
| | | lineStyle.display = 'flex' |
| | | lineStyle.alignItems = card.alignItems |
| | | lineStyle.justifyContent = _style.textAlign || 'left' |
| | | } |
| | | |
| | | contents.push( |
| | | <Col key={card.uuid} style={_style_} span={card.width}> |
| | | <div style={_style}> |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight || 'auto'}}>{val}</div> |
| | | <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div> |
| | | </div> |
| | | </Col> |
| | | ) |
| | |
| | | ) |
| | | } 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 || [] |
| | | } else if (card.$sync) { |
| | | _data = this.props.syncData |
| | | _data = this.props.syncData || [] |
| | | } else if (data.$$empty) { |
| | | _data = [] |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { cardCell } = this.props |
| | | |
| | | return ( |
| | | <div className="card-cell-list"> |
| | | <div className={'card-cell-list ' + (cardCell && cardCell.setting.layout === 'flex' ? 'mk-flex' : '')}> |
| | | {this.getContent()} |
| | | </div> |
| | | ) |