From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 九月 2021 10:31:45 +0800
Subject: [PATCH] 2021-09-01

---
 src/tabviews/custom/components/card/data-card/index.jsx |   70 +++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx
index 3a65f13..5ec9396 100644
--- a/src/tabviews/custom/components/card/data-card/index.jsx
+++ b/src/tabviews/custom/components/card/data-card/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { connect } from 'react-redux'
-import { Spin, Empty, notification, Row, Col, Pagination } from 'antd'
+import { Spin, Empty, notification, message, Row, Col, Pagination } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -146,7 +146,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('reloadData', this.reloadData)
-    MKEmitter.addListener('getSyncData', this.getSyncData)
+    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -186,18 +186,10 @@
       return
     }
     MKEmitter.removeListener('reloadData', this.reloadData)
-    MKEmitter.removeListener('getSyncData', this.getSyncData)
+    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
-  }
-
-  getSyncData = (syncModule, btnId) => {
-    const { config, selectedData } = this.state
-
-    if (config.uuid !== syncModule) return
-
-    MKEmitter.emit('triggerBtnId', btnId, (selectedData || []))
   }
 
   /**
@@ -230,6 +222,35 @@
     } else if (position === 'popclose') {                                      // 鏍囩鍏抽棴鍒锋柊
       config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
       btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
+    }
+  }
+
+  mkCheckAll = (menuId, checked) => {
+    const { config, data } = this.state
+
+    if (config.uuid !== menuId) return
+
+    if (checked) {
+      this.setState({
+        activeKey: '',
+        selectKeys: data.map((item, index) => index),
+        selectedData: data
+      })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      MKEmitter.emit('syncBalconyData', config.uuid, data, data.length > 0)
+      if (data.length === 0) {
+        message.warning('鏈幏鍙栧埌鏁版嵁锛�')
+      }
+    } else {
+      this.setState({
+        activeKey: '',
+        selectKeys: [],
+        selectedData: []
+      })
+  
+      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      MKEmitter.emit('syncBalconyData', config.uuid, [], false)
     }
   }
 
@@ -286,7 +307,7 @@
 
   async loadData () {
     const { mainSearch, menuType } = this.props
-    const { config, arr_field, pageIndex, search, BID } = this.state
+    const { config, arr_field, pageIndex, search, BID, BData } = this.state
 
     if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
@@ -299,6 +320,9 @@
         loading: false
       })
       MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
       return
     }
 
@@ -339,6 +363,7 @@
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
           item.$$BID = BID || ''
+          item.$$BData = BData || ''
           item.$Index = index + start + ''
           return item
         }),
@@ -346,6 +371,9 @@
         loading: false
       })
       MKEmitter.emit('resetSelectLine', config.uuid, '', '')
+      if (config.setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
     } else {
       this.setState({
         loading: false
@@ -363,7 +391,7 @@
    */ 
   async loadLinedata (id) {
     const { mainSearch, menuType } = this.props
-    const { config, arr_field, pageIndex, search, BID } = this.state
+    const { config, arr_field, pageIndex, search, BID, BData } = this.state
 
     let searches = fromJS(search).toJS()
     if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
@@ -394,13 +422,14 @@
               _data.key = item.key
               _data.$$uuid = _data[config.setting.primaryKey] || ''
               _data.$$BID = BID || ''
+              item.$$BData = BData || ''
               _data.$Index = item.$Index
               return _data
             } else {
               return item
             }
           })
-        } catch {
+        } catch (e) {
           console.warn('鏁版嵁鏌ヨ閿欒')
         }
       }
@@ -464,7 +493,7 @@
   }
   
   changeCard = (index, item) => {
-    const { config, selectKeys, selectedData, activeKey } = this.state
+    const { config, selectKeys, selectedData, activeKey, data } = this.state
 
     this.openView(item)
 
@@ -504,6 +533,9 @@
     })
 
     MKEmitter.emit('resetSelectLine', config.uuid, (_item ? _item.$$uuid : ''), _item)
+    if (config.setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', config.uuid, _selectedData, data.length === _selectedData.length)
+    }
   }
 
   openView = (item) => {
@@ -536,7 +568,7 @@
         newtab.param.$BID = item.$$uuid
       }
 
-      if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) {
+      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
         this.props.modifyTabview([newtab])
       } else {
         let tabs = this.props.tabviews.filter((tab, i) => {
@@ -566,7 +598,7 @@
           _param.User_Name = sessionStorage.getItem('User_Name')
           _param.param = { BID: item.$$uuid }
           src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-        } catch {
+        } catch (e) {
           console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
         }
       } else if (card.setting.joint === 'true') {
@@ -628,7 +660,7 @@
           <Row className="card-row-list">
             {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null}
             {precards.map((item, index) => (
-              <Col key={'pre' + index} className={item.setting.$click} span={item.setting.width || 6}>
+              <Col key={'pre' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                 <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
               </Col>
             ))}
@@ -638,7 +670,7 @@
               </Col>
             ))}
             {nextcards.map((item, index) => (
-              <Col key={'next' + index} className={item.setting.$click} span={item.setting.width || 6}>
+              <Col key={'next' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                 <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
               </Col>
             ))}

--
Gitblit v1.8.0