| | |
| | | } |
| | | } |
| | | |
| | | if (result) { |
| | | if (result && mark.signType) { |
| | | if (mark.signType[0] === 'font') { |
| | | style.color = mark.color |
| | | } else if (mark.signType[0] === 'background') { |
| | |
| | | }) |
| | | |
| | | 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) => { |
| | |
| | | ) |
| | | } else if (card.eleType === 'slider') { |
| | | let val = 0 |
| | | let color = card.color |
| | | |
| | | if (card.datatype === 'static') { |
| | | val = card.value |
| | |
| | | _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> |