From 08cce3334a2dc81d690b518136b0aaea64e48b0b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 14 六月 2023 09:55:50 +0800 Subject: [PATCH] 2023-06-14 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 352 ++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 193 insertions(+), 159 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 94c16f6..030841b 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -4,7 +4,7 @@ import { Col, Tooltip, notification, Typography, message } from 'antd' import moment from 'moment' -// import Api from '@/api' +import Api from '@/api' import asyncComponent from './asyncButtonComponent' import asyncElementComponent from '@/utils/asyncComponent' import { getMark } from '@/utils/utils.js' @@ -24,6 +24,7 @@ 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 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')) @@ -35,6 +36,37 @@ '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 { static propTpyes = { cards: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 @@ -44,10 +76,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), fromJS(nextProps)) } /** @@ -70,7 +100,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 = '' @@ -101,71 +131,73 @@ } window.open(_url) return + } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) { + return } // positecgroup - // if (/^sso$/ig.test(url)) { - // if (!data.LinkUrl1) { - // notification.warning({ - // top: 92, - // message: '閾炬帴鍦板潃涓嶅瓨鍦紒', - // duration: 5 - // }) - // return - // } + if (/^sso$/ig.test(url)) { + if (!data.LinkUrl1) { + notification.warning({ + top: 92, + message: '閾炬帴鍦板潃涓嶅瓨鍦紒', + duration: 5 + }) + return + } - // let _url = data.LinkUrl1 - // if (/index\.html/ig.test(_url)) { - // _url = _url.replace(/index\.html.*/ig, '') - // } else if (!/\/$/ig.test(_url)) { - // _url = _url + '/' - // } + let _url = data.LinkUrl1 + if (/index\.html/ig.test(_url)) { + _url = _url.replace(/index\.html.*/ig, '') + } else if (!/\/$/ig.test(_url)) { + _url = _url + '/' + } - // let key = (() => { - // let uuid = [] - // let timestamp = new Date().getTime() - // let _options = '0123456789abcdefghigklmnopqrstuv' - // for (let i = 0; i < 19; i++) { - // uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) - // } - // uuid = timestamp + uuid.join('') - // return uuid - // })() + let key = (() => { + let uuid = [] + let timestamp = new Date().getTime() + let _options = '0123456789abcdefghigklmnopqrstuv' + for (let i = 0; i < 19; i++) { + uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) + } + uuid = timestamp + uuid.join('') + return uuid + })() - // let _param = { - // func: 'webapi_scan_binding_key', - // binding_type: 'mk', - // scan_type: 'toggle', - // scan_appkey: data.scan_appkey || '', - // id: key - // } + let _param = { + func: 'webapi_scan_binding_key', + binding_type: 'mk', + scan_type: 'toggle', + scan_appkey: data.scan_appkey || '', + id: key + } - // Api.getSystemConfig(_param).then(res => { - // if (!res.status) { - // notification.warning({ - // top: 92, - // message: res.message, - // duration: 5 - // }) - // } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) { - // let href = _url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({ - // appid: res.thd_party_appid, - // memberId: res.thd_party_member_id, - // openid: res.thd_party_openid, - // key: key - // }))) + Api.getSystemConfig(_param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) { + let href = _url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({ + appid: res.thd_party_appid, + memberId: res.thd_party_member_id, + openid: res.thd_party_openid, + key: key + }))) - // window.open(href) - // } else { - // notification.warning({ - // top: 92, - // message: '淇℃伅缂哄け锛岃鑱旂郴绠$悊鍛橈紒', - // duration: 5 - // }) - // } - // }) - // return - // } + window.open(href) + } else { + notification.warning({ + top: 92, + message: '淇℃伅缂哄け锛岃鑱旂郴绠$悊鍛橈紒', + duration: 5 + }) + } + }) + return + } let Id = '' let con = '?' @@ -249,15 +281,15 @@ className = mark.signType } contents.push( - <Col key={card.uuid} style={_style_} 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' + 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 || '' @@ -285,7 +317,7 @@ val = data[card.field] } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -375,6 +407,9 @@ 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 = '' @@ -400,24 +435,18 @@ 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 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> + {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 @@ -460,6 +489,9 @@ } 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 = '' @@ -478,24 +510,17 @@ 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 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> - </Col> + </div> ) } else if (card.eleType === 'icon') { let val = '' let icon = '' - let height = card.innerHeight if (card.datatype === 'dynamic') { icon = data[card.field] || '' @@ -506,20 +531,6 @@ 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] @@ -528,13 +539,13 @@ } contents.push( - <Col key={card.uuid} style={_style_} span={card.width}> + <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}/>} + <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/> + </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>} </div> - </Col> + </div> ) } else if (card.eleType === 'slider') { let val = 0 @@ -558,15 +569,15 @@ } contents.push( - <Col key={card.uuid} style={_style_} 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 @@ -610,22 +621,22 @@ let urls = url ? url.split(',').filter(Boolean) : [''] urls.forEach((u, i) => { - contents.push(<Col key={card.uuid + i} style={_style_} 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)}}> <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={_style_}> + <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 = '' @@ -636,18 +647,18 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } contents.push( - <Col key={card.uuid} style={_style_} 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 = '' @@ -658,7 +669,7 @@ url = data[card.field] || '' } - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!url && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -674,11 +685,11 @@ urls.forEach((u, i) => { contents.push( - <Col key={card.uuid + i} style={_style_} 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') { @@ -690,18 +701,18 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } contents.push( - <Col key={card.uuid} style={_style_} 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') @@ -714,15 +725,15 @@ } contents.push( - <Col key={card.uuid} style={_style_} 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} : {} + let _style = {...card.style} if (card.$sync) { if (card.eval === 'false') { @@ -739,6 +750,10 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + if (window.debugger) { + console.info(_val) + console.warn(e) + } _val = 0 } } @@ -747,6 +762,8 @@ val += _val }) + } else if (data && data.$$empty) { + val = '' } else if (data) { let _val = card.formula Object.keys(data).forEach(key => { @@ -759,6 +776,10 @@ // eslint-disable-next-line _val = eval(_val) } catch (e) { + if (window.debugger) { + console.info(_val) + console.warn(e) + } _val = '' } } @@ -766,8 +787,13 @@ 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 !== '') { @@ -786,6 +812,9 @@ } 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 = '' @@ -804,19 +833,13 @@ 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 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> - </Col> + </div> ) } else if (card.eleType === 'color') { let color = '' @@ -827,7 +850,7 @@ color = data[card.field] || '' } - if (color === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!color && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -844,7 +867,7 @@ } contents.push( - <Col key={card.uuid} style={_style_} span={card.width}> + <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') { @@ -861,7 +884,7 @@ } }}></div> </div> - </Col> + </div> ) } else if (card.eleType === 'button') { let _disabled = data.$disabled @@ -882,7 +905,7 @@ if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -892,11 +915,11 @@ columns={cards.columns} selectedData={_data} /> - </Col> + </div> ) } else if (card.OpenType === 'excelIn') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -905,11 +928,11 @@ setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) } else if (card.OpenType === 'excelOut') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -918,11 +941,11 @@ setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) } else if (card.OpenType === 'popview') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -931,11 +954,11 @@ setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) } else if (card.OpenType === 'tab') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -943,23 +966,23 @@ disabled={_disabled} selectedData={_data} /> - </Col> + </div> ) } else if (card.OpenType === 'innerpage') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} BData={data.$$BData || ''} disabled={_disabled} 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={_style_} 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} @@ -968,11 +991,11 @@ setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) } else if (card.funcType === 'print') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -982,11 +1005,11 @@ columns={cards.columns} selectedData={_data} /> - </Col> + </div> ) } else if (card.funcType === 'megvii') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -994,11 +1017,11 @@ setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) } else if (card.funcType === 'filezip') { contents.push( - <Col key={card.uuid} className="mk-cell-btn" style={_style_} 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} @@ -1006,7 +1029,17 @@ 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> ) } } @@ -1022,6 +1055,7 @@ return ( <div className={'card-cell-list ' + (cardCell && cardCell.setting && cardCell.setting.layout === 'flex' ? 'mk-flex' : '')}> {this.getContent()} + <Col style={{display: 'none'}} span={24}></Col> </div> ) } -- Gitblit v1.8.0