From e07e410cf2fbc64c4e1fa8a080a9aac6a3d0c305 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 23 十月 2023 10:39:50 +0800 Subject: [PATCH] 2023-10-23 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 98 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 75 insertions(+), 23 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 85b86b8..5ca4716 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -5,8 +5,7 @@ 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 Encrypts from '@/components/encrypts' @@ -25,9 +24,9 @@ const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii')) const FuncZip = asyncComponent(() => import('@/tabviews/zshare/actionList/funczip')) const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine')) -const BarCode = asyncElementComponent(() => import('@/components/barcode')) -const QrCode = asyncElementComponent(() => import('@/components/qrcode')) -const MkProgress = asyncElementComponent(() => import('@/components/mkProgress')) +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 = { @@ -77,7 +76,7 @@ } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.data), fromJS(nextProps.data)) + return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false) } /** @@ -266,6 +265,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') { @@ -277,8 +278,7 @@ _style.lineHeight = card.innerHeight + 'px' let mark = getMark(card.marks, data, _style) - - _style = mark.style + className = mark.signType } contents.push( @@ -417,13 +417,19 @@ if (card.marks) { let mark = getMark(card.marks, data, _style) - _style = mark.style - if (mark.icon) { if (mark.position === 'front') { val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span> } 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 @@ -499,13 +505,19 @@ if (card.marks) { let mark = getMark(card.marks, data, _style) - _style = mark.style - if (mark.icon) { if (mark.position === 'front') { val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span> } 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 @@ -539,6 +551,16 @@ val = data[card.tooltip] } else { val = card.tooltip + } + + 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') { @@ -749,8 +771,24 @@ } else if (card.eleType === 'formula') { let val = 0 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) { + 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 = '' } @@ -765,10 +803,8 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { - if (window.debugger) { - console.info(_val) - console.warn(e) - } + console.info(_val) + console.warn(e) _val = 0 } } @@ -791,10 +827,8 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { - if (window.debugger) { - console.info(_val) - console.warn(e) - } + console.info(_val) + console.warn(e) _val = '' } } @@ -804,6 +838,15 @@ 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') { @@ -836,13 +879,19 @@ if (card.marks) { let mark = getMark(card.marks, data, _style) - _style = mark.style - if (mark.icon) { if (mark.position === 'front') { val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span> } 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 @@ -907,6 +956,9 @@ 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) { -- Gitblit v1.8.0