From e9c48bd7356462ba9257540b130a47a65ad1861d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 八月 2021 17:17:11 +0800
Subject: [PATCH] 2021-08-26

---
 src/tabviews/custom/components/card/data-card/index.jsx |   66 +++++++++++++++++++++++---------
 1 files changed, 47 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 9272285..23383a8 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) { // 涓昏〃鎼滅储鏉′欢
@@ -382,10 +410,6 @@
     let _orderBy = config.setting.order || ''
     let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, menuType, id)
 
-    if (param.func === 'sPC_Get_TableData') {
-      param.menuname = config.name || ''
-    }
-
     let result = await Api.genericInterface(param)
     if (result.status) {
       let data = fromJS(this.state.data).toJS()
@@ -398,6 +422,7 @@
               _data.key = item.key
               _data.$$uuid = _data[config.setting.primaryKey] || ''
               _data.$$BID = BID || ''
+              item.$$BData = BData || ''
               _data.$Index = item.$Index
               return _data
             } else {
@@ -468,7 +493,7 @@
   }
   
   changeCard = (index, item) => {
-    const { config, selectKeys, selectedData, activeKey } = this.state
+    const { config, selectKeys, selectedData, activeKey, data } = this.state
 
     this.openView(item)
 
@@ -508,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) => {
@@ -540,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) => {

--
Gitblit v1.8.0