From 20185ab64a165df51515d9fa1c9b12a7a8c55f59 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 07 四月 2023 23:11:04 +0800 Subject: [PATCH] 2023-04-07 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 1446 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 826 insertions(+), 620 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index bfbb71e..d997633 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -1,17 +1,19 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Col, Tooltip, notification } from 'antd' +import { Col, Tooltip, notification, Typography, message } 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 Encrypts from '@/components/encrypts' import './index.scss' +moment.suppressDeprecationWarnings = true +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')) @@ -20,10 +22,13 @@ 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 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 Video = asyncComponent(() => import('@/components/video')) +const MkPicture = asyncComponent(() => import('@/components/mkPicture')) const PicRadio = { '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%', '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%', @@ -39,21 +44,7 @@ elements: PropTypes.array, // 鍏冪礌闆� } - state = { - card: null, // 缂栬緫涓厓绱� - elements: null, // 鎸夐挳缁� - } - - /** - * @description 鎼滅储鏉′欢鍒濆鍖� - */ - UNSAFE_componentWillMount () { - const { elements } = this.props - - this.setState({ - elements: fromJS(elements).toJS() - }) - } + state = {} shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props), fromJS(nextProps)) @@ -70,6 +61,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() @@ -104,50 +103,85 @@ return } - if (/^sso$/ig.test(url)) { - if (!data.LinkUrl1) { - notification.warning({ - top: 92, - message: '閾炬帴鍦板潃涓嶅瓨鍦紒', - duration: 5 - }) - return - } + // positecgroup + // 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 + '/' + // } - 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 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) @@ -189,634 +223,806 @@ return color } - getContent = (card) => { - const { data, cards } = this.props + getContent = () => { + const { data, cards, elements } = this.props - if (card.eleType === 'sequence') { - let _style = {} - if (card.marks) { - _style.width = card.innerHeight - _style.height = card.innerHeight - _style.lineHeight = card.innerHeight + 'px' + let contents = [] - let mark = getMark(card.marks, data, _style) + elements.forEach(card => { + let _style_ = null - _style = mark.style + if (card.style && card.style.clear === 'left') { + _style_ = {clear: 'left'} } - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <div className="ant-mk-text"><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div> - </div> - </Col> - ) - } else if (card.eleType === 'text') { - let val = '' - let _style = card.style ? {...card.style} : {} - if (card.datatype === 'static') { - val = card.value || '' - if (/@username@|@fullName@|@login_city@/ig.test(val)) { - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - let city = sessionStorage.getItem('city') || '' - val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@login_city@/ig, city) + if (card.eleType === 'sequence') { + let _style = {} + let className = '' + if (card.marks) { + _style.width = card.innerHeight + _style.height = card.innerHeight + _style.lineHeight = card.innerHeight + 'px' + + let mark = getMark(card.marks, data, _style) + + _style = mark.style + className = mark.signType } - } else if (data.hasOwnProperty(card.field)) { - val = data[card.field] - } - - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - if (val !== '' && card.format) { - 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 { + contents.push( + <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> + </div> + ) + } else if (card.eleType === 'text') { + let val = '' + let _style = card.style ? {...card.style} : {} + + if (card.datatype === 'static') { + val = card.value || '' + if (/@username@|@fullName@|@mk_city@|@bid@/ig.test(val)) { + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + let bid = data.$$BID || '' + val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@bid@/ig, bid) + } else if (/@month@/ig.test(val)) { + val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' })) + } else if (/@week@/ig.test(val)) { + val = val.replace(/@week@/ig, (() => { + let day = new Date().getDay() + let weeks = ['鏄熸湡鏃�', '鏄熸湡涓�', '鏄熸湡浜�', '鏄熸湡涓�', '鏄熸湡鍥�', '鏄熸湡浜�', '鏄熸湡鍏�'] + return weeks[day] + })()) + } else if (/@day@/ig.test(val)) { + val = val.replace(/@day@/ig, (() => { + let day = new Date().getDate() + return day < 10 ? '0' + day : day + })()) + } + } else if (data.hasOwnProperty(card.field)) { + val = data[card.field] + } + + if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + if (val !== '' && card.format) { + 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 || ''}` - } - - if (card.marks) { - let mark = getMark(card.marks, data, _style) - - _style = mark.style - - if (mark.icon) { - if (mark.position === 'front') { - val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span> } else { - val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> - } - } - } - - if (card.link) { - _style.cursor = 'pointer' - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> - <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> - </div> - </Col> - ) - } else if (card.eleType === 'number') { - let val = '' - let _style = card.style ? {...card.style} : {} - - if (card.datatype === 'static') { - val = card.value - } else if (data.hasOwnProperty(card.field)) { - val = data[card.field] - } - - 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 (typeof(card.decimal) === 'number') { - let decimal = card.decimal - - if (card.format === 'percent') { - decimal = decimal - 2 - } - if (decimal < 0) { - decimal = 0 + _val = moment(val).format(card.format) } - val = val.toFixed(decimal) - } else { - val = '' + val - } - - if (card.format === 'percent' && (!card.postfix || card.postfix.indexOf('%') === -1)) { - val = val + '%' - } else if (card.format === 'thdSeparator') { - val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') - } - } - - if (val !== '') { - val = `${card.prefix || ''}${val}${card.postfix || ''}` - } - - if (card.marks) { - let mark = getMark(card.marks, data, _style) - - _style = mark.style - - if (mark.icon) { - if (mark.position === 'front') { - val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span> - } else { - val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + // 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 !== '') { + let orival = val + if (card.format === 'encryption') { + val = <Encrypts value={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 = <span>{card.prefix || ''}{val}{card.postfix || ''}</span> + } - return ( - <Col key={card.uuid} span={card.width}> - <div style={_style}> - <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> - </div> - </Col> - ) - } else if (card.eleType === 'icon') { - let val = '' + if (card.copyable === 'true') { + if (card.link || (card.anchors && card.anchors.length > 0)) { + let url = orival - if (card.datatype === 'static') { - val = card.tooltip - } else if (data.hasOwnProperty(card.field)) { - val = data[card.field] - } + if (card.link === 'static') { + url = card.linkurl + } else if (card.link === 'dynamic') { + url = data[card.linkurl] + } - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - {val ? <Tooltip title={val}> - <MkIcon type={card.icon}/> - </Tooltip> : <MkIcon type={card.icon}/>} - </div> - </Col> - ) - } else if (card.eleType === 'slider') { - let val = 0 - let color = card.color - - if (card.datatype === 'static') { - val = card.value - } else if (data.hasOwnProperty(card.field)) { - val = parseFloat(data[card.field]) - if (isNaN(val)) { - val = 0 + val = <span>{val}<Paragraph style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()} copyable={{ text: url }}></Paragraph></span> + } else { + val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph> + } + } } - } - - val = val / card.maxValue * 100 - val = parseInt(val * 100) / 100 - - if (card.marks) { - let _color = this.getColor(card.marks) - color = _color ? _color : color - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <MkProgress value={val} config={card} color={color}/> - </div> - </Col> - ) - } else if (card.eleType === 'picture') { - let _imagestyle = {} - let _style = card.style ? {margin: '0 auto', ...card.style} : {} - let url = '' - if (card.maxWidth) { - _style.maxWidth = card.maxWidth - if (_style.marginLeft === '0px') { - delete _style.marginLeft + + let className = '' + 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> + } + } + className = mark.signType } - if (_style.marginRight === '0px') { - delete _style.marginRight + + if (card.link || (card.anchors && card.anchors.length > 0)) { + _style.cursor = 'pointer' } - } + + if (card.bgImage && data[card.bgImage]) { + _style.backgroundImage = `url('${data[card.bgImage]}')` + } - if (card.datatype === 'static') { - url = card.url || '' - } else { - url = data[card.field] || '' - } - - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - if (url) { - _imagestyle = {backgroundImage: `url('${url}')`} - } else { - _imagestyle = {backgroundImage: `url(${LostPng})`, backgroundSize: 'contain'} - } - - if (_style.borderRadius) { - _imagestyle.borderRadius = _style.borderRadius - } - - if (PicRadio[card.lenWidRadio]) { - _imagestyle.paddingTop = PicRadio[card.lenWidRadio] - } else { - _imagestyle.paddingTop = '100%' - } - - if (card.link) { - _style.cursor = 'pointer' - } - - let scale = url && card.scale === 'true' - - return ( - <Col key={card.uuid} span={card.width}> - <div style={_style} onClick={(e) => {this.openNewView(e, card)}}> - <div - className={'ant-mk-picture' + (scale ? ' scale' : '')} - onClick={(e) => { - if (scale) { - e.stopPropagation() - } else { - return - } - - MKEmitter.emit('mkImageScale', url) - }} - style={_imagestyle} - ></div> - </div> - </Col> - ) - } else if (card.eleType === 'splitline') { - let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div> - </div> - </Col> - ) - } else if (card.eleType === 'barcode') { - let val = '' - - if (card.datatype === 'static') { - val = card.value - } else if (data.hasOwnProperty(card.field)) { - val = data[card.field] || '' - } - - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <div style={{height: card.innerHeight || 25}}> - {val ? <BarCode card={card} value={val}/> : null} + 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> </div> </div> - </Col> - ) - } else if (card.eleType === 'video') { - let url = '' + ) + } else if (card.eleType === 'number') { + let val = '' + let _style = card.style ? {...card.style} : {} + + if (card.datatype === 'static') { + val = card.value + } else if (data.hasOwnProperty(card.field)) { + val = data[card.field] + } + + if (!val && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + if (!isNaN(val) && val !== '') { + val = +val + if (card.round) { + val = Math.round(val * card.round) / card.round + } + if (card.format === 'percent') { + val = val * 100 + } else if (card.format === 'abs') { + val = Math.abs(val) + } + + if (card.round) { + val = val.toFixed(card.decimal) + } else { + val = '' + val + } - if (card.datatype === 'static') { - url = card.url - } else { - url = data[card.field] || '' - } + if (card.format === 'percent' && (!card.postfix || card.postfix.indexOf('%') === -1)) { + val = val + '%' + } else if (card.format === 'thdSeparator') { + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } + } + + if (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 || ''}` + } + } + + let className = '' + 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> + } + } + className = mark.signType + } - if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <Video card={card} value={url}/> - </div> - </Col> - ) - } else if (card.eleType === 'qrcode') { - let val = '' - - if (card.datatype === 'static') { - val = card.value - } else if (data.hasOwnProperty(card.field)) { - val = data[card.field] || '' - } - - if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� - return null - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <div style={{minHeight: card.qrWidth || 50}}> - {val ? <QrCode card={card} value={val}/> : null} + 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> </div> </div> - </Col> - ) - } else if (card.eleType === 'currentDate') { - 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} - </div> - </Col> - ) - } else if (card.eleType === 'formula') { - let val = 0 - let _style = card.style ? {...card.style} : {} + ) + } else if (card.eleType === 'icon') { + let val = '' + let icon = '' + let height = card.innerHeight - if (card.$sync) { - if (card.eval === 'false') { - val = '' + if (card.datatype === 'dynamic') { + icon = data[card.field] || '' + } else { + icon = card.icon } - this.props.syncData.forEach(item => { - let _val = card.formula - Object.keys(item).forEach(key => { - let reg = new RegExp('@' + key + '@', 'ig') - _val = _val.replace(reg, item[key]) + + 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] + } 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: height}} type={icon}/> + </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: height}} type={icon}/>} + </div> + </div> + ) + } else if (card.eleType === 'slider') { + let val = 0 + let color = card.color + + if (card.datatype === 'static') { + val = card.value + } else if (data.hasOwnProperty(card.field)) { + val = parseFloat(data[card.field]) + if (isNaN(val)) { + val = 0 + } + } + + val = val / card.maxValue * 100 + val = parseInt(val * 100) / 100 + + if (card.marks) { + let _color = this.getColor(card.marks) + color = _color ? _color : color + } + + contents.push( + <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> + </div> + ) + } else if (card.eleType === 'picture') { + let _imagestyle = {} + let _style = card.style ? {margin: '0 auto', ...card.style} : {} + let url = '' + if (card.maxWidth) { + _style.maxWidth = card.maxWidth + if (_style.marginLeft === '0px') { + delete _style.marginLeft + } + if (_style.marginRight === '0px') { + delete _style.marginRight + } + } + + if (card.datatype === 'static') { + url = card.url || '' + if (url === '@icon@') { + url = sessionStorage.getItem('avatar') || '' + } + } else { + url = data[card.field] || '' + } + + if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + if (PicRadio[card.lenWidRadio]) { + _imagestyle.paddingTop = PicRadio[card.lenWidRadio] + } else { + _imagestyle.paddingTop = '100%' + } + + _imagestyle.borderRadius = _style.borderRadius || 0 + _imagestyle.backgroundSize = _style.backgroundSize || 'cover' + _imagestyle.backgroundPosition = _style.backgroundPosition || 'center' + _imagestyle.backgroundRepeat = _style.backgroundRepeat || 'no-repeat' + + if (card.link) { + _style.cursor = 'pointer' + } + + let scale = url && card.scale === 'true' + let urls = url ? url.split(',').filter(Boolean) : [''] + + urls.forEach((u, i) => { + 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> + </div>) + }) + } else if (card.eleType === 'splitline') { + let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth + _style_ = _style_ || {} + _style_.minHeight = _borderWidth + contents.push( + <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> + </div> + ) + } else if (card.eleType === 'barcode') { + let val = '' + + if (card.datatype === 'static') { + val = card.value + } else if (data.hasOwnProperty(card.field)) { + val = data[card.field] || '' + } + + if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + contents.push( + <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> + </div> + ) + } else if (card.eleType === 'video') { + let url = '' + + if (card.datatype === 'static') { + url = card.url + } else { + url = data[card.field] || '' + } + + if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + let poster = '' + + if (card.posterType === 'dynamic') { + poster = data[card.posterField] || '' + } else { + poster = card.posterUrl || '' + } + + let urls = url.split(',').filter(Boolean) + + urls.forEach((u, i) => { + contents.push( + <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> + </div> + ) + }) + } else if (card.eleType === 'qrcode') { + let val = '' + + if (card.datatype === 'static') { + val = card.value + } else if (data.hasOwnProperty(card.field)) { + val = data[card.field] || '' + } + + if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + contents.push( + <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> + </div> + ) + } 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 || ''}` + } + + contents.push( + <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> + </div> + ) + } else if (card.eleType === 'formula') { + let val = 0 + let _style = card.style ? {...card.style} : {} + + if (card.$sync) { + if (card.eval === 'false') { + val = '' + } + this.props.syncData.forEach(item => { + let _val = card.formula + Object.keys(item).forEach(key => { + let reg = new RegExp('@' + key + '@', 'ig') + _val = _val.replace(reg, item[key]) + }) + if (card.eval !== 'false') { + try { + // eslint-disable-next-line + _val = eval(_val) + } catch (e) { + _val = 0 + } + } + + // if (!val) return + + val += _val }) + } else if (data) { + let _val = card.formula + Object.keys(data).forEach(key => { + let reg = new RegExp('@' + key + '@', 'ig') + _val = _val.replace(reg, data[key]) + }) + if (card.eval !== 'false') { try { // eslint-disable-next-line _val = eval(_val) } catch (e) { - _val = 0 + _val = '' } } - - if (!val) return - - val += _val - }) - } else if (data) { - let _val = card.formula - Object.keys(data).forEach(key => { - let reg = new RegExp('@' + key + '@', 'ig') - _val = _val.replace(reg, data[key]) - }) - - if (card.eval !== 'false') { - try { - // eslint-disable-next-line - _val = eval(_val) - } catch (e) { - _val = '' - } + + val = _val === undefined ? '' : _val } - val = _val === undefined ? '' : _val - } - - if (val !== '') { - val = `${card.prefix || ''}${val}${card.postfix || ''}` - if (card.eval === 'false') { - val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') - val = <span dangerouslySetInnerHTML={{__html: val}}></span> - } - } - - if (card.marks) { - let mark = getMark(card.marks, data, _style) - - _style = mark.style - - if (mark.icon) { - if (mark.position === 'front') { - val = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {val}</span> - } else { - val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> - } - } - } - - return ( - <Col key={card.uuid} span={card.width}> - <div style={_style}> - <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> - </div> - </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))) { + if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� 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 + + if (val !== '') { + if (val && typeof(val) === 'string') { + val = val.replace(/\n/ig, '<br/>') + if (!/<(span|div|p|a|img)\s/g.test(val)) { + val = val.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 || ''}</> + } } - } - - let _data = [data] - if (data.$$type === 'extendCard') { - _data = data.$$selectedData || [] - } else if (data.$$empty) { - _data = [] - } else if (card.$sync) { - _data = this.props.syncData - } + let className = '' + 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> + } + } + className = mark.signType + } - if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <NormalButton - BID={data.$$BID} - BData={data.$$BData || ''} - disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - columns={cards.columns} - selectedData={_data} - /> - </Col> + 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> + </div> + </div> ) - } else if (card.OpenType === 'excelIn') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <ExcelInButton - BID={data.$$BID} - BData={data.$$BData || ''} - disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - selectedData={_data} - /> - </Col> + } else if (card.eleType === 'color') { + let color = '' + + if (card.datatype === 'static') { + color = card.value + } else { + color = data[card.field] || '' + } + + if (color === '' && card.noValue === 'hide') { // 绌哄�奸殣钘� + return null + } + + let _bgstyle = {backgroundColor: color} + + if (PicRadio[card.lenWidRadio]) { + _bgstyle.paddingTop = PicRadio[card.lenWidRadio] + } else { + _bgstyle.paddingTop = '100%' + } + + if (card.copyable === 'true') { + _bgstyle.cursor = 'pointer' + } + + contents.push( + <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') { + e.stopPropagation() + + let oInput = document.createElement('input') + oInput.value = color + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + + message.success('澶嶅埗鎴愬姛銆�') + } + }}></div> + </div> + </div> ) - } else if (card.OpenType === 'excelOut') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <ExcelOutButton - BID={data.$$BID} - BData={data.$$BData || ''} - lineId={data.$$key || ''} - disabled={_disabled} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - /> - </Col> - ) - } else if (card.OpenType === 'popview') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <PopupButton - BID={data.$$BID} - BData={data.$$BData || ''} - disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - selectedData={_data} - /> - </Col> - ) - } else if (card.OpenType === 'tab') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <TabButton - BData={data.$$BData || ''} - disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - selectedData={_data} - /> - </Col> - ) - } else if (card.OpenType === 'innerpage') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <NewPageButton - BData={data.$$BData || ''} - disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} - setting={cards.setting} - selectedData={_data} - /> - </Col> - ) - } else if (card.OpenType === 'funcbutton') { - if (card.funcType === 'changeuser' || card.funcType === 'closetab') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <ChangeUserButton + } else if (card.eleType === 'button') { + let _disabled = data.$disabled + let _data = [data] + + if (data.$$type === 'extendCard') { + _data = data.$$selectedData || [] + } else if (card.$sync) { + _data = this.props.syncData || [] + } else if (data.$$empty) { + _data = [] + } + + _style_ = _style_ || {} + if (card.wrapStyle) { + _style_ = {..._style_, ...card.wrapStyle} + } + + if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) { + contents.push( + <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} BData={data.$$BData || ''} disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} setting={cards.setting} + columns={cards.columns} selectedData={_data} /> - </Col> + </div> ) - } else if (card.funcType === 'print') { - return ( - <Col key={card.uuid} className="mk-cell-btn" style={card.wrapStyle} span={card.width}> - <PrintButton + } else if (card.OpenType === 'excelIn') { + contents.push( + <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} BData={data.$$BData || ''} disabled={_disabled} - lineId={data.$$key || ''} - btn={card} - show={card.show} - style={card.style} setting={cards.setting} selectedData={_data} /> - </Col> + </div> ) + } else if (card.OpenType === 'excelOut') { + contents.push( + <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} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </div> + ) + } else if (card.OpenType === 'popview') { + contents.push( + <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} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </div> + ) + } else if (card.OpenType === 'tab') { + contents.push( + <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} + BData={data.$$BData || ''} + disabled={_disabled} + selectedData={_data} + /> + </div> + ) + } else if (card.OpenType === 'innerpage') { + contents.push( + <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} + /> + </div> + ) + } else if (card.OpenType === 'funcbutton') { + if (card.funcType === 'changeuser' || card.funcType === 'closetab') { + contents.push( + <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} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </div> + ) + } else if (card.funcType === 'print') { + contents.push( + <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} + BData={data.$$BData || ''} + disabled={_disabled} + setting={cards.setting} + columns={cards.columns} + selectedData={_data} + /> + </div> + ) + } else if (card.funcType === 'megvii') { + contents.push( + <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} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </div> + ) + } else if (card.funcType === 'filezip') { + contents.push( + <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} + disabled={_disabled} + setting={cards.setting} + selectedData={_data} + /> + </div> + ) + } } } - } + }) - return null + return contents } render() { - const { elements } = this.state - + const { cardCell } = this.props + return ( - <div className="card-cell-list"> - {elements.map(item => this.getContent(item))} + <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