From 0a98c5dab4f2783ff5250cb69715340b40d801bb Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 05 四月 2023 18:23:08 +0800
Subject: [PATCH] 2023-04-05

---
 src/tabviews/custom/components/card/cardcellList/index.jsx |  147 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 116 insertions(+), 31 deletions(-)

diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx
index 4be6caa..979f07b 100644
--- a/src/tabviews/custom/components/card/cardcellList/index.jsx
+++ b/src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Col, Tooltip, notification, Typography } from 'antd'
+import { Col, Tooltip, notification, Typography, message } from 'antd'
 import moment from 'moment'
 
 // import Api from '@/api'
@@ -237,6 +237,7 @@
 
       if (card.eleType === 'sequence') {
         let _style = {}
+        let className = ''
         if (card.marks) {
           _style.width = card.innerHeight
           _style.height = card.innerHeight
@@ -245,11 +246,12 @@
           let mark = getMark(card.marks, data, _style)
   
           _style = mark.style
+          className = mark.signType
         }
         contents.push(
           <Col key={card.uuid} style={_style_} span={card.width}>
             <div style={card.style}>
-              <div className="ant-mk-text line1" style={{height: card.innerHeight || 'auto'}}><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div>
+              <div className={'ant-mk-text line1' + className} style={{height: card.innerHeight || 'auto'}}><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div>
             </div>
           </Col>
         )
@@ -265,6 +267,19 @@
             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]
@@ -362,6 +377,7 @@
           }
         }
   
+        let className = ''
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
@@ -374,6 +390,7 @@
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
             }
           }
+          className = mark.signType
         }
   
         if (card.link || (card.anchors && card.anchors.length > 0)) {
@@ -383,11 +400,18 @@
         if (card.bgImage && data[card.bgImage]) {
           _style.backgroundImage = `url('${data[card.bgImage]}')`
         }
+
+        let lineStyle = {height: card.innerHeight || 'auto'}
+        if (card.alignItems) {
+          lineStyle.display = 'flex'
+          lineStyle.alignItems = card.alignItems
+          lineStyle.justifyContent = _style.textAlign || 'left'
+        }
   
         contents.push(
           <Col 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 || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
+              <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div>
             </div>
           </Col>
         )
@@ -405,7 +429,8 @@
           return null
         }
   
-        if (typeof(val) === 'number') {
+        if (!isNaN(val) && val !== '') {
+          val = +val
           if (card.round) {
             val = Math.round(val * card.round) / card.round
           }
@@ -437,6 +462,7 @@
           }
         }
         
+        let className = ''
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
@@ -449,12 +475,20 @@
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
             }
           }
+          className = mark.signType
+        }
+
+        let lineStyle = {height: card.innerHeight || 'auto'}
+        if (card.alignItems) {
+          lineStyle.display = 'flex'
+          lineStyle.alignItems = card.alignItems
+          lineStyle.justifyContent = _style.textAlign || 'left'
         }
   
         contents.push(
           <Col key={card.uuid} style={_style_} span={card.width}>
             <div style={_style}>
-              <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
+              <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div>
             </div>
           </Col>
         )
@@ -467,6 +501,10 @@
           icon = data[card.field] || ''
         } else {
           icon = card.icon
+        }
+
+        if (!icon && card.noValue === 'hide') { // 绌哄�奸殣钘�
+          return null
         }
 
         if (!height) { // 鍏煎
@@ -552,10 +590,6 @@
         if (url === '' && card.noValue === 'hide') { // 绌哄�奸殣钘�
           return null
         }
-
-        if (_style.borderRadius) {
-          _imagestyle.borderRadius = _style.borderRadius
-        }
   
         if (PicRadio[card.lenWidRadio]) {
           _imagestyle.paddingTop = PicRadio[card.lenWidRadio]
@@ -563,7 +597,10 @@
           _imagestyle.paddingTop = '100%'
         }
 
-        _imagestyle.backgroundSize = card.backgroundSize || 'cover'
+        _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'
@@ -686,7 +723,7 @@
       } else if (card.eleType === 'formula') {
         let val = 0
         let _style = card.style ? {...card.style} : {}
-  
+
         if (card.$sync) {
           if (card.eval === 'false') {
             val = ''
@@ -716,7 +753,7 @@
             let reg = new RegExp('@' + key + '@', 'ig')
             _val = _val.replace(reg, data[key])
           })
-  
+
           if (card.eval !== 'false') {
             try {
               // eslint-disable-next-line
@@ -728,14 +765,18 @@
   
           val = _val === undefined ? '' : _val
         }
-  
+
         if (val === '' && card.noValue === 'hide') { // 绌哄�奸殣钘�
           return null
         }
   
         if (val !== '') {
           if (val && typeof(val) === 'string') {
-            val = val.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
+            val = val.replace(/\n/ig, '<br/>')
+            if (!/<(span|div|p|a|img)\s/g.test(val)) {
+              val = val.replace(/\s/ig, '&nbsp;')
+            }
+
             val = <span dangerouslySetInnerHTML={{__html: val}}></span>
           }
   
@@ -743,10 +784,11 @@
             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 || ''}`
+            val = <>{card.prefix || ''}{val}{card.postfix || ''}</>
           }
         }
-  
+
+        let className = ''
         if (card.marks) {
           let mark = getMark(card.marks, data, _style)
   
@@ -759,35 +801,76 @@
               val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
             }
           }
+          className = mark.signType
+        }
+
+        let lineStyle = {height: card.innerHeight || 'auto'}
+        if (card.alignItems) {
+          lineStyle.display = 'flex'
+          lineStyle.alignItems = card.alignItems
+          lineStyle.justifyContent = _style.textAlign || 'left'
         }
   
         contents.push(
           <Col key={card.uuid} style={_style_} span={card.width}>
             <div style={_style}>
-              <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
+              <div className={'ant-mk-text line' + (card.height || '') + className} style={lineStyle}>{val}</div>
+            </div>
+          </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(
+          <Col 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>
           </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))) {
-            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
-          }
-        }
-        
         let _data = [data]
   
         if (data.$$type === 'extendCard') {
           _data = data.$$selectedData || []
         } else if (card.$sync) {
-          _data = this.props.syncData
+          _data = this.props.syncData || []
         } else if (data.$$empty) {
           _data = []
         }
@@ -934,8 +1017,10 @@
   }
 
   render() {
+    const { cardCell } = this.props
+    
     return (
-      <div className="card-cell-list">
+      <div className={'card-cell-list ' + (cardCell && cardCell.setting.layout === 'flex' ? 'mk-flex' : '')}>
         {this.getContent()}
       </div>
     )

--
Gitblit v1.8.0