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 | 259 +++++++++++++++++++++++++++++---------------------- 1 files changed, 146 insertions(+), 113 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index d997633..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 = '?' @@ -257,7 +289,7 @@ ) } 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( <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> </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( <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] || '' @@ -505,20 +530,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)) { @@ -531,8 +542,8 @@ <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> </div> ) @@ -566,7 +577,7 @@ ) } 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 @@ -636,7 +647,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -658,7 +669,7 @@ url = data[card.field] || '' } - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!url && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -690,7 +701,7 @@ val = data[card.field] || '' } - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -722,7 +733,7 @@ ) } 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,17 +833,11 @@ 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> ) @@ -827,7 +850,7 @@ color = data[card.field] || '' } - if (color === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + if (!color && card.noValue === 'hide') { // 绌哄�奸殣钘� return null } @@ -1008,6 +1031,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