From 25fbc16aa14667064ac5de854183b09e01105f2c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 30 三月 2022 15:44:05 +0800
Subject: [PATCH] 2022-03-30

---
 src/tabviews/custom/components/card/prop-card/index.jsx |   76 +++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx
index a347b8e..5a8912e 100644
--- a/src/tabviews/custom/components/card/prop-card/index.jsx
+++ b/src/tabviews/custom/components/card/prop-card/index.jsx
@@ -43,33 +43,32 @@
     let _data = { $$empty: true }
     let _sync = false
     
-    if (_config.setting && _config.wrap.datatype !== 'static') {
+    if (_config.wrap.datatype !== 'static') {
       _sync = _config.setting.sync === 'true'
 
       if (_sync && data) {
-        _data = data[_config.dataName] || {}
-        if (_data && Array.isArray(_data)) {
-          _data = _data[0] || {}
+        _data = data[_config.dataName] || {$$empty: true}
+        if (Array.isArray(_data)) {
+          _data = _data[0] || {$$empty: true}
         }
         _sync = false
       } else if (_sync && initdata) {
-        _data = initdata || {}
-        if (_data && Array.isArray(_data)) {
-          _data = _data[0] || {}
+        _data = initdata || {$$empty: true}
+        if (Array.isArray(_data)) {
+          _data = _data[0] || {$$empty: true}
         }
         _sync = false
       }
     }
 
-    if (_data) {
-      _data.$$BID = BID || ''
-      _data.$$BData = BData || ''
-      if (_config.setting && _config.setting.primaryKey) {
-        _data.$$uuid = _data[_config.setting.primaryKey] || ''
-      }
+    _data.$$BID = BID || ''
+    _data.$$BData = BData || ''
+    if (_config.setting.primaryKey) {
+      _data.$$uuid = _data[_config.setting.primaryKey] || ''
     }
 
     _config.columns.forEach(item => {
+      if (item.type !== 'number') return
       _cols.set(item.field, item)
     })
 
@@ -87,21 +86,21 @@
       }
       _width += card.setting.width
       card.elements = card.elements.map(item => {
-        if (item.field && _cols.has(item.field)) {
-          item.col = _cols.get(item.field)
+        if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
+          item.decimal = _cols.get(item.field).decimal || 0
         }
         return item
       })
       card.backElements = card.backElements.map(item => {
-        if (item.field && _cols.has(item.field)) {
-          item.col = _cols.get(item.field)
+        if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
+          item.decimal = _cols.get(item.field).decimal || 0
         }
         return item
       })
     })
 
     let offset = 0
-    if (_config.wrap.cardFloat && _config.wrap.cardFloat !== 'left' && _config.subcards[0] && _width < 24) {
+    if (_config.wrap.cardFloat && _config.wrap.cardFloat !== 'left' && _width < 24) {
       offset = 24 - _width
       if (_config.wrap.cardFloat === 'center') {
         offset = Math.floor(offset / 2)
@@ -114,6 +113,7 @@
     _config.wrap.selStyle = _config.wrap.selStyle || 'active'
     _config.wrap.priKeyType = _config.wrap.priKeyType || 'static'
     _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : ''
+    _config.wrap.layout = (_config.wrap.layout || 'grid') + '-layout'
 
     _config.wrap.wrapClass =  `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale || ''}`
 
@@ -126,8 +126,10 @@
       config: _config,
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
-      if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        this.loadData()
+      if (_config.wrap.datatype !== 'static' && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
+        setTimeout(() => {
+          this.loadData()
+        }, _config.setting.delay || 0)
       } else if ((!_sync || _config.wrap.priKeyType === 'static') && selected !== 'false') {
         setTimeout(() => {
           this.checkTopLine()
@@ -166,9 +168,9 @@
     if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
       let _data = { $$empty: true }
       if (nextProps.data && nextProps.data[config.dataName]) {
-        _data = nextProps.data[config.dataName] || {}
+        _data = nextProps.data[config.dataName]
         if (Array.isArray(_data)) {
-          _data = _data[0] || {}
+          _data = _data[0] || {$$empty: true}
         }
       }
 
@@ -192,8 +194,6 @@
 
   checkTopLine = () => {
     const { config, data, selected } = this.state
-
-    if (!config.subcards[0]) return
 
     this.setState({
       activeKey: 0,
@@ -271,16 +271,23 @@
 
     if (config.uuid !== menuId) return
 
-    this.loadData()                                                            // 鏁版嵁鍒锋柊
+    let supModule = config.setting.supModule
 
-    if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
-      MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
+    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
+
+    if (!btn.syncComponentId || btn.syncComponentId !== supModule) {
+      if (position === 'mainline' || position === 'popclose') { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
+        if (supModule && BID) {
+          MKEmitter.emit('reloadData', supModule, BID)
+        } else {
+          this.loadData()
+        }
+      } else {
+        this.loadData()
+      }
     }
 
-    if (position === 'mainline' && config.setting.supModule) {                 // 涓昏〃琛屽埛鏂�
-      MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
-    } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
-      config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
+    if (position === 'popclose') { // 鎵ц鍚姩寮圭獥鐨勬寜閽墍閫夋嫨鐨勫埛鏂伴」
       btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
     }
   }
@@ -288,7 +295,8 @@
   resetParentParam = (MenuID, id, data) => {
     const { config } = this.state
 
-    if (!config.setting || !config.setting.supModule || config.setting.supModule !== MenuID) return
+    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
+    
     if (id !== this.state.BID || id !== '') {
       this.setState({ BID: id, BData: data }, () => {
         this.loadData()
@@ -400,6 +408,8 @@
   render() {
     const { config, loading, data, activeKey } = this.state
 
+    if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null
+
     return (
       <div className="custom-prop-card-box" style={config.style}>
         {loading ?
@@ -409,7 +419,7 @@
           </div> : null
         }
         <NormalHeader config={config}/>
-        <Row className={`card-row-list data-zoom ${config.wrap.wrapClass}`}>
+        <Row className={`card-row-list data-zoom ${config.wrap.wrapClass} ${config.wrap.layout}`}>
           {config.subcards.map((item, index) => {
             let className = item.setting.click ? 'mk-card pointer ' : 'mk-card '
             if (activeKey === index) {

--
Gitblit v1.8.0