From 26d0fa42ea8c63a87e8ef93d0915f75f46fb1f9c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 24 三月 2022 11:09:53 +0800 Subject: [PATCH] 2022-03-24 --- src/tabviews/custom/components/share/normalTable/index.jsx | 136 +++++++++++++++++---------------------------- 1 files changed, 52 insertions(+), 84 deletions(-) diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index b27e7bb..fe54374 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -3,9 +3,11 @@ import md5 from 'md5' import { connect } from 'react-redux' import { is, fromJS } from 'immutable' -import { Table, Typography, Icon, Col, Switch, message } from 'antd' +import { Table, Typography, Col, Switch, message } from 'antd' import asyncComponent from '@/utils/asyncComponent' +import { getMark } from '@/utils/utils.js' +import MkIcon from '@/components/mk-icon' import MKEmitter from '@/utils/events.js' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' @@ -27,6 +29,10 @@ render() { let { lineMarks, onDoubleClick, data, className, ...resProps } = this.props let style = {} + + if (data && data.$disabled) { + className = className + ' mk-disabled ' + } if (lineMarks && lineMarks.length > 0) { lineMarks.some(mark => { @@ -78,7 +84,7 @@ if (mark.fontColor) { style.color = mark.fontColor } - className += className + ' background' + className = className + ' background' } else if (mark.signType[0] === 'underline') { style.textDecoration = 'underline' style.color = mark.color @@ -97,77 +103,6 @@ } class BodyCell extends React.Component { - getMark = (record, marks, style, content) => { - marks.some(mark => { - let originVal = record[mark.field[0]] + '' - let contrastVal = '' - let result = false - - if (mark.field[1] === 'static') { - contrastVal = mark.contrastValue + '' - } else { - contrastVal = record[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) { - 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 - } - shouldComponentUpdate (nextProps, nextState) { return !nextProps.record || !is(fromJS(this.props.record), fromJS(nextProps.record)) } @@ -194,8 +129,17 @@ } if (col.marks) { - style = style || {} - content = this.getMark(record, col.marks, style, content) + let mark = getMark(col.marks, record, style) + + style = mark.style + + if (mark.icon) { + if (mark.position === 'front') { + content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + } else { + content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + } + } } if (col.blur) { content = md5(content) @@ -205,7 +149,7 @@ resProps.rowSpan = record['$$' + col.field] } - if (col.linkThdMenu || col.linkurl) { + if (!record.$disabled && (col.linkThdMenu || col.linkurl)) { content = ( <div> <div className="link-menu" onDoubleClick={(e) => triggerLink(e, col, record)}></div> @@ -231,6 +175,8 @@ if (col.format === 'percent') { content = content * 100 decimal = decimal > 2 ? decimal - 2 : 0 + } else if (col.format === 'abs') { + content = Math.abs(content) } content = content.toFixed(decimal) @@ -243,8 +189,17 @@ } if (col.marks) { - style = style || {} - content = this.getMark(record, col.marks, style, content) + let mark = getMark(col.marks, record, style) + + style = mark.style + + if (mark.icon) { + if (mark.position === 'front') { + content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + } else { + content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + } + } } if (col.blur) { @@ -255,7 +210,7 @@ resProps.rowSpan = record['$$' + col.field] } - if (col.linkThdMenu || col.linkurl) { + if (!record.$disabled && (col.linkThdMenu || col.linkurl)) { content = ( <div> <div className="link-menu" onDoubleClick={(e) => triggerLink(e, col, record)}></div> @@ -383,8 +338,17 @@ } if (col.marks) { - style = style || {} - content = this.getMark(record, col.marks, style, content) + let mark = getMark(col.marks, record, style) + + style = mark.style + + if (mark.icon) { + if (mark.position === 'front') { + content = <span><MkIcon style={{color: mark.color}} type={mark.icon} /> {content}</span> + } else { + content = <span>{content} <MkIcon style={{color: mark.color}} type={mark.icon} /></span> + } + } } resProps.children = content @@ -418,7 +382,6 @@ lineMarks: PropTypes.array, // 琛屾爣璁� fields: PropTypes.array, // 缁勪欢瀛楁闆� ContainerId: PropTypes.any, // 鏍囩椤靛灞侷d - BData: PropTypes.any, // 涓昏〃鏁版嵁 data: PropTypes.any, // 琛ㄦ牸鏁版嵁 total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� @@ -568,6 +531,7 @@ const { MenuID, data, setting } = this.props if (MenuID !== menuId || !data || data.length === 0) return + if (data[0].$disabled) return this.changedata(0) this.setState({ selectedRowKeys: [0], activeIndex: 0 }) @@ -691,7 +655,7 @@ this.setState({ selectedRowKeys, activeIndex: _activeIndex }) - let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index)) + let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index) && !item.$disabled) this.props.chgSelectData(selects) if (setting.$hasSyncModule) { @@ -706,6 +670,7 @@ const { setting, MenuID, data } = this.props if (!setting.tableType || this.state.pickup) return + if (record.$disabled) return let newkeys = fromJS(this.state.selectedRowKeys).toJS() @@ -730,7 +695,7 @@ this.setState({ selectedRowKeys: newkeys, activeIndex: _index !== '' ? _index : null }) } - let selects = this.props.data.filter((item, _index) => newkeys.includes(_index)) + let selects = this.props.data.filter((item, _index) => newkeys.includes(_index) && !item.$disabled) this.props.chgSelectData(selects) @@ -765,6 +730,8 @@ _id = data[index][setting.primaryKey] || '' _data = data[index] || '' } + + if (_data && _data.$disabled) return MKEmitter.emit('resetSelectLine', MenuID, _id, _data) } @@ -854,6 +821,7 @@ const { setting } = this.props if (!setting.doubleClick) return + if (record.$disabled) return MKEmitter.emit('triggerBtnId', setting.doubleClick, [record]) } -- Gitblit v1.8.0