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/index.jsx |   71 +++++++++++++++++++++++++++++++----
 1 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 22c148f..985546b 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -130,7 +130,8 @@
 
       // 鏉冮檺杩囨护
       let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
-      config.components = this.filterComponent(config.components, roleId, permAction, permMenus)
+      let balMap = new Map()
+      config.components = this.filterComponent(config.components, roleId, permAction, permMenus, balMap)
       
       // 鑾峰彇涓绘悳绱㈡潯浠�
       let mainSearch = []
@@ -190,7 +191,11 @@
         })
       }
 
-      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs)
+      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap)
+
+      if ([...balMap.keys()].length > 0) {
+        config.components = this.filterBalcony(config.components, balMap)
+      }
 
       this.setState({
         BID: BID,
@@ -439,7 +444,7 @@
     })
   }
 
-  filterComponent = (components, roleId, permAction, permMenus) => {
+  filterComponent = (components, roleId, permAction, permMenus, balMap) => {
     return components.filter(item => {
       
       if (item.style && item.style.boxShadow) {
@@ -470,7 +475,7 @@
         })
 
         item.subtabs = item.subtabs.map(tab => {
-          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus)
+          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus, balMap)
           return tab
         })
 
@@ -493,7 +498,7 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, permAction, permMenus)
+        item.components = this.filterComponent(item.components, roleId, permAction, permMenus, balMap)
       } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) {
         if (
           item.plot.blacklist && item.plot.blacklist.length > 0 &&
@@ -638,6 +643,10 @@
           })
         })
       } else if (item.type === 'balcony') {
+        if (item.wrap.linkType === 'sync') {
+          item.wrap.syncModuleId = item.wrap.syncModule.pop()
+          balMap.set(item.wrap.syncModuleId, true)
+        }
         item.elements = item.elements.filter(cell => {
           if (cell.eleType === 'button') {
             cell.logLabel = item.$menuname + '-' + cell.label
@@ -729,6 +738,45 @@
     })
   }
 
+
+  filterBalcony = (components, balMap) => {
+    return components.filter(item => {
+      if (item.type === 'tabs') {
+        item.subtabs = item.subtabs.map(tab => {
+          tab.components = this.filterBalcony(tab.components, balMap)
+          return tab
+        })
+      } else if (item.type === 'group') {
+        item.components = this.filterBalcony(item.components, balMap)
+      }
+
+      if (item.type === 'balcony' && item.wrap.linkType === 'sync') {
+        let conf = balMap.get(item.wrap.syncModuleId)
+
+        if (!conf || conf === true) {
+          return false
+        }
+        
+        item.syncConfig = {
+          uuid: conf.uuid,
+          wrap: conf.wrap,
+          setting: conf.setting,
+          columns: conf.columns
+        }
+
+        if (item.wrap.checkAll === 'show') {
+          if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') {
+            item.wrap.checkAll = 'hidden'
+          } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') {
+            item.wrap.checkAll = 'hidden'
+          }
+        }
+      }
+      
+      return true
+    })
+  }
+
   getPrinter = (item, parentId) => {
     let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
 
@@ -748,17 +796,17 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatSetting = (components, params, mainSearch, inherit, regs) => {
+  formatSetting = (components, params, mainSearch, inherit, regs, balMap) => {
     return components.map(component => {
       if (component.type === 'tabs') {
         component.subtabs = component.subtabs.map(tab => {
-          tab.components = this.formatSetting(tab.components, [], [], inherit, regs)
+          tab.components = this.formatSetting(tab.components, [], [], inherit, regs, balMap)
           tab = {...tab, ...inherit}
           return tab
         })
         return component
       } else if (component.type === 'group') {
-        component.components = this.formatSetting(component.components, [], [], inherit, regs)
+        component.components = this.formatSetting(component.components, [], [], inherit, regs, balMap)
         component = {...component, ...inherit}
         return component
       }
@@ -844,6 +892,11 @@
         }
       } else if (component.floor === 1) {
         component.setting.sync = 'false'
+      }
+
+      if (balMap.has(component.uuid)) {
+        component.setting.$hasSyncModule = true
+        balMap.set(component.uuid, component)
       }
 
       return component
@@ -1012,7 +1065,7 @@
       } else if (item.type === 'balcony') {
         return (
           <Col span={item.width} key={item.uuid}>
-            <Balcony menu={config} config={item} data={data} BID={_bid} menuType={menuType} />
+            <Balcony config={item} data={data} BID={_bid} menuType={menuType} />
           </Col>
         )
       } else if (item.type === 'carousel' && item.subtype === 'datacard') {

--
Gitblit v1.8.0