From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 15 八月 2023 14:22:03 +0800 Subject: [PATCH] 2023-08-15 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 143 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 113 insertions(+), 30 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index fe7a373..493a682 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' @@ -24,9 +23,10 @@ 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 = { @@ -75,10 +75,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))) } /** @@ -101,7 +99,7 @@ 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 = '' @@ -131,6 +129,8 @@ _url = _url + `?subject=鏉ヨ嚜${fullName}鐨勯偖浠禶 } window.open(_url) + return + } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) { return } @@ -199,11 +199,6 @@ // } let Id = '' - let con = '?' - - if (/\?/ig.test(url)) { - con = '&' - } if (cards.subtype === 'propcard' && cardCell) { Id = cardCell.setting.primaryId || '' @@ -212,6 +207,12 @@ } 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') || ''}` } @@ -264,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') { @@ -316,7 +319,7 @@ val = data[card.field] } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -523,6 +526,8 @@ if (card.datatype === 'dynamic') { icon = data[card.field] || '' + } else if (card.tipType === 'text') { + icon = card.value } else { icon = card.icon } @@ -536,16 +541,38 @@ } 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: card.innerHeight}} type={icon}/> - </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} 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 @@ -646,7 +673,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -668,7 +695,7 @@ url = data[card.field] || '' } - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!url && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -700,7 +727,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -733,8 +760,26 @@ } 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) { + if (window.GLOB.debugger === true) { + console.warn(e) + } + val = '' + } + } else if (card.$sync) { if (card.eval === 'false') { val = '' } @@ -749,6 +794,10 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + if (window.GLOB.debugger === true) { + console.info(_val) + console.warn(e) + } _val = 0 } } @@ -757,6 +806,8 @@ val += _val }) + } else if (data && data.$$empty) { + val = '' } else if (data) { let _val = card.formula Object.keys(data).forEach(key => { @@ -769,6 +820,10 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + if (window.GLOB.debugger === true) { + console.info(_val) + console.warn(e) + } _val = '' } } @@ -776,8 +831,22 @@ 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 !== '') { @@ -834,7 +903,7 @@ color = data[card.field] || '' } - if (color === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!color && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -876,6 +945,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) { @@ -957,6 +1029,7 @@ <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} selectedData={_data} @@ -1015,6 +1088,16 @@ /> </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> + ) } } } -- Gitblit v1.8.0