From bd1dfc9e6c9b9f8076ca2783ce598e0936b4c664 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 十二月 2021 14:36:03 +0800
Subject: [PATCH] 2021-12-22

---
 src/tabviews/custom/components/card/cardcellList/index.jsx |  123 ++++++++++++++---------------------------
 1 files changed, 42 insertions(+), 81 deletions(-)

diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx
index c563e29..747bad8 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -1,12 +1,13 @@
 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 } from 'antd'
 import moment from 'moment'
 
 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'
@@ -152,79 +153,6 @@
     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) => {
     const { data } = this.props
     let color = ''
@@ -270,7 +198,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}>
@@ -363,7 +294,17 @@
       }
 
       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={{color: mark.color}} type={mark.icon} /> {val}</span>
+          } else {
+            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
+          }
+        }
       }
 
       if (card.link) {
@@ -419,7 +360,17 @@
       }
       
       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={{color: mark.color}} type={mark.icon} /> {val}</span>
+          } else {
+            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
+          }
+        }
       }
 
       return (
@@ -442,8 +393,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 type={card.icon}/>
+            </Tooltip> : <MkIcon type={card.icon}/>}
           </div>
         </Col>
       )
@@ -676,7 +627,17 @@
       }
 
       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={{color: mark.color}} type={mark.icon} /> {val}</span>
+          } else {
+            val = <span>{val} <MkIcon style={{color: mark.color}} type={mark.icon} /></span>
+          }
+        }
       }
 
       return (

--
Gitblit v1.8.0