From 6afdec0062dacbded57e166230eb22cc55ced0c1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 08 五月 2021 14:30:21 +0800 Subject: [PATCH] 2021-05-08 --- src/tabviews/custom/components/card/cardcellList/index.jsx | 292 +++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 178 insertions(+), 114 deletions(-) diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 9f8f546..01b98b4 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -4,8 +4,6 @@ import { Icon, Col, Tooltip, notification } from 'antd' import moment from 'moment' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import asyncComponent from './asyncButtonComponent' import asyncElementComponent from '@/utils/asyncComponent' @@ -22,19 +20,22 @@ const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton')) const BarCode = asyncElementComponent(() => import('@/components/barcode')) const QrCode = asyncElementComponent(() => import('@/components/qrcode')) +const Video = asyncComponent(() => import('@/components/video')) +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%', + '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%' +} class CardCellComponent extends Component { static propTpyes = { - seq: PropTypes.any, // 搴忓彿 cards: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 cardCell: PropTypes.object, data: PropTypes.object, elements: PropTypes.array, // 鍏冪礌闆� - updateStatus: PropTypes.func, // 鐘舵�佹洿鏂� } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, // 缂栬緫涓厓绱� elements: null, // 鎸夐挳缁� } @@ -179,7 +180,7 @@ } } - if (result) { + if (result && mark.signType) { if (mark.signType[0] === 'font') { style.color = mark.color } else if (mark.signType[0] === 'background') { @@ -208,14 +209,68 @@ return content } + getColor = (marks) => { + const { data } = this.props + let color = '' + + 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 { + originVal = NaN + } + + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { + result = true + } + } else if (mark.match === '<') { + try { + originVal = parseFloat(originVal) + contrastVal = parseFloat(contrastVal) + } catch { + originVal = NaN + } + + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { + result = true + } + } + + if (result) { + color = mark.color + } + return result + }) + + return color + } + getContent = (card) => { - const { data, cards, seq } = this.props + const { data, cards } = this.props if (card.eleType === 'sequence') { return ( <Col key={card.uuid} span={card.width}> <div style={card.style}> - <div className={'ant-mk-text'}>{seq}</div> + <div className={'ant-mk-text'}>{data.$Index || ''}</div> </div> </Col> ) @@ -224,7 +279,13 @@ let _style = card.style ? {...card.style} : {} if (card.datatype === 'static') { - val = card.value + 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) + } } else if (data.hasOwnProperty(card.field)) { val = data[card.field] } @@ -250,7 +311,7 @@ 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 || 21}}>{val}</div> + <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> </div> </Col> ) @@ -302,7 +363,7 @@ return ( <Col key={card.uuid} span={card.width}> <div style={_style}> - <div className={'ant-mk-text line' + card.height} style={{height: card.innerHeight || 21}}>{val}</div> + <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div> </div> </Col> ) @@ -326,6 +387,7 @@ ) } else if (card.eleType === 'slider') { let val = 0 + let color = card.color if (card.datatype === 'static') { val = card.value @@ -346,14 +408,19 @@ _val = `${val}%` } + 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}> <div className="ant-mk-slider"> <div className="ant-mk-slider-rail"></div> - <div className="ant-mk-slider-track" style={{width: _val, backgroundColor: card.color}}></div> + <div className="ant-mk-slider-track" style={{width: _val, backgroundColor: color}}></div> <Tooltip title={`${val}%`}> - <div className="ant-mk-slider-handle" style={{left: _val, borderColor: card.color}}></div> + <div className="ant-mk-slider-handle" style={{left: _val, borderColor: color}}></div> </Tooltip> </div> </div> @@ -380,12 +447,8 @@ _imagestyle.borderRadius = _style.borderRadius } - if (card.lenWidRadio === '16:9') { - _imagestyle.paddingTop = '56.25%' - } else if (card.lenWidRadio === '3:2') { - _imagestyle.paddingTop = '66.67%' - } else if (card.lenWidRadio === '4:3') { - _imagestyle.paddingTop = '75%' + if (PicRadio[card.lenWidRadio]) { + _imagestyle.paddingTop = PicRadio[card.lenWidRadio] } else { _imagestyle.paddingTop = '100%' } @@ -428,6 +491,22 @@ </div> </Col> ) + } else if (card.eleType === 'video') { + let url = '' + + if (card.datatype === 'static') { + url = card.url + } else { + url = data[card.field] || '' + } + + 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 = '' @@ -455,137 +534,122 @@ </Col> ) } else if (card.eleType === 'button') { + if (card.$type === 'tableButton' && card.controlField) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + if (data[card.controlField] === card.controlVal) { + return null + } else if (card.controlVal && card.controlVal.split(',').includes(data[card.controlField])) { + return null + } + } + if (['exec', 'prompt', 'pop'].includes(card.OpenType)) { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <NormalButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - columns={cards.columns} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <NormalButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + columns={cards.columns} + selectedData={[data]} + /> </Col> ) } else if (card.OpenType === 'excelIn') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <ExcelInButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <ExcelInButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } else if (card.OpenType === 'excelOut') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <ExcelOutButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - // getexceloutparam={getexceloutparam} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <ExcelOutButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + /> </Col> ) } else if (card.OpenType === 'popview') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <PopupButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <PopupButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } else if (card.OpenType === 'tab') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <TabButton - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <TabButton + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } else if (card.OpenType === 'innerpage') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <NewPageButton - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <NewPageButton + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } else if (card.OpenType === 'funcbutton') { if (card.funcType === 'changeuser') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <ChangeUserButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <ChangeUserButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } else if (card.funcType === 'print') { return ( - <Col key={card.uuid} span={card.width}> - <div style={card.style}> - <PrintButton - BID={data.$$BID} - btn={card} - show={card.show} - style={card.btnstyle} - setting={cards.setting} - selectedData={[data]} - updateStatus={this.props.updateStatus} - /> - </div> + <Col key={card.uuid} className="mk-cell-btn" span={card.width}> + <PrintButton + BID={data.$$BID} + btn={card} + show={card.show} + style={card.style} + setting={cards.setting} + selectedData={[data]} + /> </Col> ) } } } + + return null } render() { -- Gitblit v1.8.0