From 992f25d08ea2b5a6438ccc792a5c723b8a72f674 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 06 八月 2021 18:19:39 +0800
Subject: [PATCH] 2021-08-06

---
 src/tabviews/custom/components/card/balcony/index.jsx |   57 +++++++++++++++++++++++++++------------------------------
 1 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx
index 879d8f5..9ac4da5 100644
--- a/src/tabviews/custom/components/card/balcony/index.jsx
+++ b/src/tabviews/custom/components/card/balcony/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Spin, notification } from 'antd'
+import { Spin, notification, Checkbox } from 'antd'
 
 import Api from '@/api'
 // import Utils from '@/utils/utils.js'
@@ -15,7 +15,6 @@
 class BalconyComponent extends Component {
   static propTpyes = {
     BID: PropTypes.any,
-    menu: PropTypes.object,
     data: PropTypes.array,
     config: PropTypes.object,
     menuType: PropTypes.any,
@@ -28,11 +27,13 @@
     loading: false,
     sync: false,
     data: {},
-    show: true
+    syncData: [],
+    show: true,
+    checked: false
   }
 
   UNSAFE_componentWillMount () {
-    const { data, BID, menu } = this.props
+    const { data, BID } = this.props
     let _config = fromJS(this.props.config).toJS()
     let _cols = new Map()
 
@@ -75,32 +76,11 @@
     let show = true
     let syncConfig = null
     if (_config.wrap.linkType === 'sync') {
-      _config.wrap.syncModule = _config.wrap.syncModule.pop()
-      
-      let filterComponent = (components) => {
-        components.forEach(item => {
-          if (syncConfig) return
-          if (item.type === 'tabs') {
-            item.subtabs.forEach(tab => {
-              filterComponent(tab.components)
-            })
-          } else if (item.type === 'group') {
-            filterComponent(item.components)
-          } else if (_config.wrap.syncModule === item.uuid) {
-            syncConfig = {
-              uuid: item.uuid,
-              wrap: item.wrap,
-              setting: item.setting,
-              columns: item.columns
-            }
-          }
-        })
-      }
+      syncConfig = _config.syncConfig
 
-      filterComponent(menu.components)
       _config.elements = _config.elements.map(item => {
-        if (item.eleType === 'button') {
-          item.$syncModule = _config.wrap.syncModule
+        if (item.eleType === 'button' || item.eleType === 'formula') {
+          item.$sync = true
         }
         return item
       })
@@ -128,6 +108,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('reloadData', this.reloadData)
+    MKEmitter.addListener('syncBalconyData', this.syncBalconyData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
   }
@@ -141,6 +122,7 @@
       return
     }
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('syncBalconyData', this.syncBalconyData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
@@ -199,6 +181,14 @@
       supModule && MKEmitter.emit('reloadData', supModule, (BID || 'empty'))
       btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
     }
+  }
+
+  syncBalconyData = (menuId, data, checked) => {
+    const { syncConfig } = this.state
+
+    if (!syncConfig || syncConfig.uuid !== menuId) return
+
+    this.setState({syncData: data, checked})
   }
 
   resetParentParam = (MenuID, id) => {
@@ -281,8 +271,14 @@
     }
   }
 
+  checkAll = (e) => {
+    const { syncConfig } = this.state
+
+    MKEmitter.emit('mkCheckAll', syncConfig.uuid, e.target.checked)
+  }
+
   render() {
-    const { config, loading, data, show, syncConfig } = this.state
+    const { config, loading, data, show, syncConfig, syncData, checked } = this.state
 
     return (
       <div className={'custom-balcony-box' + (!show ? ' hidden' : '')} style={config.style}>
@@ -292,7 +288,8 @@
             <Spin />
           </div> : null
         }
-        <CardCellComponent data={data} cards={syncConfig || config} cardCell={config} elements={config.elements}/>
+        {config.wrap.checkAll === 'show' ? <div className="check-all"><Checkbox checked={checked} onChange={this.checkAll}>鍏ㄩ��</Checkbox></div> : null}
+        <CardCellComponent data={data} syncData={syncData || []} cards={syncConfig || config} cardCell={config} elements={config.elements}/>
       </div>
     )
   }

--
Gitblit v1.8.0