From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/tabviews/custom/components/card/table-card/index.jsx |   68 ++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx
index d852e7e..845703f 100644
--- a/src/tabviews/custom/components/card/table-card/index.jsx
+++ b/src/tabviews/custom/components/card/table-card/index.jsx
@@ -8,7 +8,6 @@
 import Utils from '@/utils/utils.js'
 import asyncComponent from '@/utils/asyncComponent'
 import UtilsDM from '@/utils/utils-datamanage.js'
-import { modifyTabview } from '@/store/action'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
@@ -33,7 +32,7 @@
     total: 0,                  // 鎬绘暟
     sync: false,               // 鏄惁缁熶竴璇锋眰鏁版嵁
     data: null,                // 鏁版嵁
-    BData: null
+    BData: ''
   }
 
   /**
@@ -41,7 +40,7 @@
    * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦
    */
   UNSAFE_componentWillMount () {
-    const { data, initdata, BID } = this.props
+    const { data, initdata, BID, BData } = this.props
     let _config = fromJS(this.props.config).toJS()
     let _cols = new Map()
 
@@ -61,6 +60,7 @@
         item.key = index
         item.$$uuid = item[_config.setting.primaryKey] || ''
         item.$$BID = BID || ''
+        item.$$BData = BData || ''
         item.$Index = index + 1 + ''
         return item
       })
@@ -78,13 +78,14 @@
     }
 
     _config.columns.forEach(item => {
+      if (item.type !== 'number') return
       _cols.set(item.field, item)
     })
 
     _config.subcards.forEach(card => {
       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
       })
@@ -93,13 +94,16 @@
     this.setState({
       sync: _sync,
       BID: BID || '',
+      BData: BData || '',
       data: _data,
       config: _config,
       search: Utils.initMainSearch(_config.search),
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
       if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        this.loadData()
+        setTimeout(() => {
+          this.loadData()
+        }, _config.setting.delay || 0)
       }
     })
   }
@@ -129,7 +133,7 @@
    * @description 鍥捐〃鏁版嵁鏇存柊锛屽埛鏂板唴瀹�
    */
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { sync, config, BID } = this.state
+    const { sync, config, BID, BData } = this.state
 
     if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
       let _data = []
@@ -141,6 +145,7 @@
         item.key = index
         item.$$uuid = item[config.setting.primaryKey] || ''
         item.$$BID = BID || ''
+        item.$$BData = BData || ''
         item.$Index = index + 1 + ''
         return item
       })
@@ -164,16 +169,23 @@
 
     if (config.uuid !== menuId) return
 
-    this.loadData(btn)                                                         // 鏁版嵁鍒锋柊
+    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)
     }
   }
@@ -182,7 +194,7 @@
     const { config } = this.state
 
     if (!config.setting.supModule || config.setting.supModule !== MenuID) return
-    if (id !== this.state.BID) {
+    if (id !== this.state.BID || id !== '') {
       this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
         this.loadData()
       })
@@ -324,7 +336,6 @@
 
       let newtab = {
         ...menu,
-        selected: true,
         param: {}
       }
 
@@ -333,21 +344,9 @@
       }
 
       if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
-        this.props.modifyTabview([newtab])
+        MKEmitter.emit('modifyTabs', newtab, 'replace')
       } else {
-        let tabs = this.props.tabviews.filter((tab, i) => {
-          tab.selected = false
-          return tab.MenuID !== newtab.MenuID
-        })
-
-        if (this.props.tabviews.length > tabs.length) {
-          this.props.modifyTabview(fromJS(tabs).toJS())
-        }
-
-        this.setState({}, () => {
-          tabs.push(newtab)
-          this.props.modifyTabview(tabs)
-        })
+        MKEmitter.emit('modifyTabs', newtab, 'plus', true)
       }
     } else if (card.setting.click === 'link') {
       let src = card.setting.linkurl
@@ -420,6 +419,8 @@
   render() {
     const { config, loading, data, BID, pageIndex, total } = this.state
 
+    if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null
+    
     return (
       <div className="custom-table-card-box" style={{...config.style}}>
         {loading ?
@@ -444,14 +445,11 @@
 const mapStateToProps = (state) => {
   return {
     permMenus: state.permMenus,
-    tabviews: state.tabviews,
   }
 }
 
-const mapDispatchToProps = (dispatch) => {
-  return {
-    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
-  }
+const mapDispatchToProps = () => {
+  return {}
 }
 
 export default connect(mapStateToProps, mapDispatchToProps)(TableCard)
\ No newline at end of file

--
Gitblit v1.8.0