From 4b6a4e2f04f492d770573cf48ca52d4e748a086a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 18 十月 2021 18:30:50 +0800
Subject: [PATCH] 2021-10-18

---
 src/tabviews/formtab/index.jsx |   64 +++++++++++++-------------------
 1 files changed, 26 insertions(+), 38 deletions(-)

diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx
index 69bdf15..f831a71 100644
--- a/src/tabviews/formtab/index.jsx
+++ b/src/tabviews/formtab/index.jsx
@@ -48,11 +48,11 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction } = this.props
+    const { permAction, MenuID } = this.props
 
     let param = {
       func: 'sPC_Get_LongParam',
-      MenuID: this.props.MenuID
+      MenuID: MenuID
     }
     let result = await Api.getCacheConfig(param)
     if (result.status) {
@@ -103,13 +103,15 @@
         config.tabgroups = _tabgroups
       }
 
-      // 鏉冮檺杩囨护
-      if (this.props.menuType !== 'HS') {
-        config.action = config.action.filter(item => permAction[item.uuid])
-        config.tabgroups.forEach(group => {
-          group.sublist = group.sublist.filter(tab => permAction[tab.linkTab])
+      config.action = config.action.filter(item => permAction[item.uuid])
+      config.tabgroups.forEach(group => {
+        group.sublist = group.sublist.filter(tab => {
+          if (tab.supMenu === 'mainTable') {
+            tab.supMenu = MenuID
+          }
+          return permAction[tab.linkTab]
         })
-      }
+      })
 
       // 鎸夐挳绫诲瀷鍏煎
       config.action = config.action.map(item => {
@@ -141,8 +143,8 @@
         primaryId: this.props.param.primaryId || '',
         data: this.props.param.data || null,
         BIDs: {
-          mainTable: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '',
-          mainTabledata: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : ''
+          [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '',
+          [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : ''
         }
       }, () => {
         this.improveSelectOption(config.groups)
@@ -340,11 +342,7 @@
       this.setState({
         data: _data,
         primaryId: _primaryId,
-        BIDs: {
-          ...BIDs,
-          mainTable: _primaryId,
-          mainTabledata: _data
-        }
+        BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data }
       })
 
       if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) {
@@ -493,11 +491,7 @@
           }
 
           this.setState({
-            BIDs: {
-              ...BIDs,
-              mainTable: primaryId,
-              mainTabledata: data
-            }
+            BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data }
           })
         }
       })
@@ -517,21 +511,6 @@
       }
       MKEmitter.emit('closeTabView', this.props.MenuID)
     }
-  }
-
-  /**
-   * @description 琛ㄦ牸Id鍙樺寲
-   */
-  handleTableId = (type, id, data) => {
-    const { BIDs } = this.state
-
-    this.setState({
-      BIDs: {
-        ...BIDs,
-        [type]: id,
-        [type + 'data']: data
-      }
-    })
   }
 
   /**
@@ -574,6 +553,14 @@
     this.loadmaindata()
   }
 
+  changeTableLine = (ContainerId, tableId, id, data) => {
+    if (this.state.ContainerId !== ContainerId) return
+
+    this.setState({
+      BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data}
+    })
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -584,8 +571,9 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.addListener('reloadData', this.reloadData)
+    MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
+    MKEmitter.addListener('changeTableLine', this.changeTableLine)
   }
 
   /**
@@ -596,8 +584,9 @@
       return
     }
 
-    MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
+    MKEmitter.removeListener('changeTableLine', this.changeTableLine)
   }
 
   render() {
@@ -653,7 +642,6 @@
                         ContainerId={this.state.ContainerId}
                         BID={this.state.BIDs[_tab.supMenu] || ''}
                         BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
-                        handleTableId={this.handleTableId}
                       />
                     </TabPane>
                   )

--
Gitblit v1.8.0