From bf292de8879e2ce71696cb3ddc4dc8fa88d91a20 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 10 六月 2022 16:51:22 +0800 Subject: [PATCH] 2022-06-10 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 507 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 319 insertions(+), 188 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index cfd30dd..fd968c0 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -1,16 +1,19 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Col, Tooltip, notification } from 'antd' +import { Col, Tooltip, notification, Typography } from 'antd' import moment from 'moment' +// import Api from '@/api' import asyncComponent from './asyncButtonComponent' import asyncElementComponent from '@/utils/asyncComponent' - +import { getMark } from '@/utils/utils.js' +import MkIcon from '@/components/mk-icon' import MKEmitter from '@/utils/events.js' import LostPng from '@/assets/img/lost.png' import './index.scss' +const { Paragraph } = Typography const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton')) const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton')) const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton')) @@ -19,6 +22,7 @@ const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton')) const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton')) const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton')) +const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii')) const BarCode = asyncElementComponent(() => import('@/components/barcode')) const QrCode = asyncElementComponent(() => import('@/components/qrcode')) const MkProgress = asyncElementComponent(() => import('@/components/mkProgress')) @@ -70,6 +74,14 @@ openNewView = (e, card) => { const { cardCell, data, cards } = this.props + if (data.$disabled) return + + if (card.anchors && card.anchors.length > 0) { + 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() @@ -90,126 +102,101 @@ return } - if (/^sso$/ig.test(url)) { - if (!data.LinkUrl1) { - notification.warning({ - top: 92, - message: '閾炬帴鍦板潃涓嶅瓨鍦紒', - duration: 5 - }) - return + if (card.linkType === 'tel') { + window.open('tel:' + url) + return + } else if (card.linkType === 'email') { + let _url = 'mailto:' + url + let fullName = sessionStorage.getItem('Full_Name') || '' + if (fullName) { + _url = _url + `?subject=鏉ヨ嚜${fullName}鐨勯偖浠禶 } + window.open(_url) + return + } - let _url = data.LinkUrl1 - if (/index\.html/ig.test(_url)) { - _url = _url.replace(/index\.html.*/ig, '') - } else if (!/\/$/ig.test(_url)) { - _url = _url + '/' - } + // positecgroup + // if (/^sso$/ig.test(url)) { + // if (!data.LinkUrl1) { + // notification.warning({ + // top: 92, + // message: '閾炬帴鍦板潃涓嶅瓨鍦紒', + // duration: 5 + // }) + // return + // } - url = _url + 'index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({ - UserID: sessionStorage.getItem('UserID'), - LoginUID: sessionStorage.getItem('LoginUID'), - User_Name: sessionStorage.getItem('User_Name'), - Full_Name: sessionStorage.getItem('Full_Name'), - avatar: sessionStorage.getItem('avatar'), - dataM: data.dataM ? 'true' : '', - debug: data.debug || '', - role_id: data.role_id || '' - }))) + // 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 _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 + // }))) + + // window.open(href) + // } else { + // notification.warning({ + // top: 92, + // message: '淇℃伅缂哄け锛岃鑱旂郴绠$悊鍛橈紒', + // duration: 5 + // }) + // } + // }) + // return + // } + + let Id = '' + let con = '?' + + if (/\?/ig.test(url)) { + con = '&' + } + + if (cards.subtype === 'propcard' && cardCell) { + Id = cardCell.setting.primaryId || '' } else { - 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') || ''}` - } + 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') || ''}` } window.open(url) - } - - getMark = (marks, style, content) => { - const { data } = this.props - - marks.some(mark => { - let originVal = data[mark.field[0]] + '' - let contrastVal = '' - let result = false - - if (mark.field[1] === 'static') { - contrastVal = mark.contrastValue + '' - } else { - contrastVal = data[mark.field[2]] + '' - } - - if (mark.match === '=') { - result = originVal === contrastVal - } else if (mark.match === '!=') { - result = originVal !== contrastVal - } else if (mark.match === 'like') { - result = originVal.indexOf(contrastVal) > -1 - } else if (mark.match === '>') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { - result = true - } - } else if (mark.match === '<') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { - result = true - } - } - - if (result && mark.signType) { - if (mark.signType[0] === 'font') { - style.color = mark.color - } else if (mark.signType[0] === 'background') { - style.background = mark.color - if (mark.fontColor) { - style.color = mark.fontColor - } - } else if (mark.signType[0] === 'underline') { - style.textDecoration = 'underline' - style.color = mark.color - } else if (mark.signType[0] === 'line-through') { - style.textDecoration = 'line-through' - style.color = mark.color - } else if (mark.signType[0] === 'icon') { - let icon = (<Icon style={{color: mark.color}} type={mark.signType[3]} />) - if (mark.signType[1] === 'front') { - content = <span>{icon} {content}</span> - } else { - content = <span>{content} {icon}</span> - } - } - } - return result - }) - - return content } getColor = (marks) => { @@ -234,27 +221,9 @@ } else if (mark.match === 'like') { result = originVal.indexOf(contrastVal) > -1 } else if (mark.match === '>') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { - result = true - } + result = parseFloat(originVal) > parseFloat(contrastVal) } else if (mark.match === '<') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { - result = true - } + result = parseFloat(originVal) < parseFloat(contrastVal) } if (result) { @@ -275,7 +244,10 @@ _style.width = card.innerHeight _style.height = card.innerHeight _style.lineHeight = card.innerHeight + 'px' - this.getMark(card.marks, _style) + + let mark = getMark(card.marks, data, _style) + + _style = mark.style } return ( <Col key={card.uuid} span={card.width}> @@ -305,21 +277,97 @@ } if (val !== '' && 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)}` + let _val = null + + if (card.format === 'calendar1') { + _val = moment(val).calendar(null, { + sameDay: '[浠婂ぉ] ahh:mm', + nextDay: '[鏄庡ぉ] ahh:mm', + nextWeek: 'MM鏈圖D鏃� ahh:mm', + lastDay: '[鏄ㄥぉ] ahh:mm', + lastWeek: 'dddd ahh:mm', + sameElse: 'MM鏈圖D鏃� ahh:mm' + }) + } else if (card.format === 'calendar2') { + let time = new Date(val).getTime() + if (!isNaN(time)) { + time = parseInt(time / 60000) // 鏃堕棿鍊� + let now = parseInt(new Date().getTime() / 60000) // 褰撳墠鏃堕棿鍊� + let start = new Date(new Date().toDateString()).getTime() / 60000 // 浠婂ぉ闆剁偣鏃堕棿鍊� + let split = now - time + + if (split < 0) { // 鏃堕棿鍊煎湪褰撳墠鏃堕棿涔嬪悗 + _val = moment(val).format('MM鏈圖D鏃� HH:mm') + } else if (split < 3) { + _val = '鍒氬垰' + } else if (split < 5) { + _val = '3鍒嗛挓鍓�' + } else if (split < 10) { + _val = '5鍒嗛挓鍓�' + } else if (split < 20) { + _val = '10鍒嗛挓鍓�' + } else if (split < 30) { + _val = '20鍒嗛挓鍓�' + } else if (split < 60) { + _val = '30鍒嗛挓鍓�' + } else if (split < 420 || time > start) { // 7灏忔椂鍐呮垨鏃堕棿鍊煎湪浠婂ぉ闆剁偣鍚� + _val = parseInt(split / 60) + '灏忔椂鍓�' + } else { // 鏃堕棿鍊煎湪浠婂ぉ闆剁偣涔嬪墠 + let _day = parseInt((start - time) / (24 * 60)) + 1 + if (_day === 1) { + _val = '鏄ㄥぉ' + } else if (_day <= 30) { + _val = _day + '澶╁墠' + } else { + _val = moment(val).format('MM鏈圖D鏃� HH:mm') + } + } + } + } 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 !== '') { - val = `${card.prefix || ''}${val}${card.postfix || ''}` + let orival = val + if (card.fixStyle === 'alone') { + let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} + val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></> + } else { + val = `${card.prefix || ''}${val}${card.postfix || ''}` + } + if (card.copyable === 'true') { + val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph> + } } if (card.marks) { - val = this.getMark(card.marks, _style, val) + 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> + } + } } - if (card.link) { + if (card.link || (card.anchors && card.anchors.length > 0)) { _style.cursor = 'pointer' + } + + if (card.bgImage && data[card.bgImage]) { + _style.backgroundImage = `url('${data[card.bgImage]}')` } return ( @@ -339,13 +387,19 @@ val = data[card.field] } - if (val !== '' && typeof(val) === 'number') { + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + if (typeof(val) === 'number') { if (card.format === 'percent') { val = val * 100 + } else if (card.format === 'abs') { + val = Math.abs(val) } - if (card.col && card.col.type === 'number') { - let decimal = card.col.decimal || 0 + if (typeof(card.decimal) === 'number') { + let decimal = card.decimal if (card.format === 'percent') { decimal = decimal - 2 @@ -367,11 +421,26 @@ } if (val !== '') { - val = `${card.prefix || ''}${val}${card.postfix || ''}` + if (card.fixStyle === 'alone') { + let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} + val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></> + } else { + val = `${card.prefix || ''}${val}${card.postfix || ''}` + } } if (card.marks) { - val = this.getMark(card.marks, _style, val) + 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> + } + } } return ( @@ -394,8 +463,8 @@ <Col key={card.uuid} span={card.width}> <div style={card.style}> {val ? <Tooltip title={val}> - <Icon type={card.icon}/> - </Tooltip> : <Icon type={card.icon}/>} + <MkIcon className="ant-mk-icon" style={{height: card.innerHeight || 'auto'}} type={card.icon}/> + </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight || 'auto'}} type={card.icon}/>} </div> </Col> ) @@ -536,10 +605,18 @@ return null } + let poster = '' + + if (card.posterType === 'dynamic') { + poster = data[card.posterField] || '' + } else { + poster = card.posterUrl || '' + } + return ( <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <Video card={card} value={url}/> + <div className="video-wrap" style={card.style}> + <Video card={card} poster={poster} value={url}/> </div> </Col> ) @@ -566,10 +643,19 @@ </Col> ) } else if (card.eleType === 'currentDate') { + let val = moment().format(card.dateFormat || 'YYYY-MM-DD') + + if (card.fixStyle === 'alone') { + let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} + val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></> + } else { + val = `${card.prefix || ''}${val}${card.postfix || ''}` + } + return ( <Col key={card.uuid} span={card.width}> <div className="ant-mk-date" style={card.style}> - {card.dateFormat ? `${card.prefix || ''}${moment().format(card.dateFormat)}${card.postfix || ''}` : null} + {val} </div> </Col> ) @@ -596,7 +682,7 @@ } } - if (!val) return + // if (!val) return val += _val }) @@ -619,16 +705,36 @@ val = _val === undefined ? '' : _val } + if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + if (val !== '') { - val = `${card.prefix || ''}${val}${card.postfix || ''}` - if (card.eval === 'false' && /\s/ig.test(val)) { - val = val.replace(/\s/ig, ' ') + if (val && typeof(val) === 'string') { + val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') val = <span dangerouslySetInnerHTML={{__html: val}}></span> + } + + if (card.fixStyle === 'alone') { + let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight} + val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></> + } else { + val = `${card.prefix || ''}${val}${card.postfix || ''}` } } if (card.marks) { - val = this.getMark(card.marks, _style, val) + 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> + } + } } return ( @@ -639,23 +745,37 @@ </Col> ) } else if (card.eleType === 'button') { + let _disabled = data.$disabled + if (card.control === 'hidden') { + let s = data[card.controlField] !== undefined ? data[card.controlField] + '' : '' + if (s === card.controlVal || (card.controlVal && card.controlVal.split(',').includes(s))) { + return null + } + } else if (card.control === 'disabled') { + let s = data[card.controlField] !== undefined ? data[card.controlField] + '' : '' + if (s === card.controlVal || (card.controlVal && card.controlVal.split(',').includes(s))) { + _disabled = true + } + } + let _data = [data] - if (data.$$type === 'extendCard' || data.$$empty) { - _data = [] + if (data.$$type === 'extendCard') { + _data = data.$$selectedData || [] } else if (card.$sync) { _data = this.props.syncData + } else if (data.$$empty) { + _data = [] } - if (['exec', 'prompt', 'pop'].includes(card.OpenType)) { + if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <NormalButton + btn={card} BID={data.$$BID} BData={data.$$BData || ''} - btn={card} - show={card.show} - style={card.style} + disabled={_disabled} setting={cards.setting} columns={cards.columns} selectedData={_data} @@ -664,12 +784,12 @@ ) } else if (card.OpenType === 'excelIn') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <ExcelInButton - BID={data.$$BID} btn={card} - show={card.show} - style={card.style} + BID={data.$$BID} + BData={data.$$BData || ''} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> @@ -677,25 +797,25 @@ ) } else if (card.OpenType === 'excelOut') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <ExcelOutButton - BID={data.$$BID} btn={card} - show={card.show} - style={card.style} + BID={data.$$BID} + BData={data.$$BData || ''} + disabled={_disabled} setting={cards.setting} + selectedData={_data} /> </Col> ) } else if (card.OpenType === 'popview') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <PopupButton + btn={card} BID={data.$$BID} BData={data.$$BData || ''} - btn={card} - show={card.show} - style={card.style} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> @@ -703,11 +823,11 @@ ) } else if (card.OpenType === 'tab') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <TabButton btn={card} - show={card.show} - style={card.style} + BData={data.$$BData || ''} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> @@ -715,11 +835,11 @@ ) } else if (card.OpenType === 'innerpage') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <NewPageButton btn={card} - show={card.show} - style={card.style} + BData={data.$$BData || ''} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> @@ -728,12 +848,12 @@ } else if (card.OpenType === 'funcbutton') { if (card.funcType === 'changeuser' || card.funcType === 'closetab') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <ChangeUserButton - BID={data.$$BID} btn={card} - show={card.show} - style={card.style} + BID={data.$$BID} + BData={data.$$BData || ''} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> @@ -741,13 +861,24 @@ ) } else if (card.funcType === 'print') { return ( - <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> <PrintButton + btn={card} BID={data.$$BID} BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </Col> + ) + } else if (card.funcType === 'megvii') { + return ( + <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> + <FuncMegvii btn={card} - show={card.show} - style={card.style} + BID={data.$$BID} + disabled={_disabled} setting={cards.setting} selectedData={_data} /> -- Gitblit v1.8.0