From c18f79e01a2705d34d5ac2923a26913dba07ea14 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 03 八月 2024 16:04:18 +0800 Subject: [PATCH] 2024-08-03 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 868 +++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 596 insertions(+), 272 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index d997633..f585b93 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -5,10 +5,10 @@ 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 Encrypts from '@/components/encrypts' import './index.scss' @@ -24,15 +24,49 @@ 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 ExportPdf = asyncComponent(() => import('@/tabviews/zshare/actionList/exportPdf')) +const FuncButton = asyncComponent(() => import('@/tabviews/zshare/actionList/funcbutton')) +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 { @@ -44,10 +78,8 @@ 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) } /** @@ -62,16 +94,40 @@ openNewView = (e, card) => { const { cardCell, data, cards } = this.props - if (data.$disabled) return + e.stopPropagation() - if (card.anchors && card.anchors.length > 0) { + if (card.anchors) { let id = card.anchors[card.anchors.length - 1] let node = document.getElementById('anchor' + id) node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'}) } - if (!card.link) return - e.stopPropagation() + if (card.linkType === 'qywx') return + if (card.linkType === 'linkmenu') { + if (card.linkThdMenu) { + let __param = { + $BID: data.$$uuid || '' + } + + if (card.field) { + __param.$searchkey = card.field.toLowerCase() + __param.$searchval = data[card.field] || '' + } + + Object.keys(data).forEach(key => { + if (/^\$/.test(key)) return + if (key === 'children') return + __param[key] = data[key] + }) + + let tabmenu = card.linkThdMenu + + tabmenu.param = __param + + MKEmitter.emit('modifyTabs', tabmenu, true) + } + return + } let url = '' @@ -100,6 +156,8 @@ _url = _url + `?subject=鏉ヨ嚜${fullName}鐨勯偖浠禶 } window.open(_url) + return + } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) { return } @@ -166,25 +224,46 @@ // }) // return // } - - let Id = '' - let con = '?' - - if (/\?/ig.test(url)) { - con = '&' - } - - if (cards.subtype === 'propcard' && cardCell) { - Id = cardCell.setting.primaryId || '' - } else { - Id = data[cards.setting.primaryKey] || '' - } - if (card.joint === 'true') { - url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` - } + if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar|.ppt)$/i.test(url)) { + let name = url.replace(/.+\//g, '').replace(/\.{1}[^.]*$/g, '') + let d = document.createElement('a') + d.href = url + d.setAttribute('download', name) + d.setAttribute('target', '_blank') + document.body.appendChild(d) + d.click() + d.remove() + } else { + let Id = data.$$uuid || '' - window.open(url) + 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') || ''}` + } else if (/@/.test(url)) { + url = url.replace(/@id@/ig, Id) + url = url.replace(/@appkey@/ig, window.GLOB.appkey) + url = url.replace(/@userid@/ig, sessionStorage.getItem('UserID')) + url = url.replace(/@LoginUID@/ig, sessionStorage.getItem('LoginUID')) + + Object.keys(data).forEach(key => { + if (/^\$/.test(key)) return + let reg = new RegExp('@' + key + '@', 'ig') + url = url.replace(reg, data[key]) + }) + } + + window.open(url) + } } getColor = (marks) => { @@ -233,6 +312,8 @@ 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') { @@ -244,55 +325,55 @@ _style.lineHeight = card.innerHeight + 'px' let mark = getMark(card.marks, data, _style) - - _style = mark.style + className = mark.signType } contents.push( <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' + className} 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}>{card.prefix || ''}{data.$Index || ''}{card.postfix || ''}</span></div> </div> </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 || '' - if (/@username@|@fullName@|@mk_city@|@bid@/ig.test(val)) { - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - 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 - })()) + if (/@.+@/g.test(val)) { + if (/@username@|@fullName@|@mk_city@|@appname@|@bid@/ig.test(val)) { + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + let appname = sessionStorage.getItem('appname') || '' + let bid = data.$$BID || '' + val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@appname@/ig, appname).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] + val = data[card.field] + '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - if (val !== '' && card.format) { + if (val && card.format && card.format !== 'encryption') { let _val = null - if (card.format === 'calendar1') { + if (val < '1949-10-02') { + val = '' + } else if (card.format === 'calendar1') { _val = moment(val).calendar(null, { sameDay: '[浠婂ぉ] ahh:mm', nextDay: '[鏄庡ぉ] ahh:mm', @@ -339,17 +420,43 @@ } 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 (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } if (val !== '') { let orival = val + + if (card.linkType === 'download') { + let url = '' + + if (card.link === 'static') { + url = card.linkurl + } else { + url = data[card.linkurl] + } + + if (/^http.+(.txt|.doc|.docx|.pdf|.xlsx|.xls|.zip|.rar)$/i.test(url)) { + if (/pdf$/i.test(url)) { + val = <><img src="./media/pdf.png" className="file-image" alt=""/> {val}</> + } else if (/(.doc|.docx)$/i.test(url)) { + val = <><img src="./media/word.png" className="file-image" alt=""/> {val}</> + } else if (/(.xlsx|.xls)$/i.test(url)) { + val = <><img src="./media/excel.png" className="file-image" alt=""/> {val}</> + } else if (/(.zip|.rar)$/i.test(url)) { + val = <><img src="./media/rar.png" className="file-image" alt=""/> {val}</> + } else { + val = <><img src="./media/txt.png" className="file-image" alt=""/> {val}</> + } + } + } + if (card.format === 'encryption') { val = <Encrypts value={val} /> } @@ -361,7 +468,7 @@ } if (card.copyable === 'true') { - if (card.link || (card.anchors && card.anchors.length > 0)) { + if (card.link || card.anchors) { let url = orival if (card.link === 'static') { @@ -375,13 +482,14 @@ 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) - - _style = mark.style if (mark.icon) { if (mark.position === 'front') { @@ -389,35 +497,45 @@ } else { val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.space) { + val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</> + } else if (mark.point) { + if (mark.position === 'front') { + val = <>{mark.point}{val}</> + } else { + val = <>{val}{mark.point}</> + } } className = mark.signType - } - - if (card.link || (card.anchors && card.anchors.length > 0)) { - _style.cursor = 'pointer' } 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( - <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 || '') + className} style={lineStyle}>{val}</div> + if (!data.$disabled && (card.link || card.anchors)) { + _style.cursor = 'pointer' + contents.push( + <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)}}> + {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> - </div> - ) + ) + } else { + 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 === 'number') { let val = '' - let _style = card.style ? {...card.style} : {} + let _style = {...card.style} if (card.datatype === 'static') { val = card.value @@ -460,13 +578,14 @@ } 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) - - _style = mark.style if (mark.icon) { if (mark.position === 'front') { @@ -474,31 +593,34 @@ } else { val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.space) { + val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</> + } else if (mark.point) { + if (mark.position === 'front') { + val = <>{mark.point}{val}</> + } else { + val = <>{val}{mark.point}</> + } } 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( <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 || '') + className} style={lineStyle}>{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> </div> ) } else if (card.eleType === 'icon') { let val = '' let icon = '' - let height = card.innerHeight if (card.datatype === 'dynamic') { icon = data[card.field] || '' + } else if (card.tipType === 'text') { + icon = card.value } else { icon = card.icon } @@ -506,36 +628,44 @@ if (!icon && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } - - 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 (data.hasOwnProperty(card.tooltip)) { val = data[card.tooltip] } else { val = card.tooltip } - - 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: height}} type={icon}/> - </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: height}} type={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> - </div> - ) + ) + } 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 @@ -566,14 +696,12 @@ ) } 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 (_style.marginLeft === '0px') { + if (_style.marginLeft === '0px' && _style.marginRight === '0px') { delete _style.marginLeft - } - if (_style.marginRight === '0px') { delete _style.marginRight } } @@ -602,20 +730,31 @@ _imagestyle.backgroundPosition = _style.backgroundPosition || 'center' _imagestyle.backgroundRepeat = _style.backgroundRepeat || 'no-repeat' - if (card.link) { - _style.cursor = 'pointer' + if (_style.position === 'absolute') { + _style.width = '100%' } - + let scale = url && card.scale === 'true' let urls = url ? url.split(',').filter(Boolean) : [''] - - urls.forEach((u, i) => { - 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)}}> - <MkPicture style={_imagestyle} scale={scale} url={u} urls={urls}/> - </div> - </div>) - }) + + if (card.link && !data.$disabled) { + _style.cursor = 'pointer' + urls.forEach((u, i) => { + 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)}}> + <MkPicture style={_imagestyle} lostTip={card.lostTip !== 'false'} scale={scale} url={u} urls={urls}/> + </div> + </div>) + }) + } else { + urls.forEach((u, i) => { + contents.push(<div className={'ant-col ant-col-' + card.width} key={card.uuid + i} style={_style_} span={card.width}> + <div style={_style}> + <MkPicture style={_imagestyle} lostTip={card.lostTip !== 'false'} scale={scale} url={u} urls={urls}/> + </div> + </div>) + }) + } } else if (card.eleType === 'splitline') { let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth _style_ = _style_ || {} @@ -636,7 +775,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -658,7 +797,7 @@ url = data[card.field] || '' } - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!url && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -690,7 +829,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -722,9 +861,75 @@ ) } else if (card.eleType === 'formula') { let val = 0 - let _style = card.style ? {...card.style} : {} + let _style = {...card.style} + + if (card.eval === 'func') { + let _data = [] + if (card.$sync) { + _data = this.props.syncData + } else if (data && !data.$$empty) { + _data = [data] + } - if (card.$sync) { + let _val = card.formula + if (/@username@|@fullName@|@bid@/ig.test(_val)) { + _val = _val.replace(/@username@/ig, sessionStorage.getItem('User_Name') || '').replace(/@fullName@/ig, sessionStorage.getItem('Full_Name') || '').replace(/@bid@/ig, data.$$BID || '') + } + + try { + // eslint-disable-next-line + let func = new Function('data', _val) + val = func(_data) + } catch (e) { + console.warn(e) + val = '' + } + + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } else if (typeof(val) === 'object' && val.type === 'linkmenu') { + // type: 'linkmenu', linkThdMenu: null, menuId: '', value: ``, defaultValue: '', onclick: 'inner' + let item = {linkType: 'linkmenu', linkThdMenu: val.linkThdMenu} + let _val_ = val.value || '' + + if (!item.linkThdMenu && val.menuId) { + item.linkThdMenu = window.GLOB.mkThdMenus.get(val.menuId) || '' + } + if (!item.linkThdMenu && val.defaultValue) { + _val_ = val.defaultValue + } + + if (val.onclick === 'inner') { + 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}}> + <span onClick={(e) => {this.openNewView(e, item)}} dangerouslySetInnerHTML={{__html: _val_}}></span> + </div> + </div> + </div> + ) + } else { + _style.cursor = 'pointer' + contents.push( + <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> + <div style={_style} onClick={(e) => {this.openNewView(e, item)}}> + <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}} dangerouslySetInnerHTML={{__html: _val_}}></div> + </div> + </div> + ) + } + } else { + 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 + } else if (card.$sync) { if (card.eval === 'false') { val = '' } @@ -739,6 +944,8 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + window.mkInfo(_val) + console.warn(e) _val = 0 } } @@ -747,8 +954,36 @@ val += _val }) + } else if (data && data.$$empty && /@.*@/.test(card.formula)) { + val = '' } else if (data) { let _val = card.formula + + if (card.$keys && card.noValue === 'hide') { // 绌哄�奸殣钘� + let _data = {} + let empty = true + + Object.keys(data).forEach(key => { + _data[key.toLowerCase()] = data[key] + }) + _data.username = sessionStorage.getItem('User_Name') || '' + _data.fullname = sessionStorage.getItem('Full_Name') || '' + _data.bid = data.$$BID || '' + + card.$keys.forEach(key => { + if (!_data.hasOwnProperty(key)) { + empty = false + } else if (_data[key] && !/^1949-10-01/.test(_data[key])) { + empty = false + } + }) + + if (empty) return null + } + + if (/@username@|@fullName@|@bid@/ig.test(_val)) { + _val = _val.replace(/@username@/ig, sessionStorage.getItem('User_Name') || '').replace(/@fullName@/ig, sessionStorage.getItem('Full_Name') || '').replace(/@bid@/ig, data.$$BID || '') + } Object.keys(data).forEach(key => { let reg = new RegExp('@' + key + '@', 'ig') _val = _val.replace(reg, data[key]) @@ -759,6 +994,8 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + window.mkInfo(_val) + console.warn(e) _val = '' } } @@ -766,14 +1003,21 @@ val = _val === undefined ? '' : _val } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null + } + + 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/>') - if (!/<(span|div|p|a|img)\s/g.test(val)) { + if (!card.evalchars || card.evalchars.includes('enter')) { + val = val.replace(/\n/ig, '<br/>') + } + if ((!card.evalchars || card.evalchars.includes('space')) && !/<(span|div|p|a|img)\s/g.test(val)) { val = val.replace(/\s/ig, ' ') } @@ -786,13 +1030,14 @@ } 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) - - _style = mark.style if (mark.icon) { if (mark.position === 'front') { @@ -800,24 +1045,88 @@ } else { val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span> } + } else if (mark.space) { + val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</> + } else if (mark.point) { + if (mark.position === 'front') { + val = <>{mark.point}{val}</> + } else { + val = <>{val}{mark.point}</> + } } className = mark.signType } - let lineStyle = {height: card.innerHeight || 'auto'} - if (card.alignItems) { - lineStyle.display = 'flex' - lineStyle.alignItems = card.alignItems - lineStyle.justifyContent = _style.textAlign || 'left' + if (card.link && !data.$disabled) { + _style.cursor = 'pointer' + contents.push( + <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)}}> + {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 { + 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 === 'tag') { + let vals = '' + + if (card.datatype === 'static') { + vals = card.value + } else { + vals = data[card.field] || '' } - 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 || '') + className} style={lineStyle}>{val}</div> + if (!vals && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + vals = vals.split(',').filter(Boolean) + + if (card.signs) { + vals = vals.map(val => { + let sign = card.signs.filter(s => s.value === val)[0] + let cell = {value: val, style: {...card.style}} + + if (sign) { + cell.style.backgroundColor = sign.background + cell.style.color = sign.color + cell.style.borderColor = sign.border + + // delete cell.style.borderTopColor + // delete cell.style.borderBottomColor + // delete cell.style.borderLeftColor + // delete cell.style.borderRightColor + } + + return cell + }) + + contents.push( + <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> + <div className="ant-mk-tag"> + {vals.map((item, index) => <span key={index} className="tag-item" style={item.style}>{item.value}</span>)} + </div> </div> - </div> - ) + ) + } else { + contents.push( + <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> + <div className="ant-mk-tag"> + {vals.map((val, index) => <span key={index} className="tag-item" style={card.style}>{val}</span>)} + </div> + </div> + ) + } } else if (card.eleType === 'color') { let color = '' @@ -827,7 +1136,7 @@ color = data[card.field] || '' } - if (color === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!color && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -869,147 +1178,162 @@ if (data.$$type === 'extendCard') { _data = data.$$selectedData || [] + if (card.Ot === 'notRequired' && _data.length === 0) { + _data = [data] + } } else if (card.$sync) { _data = this.props.syncData || [] } else if (data.$$empty) { _data = [] + } + let name = '' + if (card.showName) { + name = data[card.showName] || ' ' } _style_ = _style_ || {} if (card.wrapStyle) { _style_ = {..._style_, ...card.wrapStyle} } + + let MkButton = null + let lid = (data.$$uuid || '') + (data.$Index || '') if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { - contents.push( - <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} - BData={data.$$BData || ''} - disabled={_disabled} - setting={cards.setting} - columns={cards.columns} - selectedData={_data} - /> - </div> - ) + MkButton = <NormalButton + btn={card} + name={name} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + columns={cards.columns} + selectedData={_data} + /> } else if (card.OpenType === 'excelIn') { - contents.push( - <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} - BData={data.$$BData || ''} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <ExcelInButton + btn={card} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> } else if (card.OpenType === 'excelOut') { - contents.push( - <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} - BData={data.$$BData || ''} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <ExcelOutButton + btn={card} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> } else if (card.OpenType === 'popview') { - contents.push( - <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} - BData={data.$$BData || ''} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <PopupButton + btn={card} + name={name} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> } else if (card.OpenType === 'tab') { - contents.push( - <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} - selectedData={_data} - /> - </div> - ) + MkButton = <TabButton + btn={card} + name={name} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + selectedData={_data} + /> } else if (card.OpenType === 'innerpage') { - contents.push( - <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> - <NewPageButton - btn={card} - BData={data.$$BData || ''} - disabled={_disabled} - selectedData={_data} - /> - </div> - ) + MkButton = <NewPageButton + btn={card} + name={name} + BID={data.$$BID} + LID={lid} + columns={cards.columns} + BData={data.$$BData || ''} + disabled={_disabled} + selectedData={_data} + /> } else if (card.OpenType === 'funcbutton') { if (card.funcType === 'changeuser' || card.funcType === 'closetab') { - contents.push( - <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} - BData={data.$$BData || ''} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <ChangeUserButton + btn={card} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> } else if (card.funcType === 'print') { - contents.push( - <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} - /> - </div> - ) + MkButton = <PrintButton + btn={card} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + columns={cards.columns} + selectedData={_data} + /> } else if (card.funcType === 'megvii') { - contents.push( - <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} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <FuncMegvii + btn={card} + BID={data.$$BID} + LID={lid} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> } else if (card.funcType === 'filezip') { - contents.push( - <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} - disabled={_disabled} - setting={cards.setting} - selectedData={_data} - /> - </div> - ) + MkButton = <FuncZip + btn={card} + BID={data.$$BID} + LID={lid} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + } else if (card.funcType === 'expPdf') { + MkButton = <ExportPdf + btn={card} + LID={lid} + /> + } else if (card.funcType === 'addline' || card.funcType === 'delline') { + MkButton = <EditLine + btn={card} + disabled={_disabled} + selectedData={_data} + /> + } else { + MkButton = <FuncButton + BID={data.$$BID} + disabled={_disabled} + LID={lid} + btn={card} + columns={cards.columns} + selectedData={_data} + /> } } + + if (MkButton) { + contents.push( + <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}> + {MkButton} + </div> + ) + } } }) -- Gitblit v1.8.0