From da7068bd48791cdee966c786ce0dfd46f6e03df9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 一月 2021 19:02:24 +0800
Subject: [PATCH] 2021-01-08

---
 src/tabviews/commontable/index.jsx |  113 +++++++++++++++++++++++++++-----------------------------
 1 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 293205f..3f0ae4c 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -2,10 +2,9 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography, Row, Col } from 'antd'
+import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Typography, Row, Col } from 'antd'
 
 import Api from '@/api'
-import options from '@/store/options.js'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import Utils from '@/utils/utils.js'
@@ -27,7 +26,6 @@
 const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
 
 const { TabPane } = Tabs
-const { TreeNode } = Tree
 const { Paragraph } = Typography
 
 class NormalTable extends Component {
@@ -68,7 +66,6 @@
     statFields: [],       // 鍚堣瀛楁
     statFValue: [],       // 鍚堣鍊�
     absFields: [],        // 缁濆鍊煎瓧娈�
-    debug: sessionStorage.getItem('debug') === 'true'
   }
 
   /**
@@ -513,6 +510,9 @@
           }
 
           item.key = index
+          item.$$uuid = item[setting.primaryKey] || ''
+          item.$$BID = BID || ''
+
           return item
         }),
         total: result.total,
@@ -567,6 +567,9 @@
           data = data.map(item => {
             if (item[setting.primaryKey] === _data[setting.primaryKey]) {
               _data.key = item.key
+              _data.$$uuid = _data[setting.primaryKey] || ''
+              _data.$$BID = BID || ''
+
               return _data
             } else {
               return item
@@ -727,15 +730,6 @@
   }
 
   /**
-   * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤�
-   */
-  refreshbyaction = (position, btn) => {
-    if (position === 'grid' || position === 'view') {
-      this.reloadtable(btn)
-    }
-  }
-
-  /**
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
   getexceloutparam = (menuId, btnId) => {
@@ -831,15 +825,7 @@
       if (_others) {
         _title = _title + ': ' + _others
       }
-
-      if (item.subfuncs && item.subfuncs.length > 0) {
-        return (
-          <TreeNode title={_title} key={item.uuid} dataRef={item} selectable={false}>
-            {this.getTreeNode(item.subfuncs)}
-          </TreeNode>
-        )
-      }
-      return <TreeNode key={item.uuid} title={_title} isLeaf selectable={false} />
+      return <p key={item.uuid}>{_title}</p>
     })
   }
 
@@ -884,6 +870,20 @@
     this.setShortcut()
   }
 
+  /**
+   * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂�
+   * @param {*} menuId     // 鑿滃崟Id
+   * @param {*} position   // 鍒锋柊浣嶇疆
+   * @param {*} btn        // 鎵ц鐨勬寜閽�
+   */
+  refreshByButtonResult = (menuId, position, btn) => {
+    const { MenuID } = this.props
+
+    if (MenuID !== menuId) return
+
+    this.reloadtable(btn)
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -915,6 +915,7 @@
     MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu)
     MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   /**
@@ -929,11 +930,12 @@
     MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu)
     MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
   render() {
     const { menuType, MenuName } = this.props
-    const { debug, BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state
+    const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state
 
     return (
       <div className="commontable" id={this.state.ContainerId}>
@@ -965,7 +967,6 @@
                       MenuID={this.props.MenuID}
                       selectedData={selectedData}
                       ContainerId={this.state.ContainerId}
-                      refreshdata={this.refreshbyaction}
                     />
                   </div>
                   <div className="main-table-box">
@@ -984,7 +985,6 @@
                     }
                     <MainTable
                       tableId="mainTable"
-                      BID={BID}
                       pickup={pickup}
                       setting={setting}
                       columns={columns}
@@ -994,11 +994,10 @@
                       total={this.state.total}
                       MenuID={this.props.MenuID}
                       loading={this.state.loading}
-                      refreshdata={this.refreshbytable}
                       statFValue={this.state.statFValue}
-                      handleTableId={this.handleTableId}
                       ContainerId={this.state.ContainerId}
-                      refreshbyaction={this.refreshbyaction}
+                      refreshdata={this.refreshbytable}
+                      handleTableId={this.handleTableId}
                       chgSelectData={this.changeSelectedData}
                     />
                   </div>
@@ -1017,7 +1016,6 @@
                     MenuID={this.props.MenuID}
                     loading={this.state.loading}
                     ContainerId={this.state.ContainerId}
-                    refreshdata={this.refreshbyaction}
                     handleTableId={this.handleTableId}
                   />
                 </Col>
@@ -1038,33 +1036,32 @@
           })}
         </Row> : null }
         {setting && config.tabgroups.map(group => (
-            <Tabs key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
-              {group.sublist.map(_tab => {
-                return (
-                  <TabPane tab={
-                    <span>
-                      {_tab.icon ? <Icon type={_tab.icon} /> : null}
-                      {_tab.label}
-                    </span>
-                  } key={_tab.uuid}>
-                    <SubTable
-                      Tab={_tab}
-                      MenuID={_tab.linkTab}
-                      mainSearch={_tab.searchPass === 'true' ? search : null}
-                      userConfig={userConfig ? userConfig[_tab.uuid] : null}
-                      SupMenuID={this.props.MenuID}
-                      ContainerId={this.state.ContainerId}
-                      BID={this.state.BIDs[_tab.supMenu] || ''}
-                      BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
-                      handleTableId={this.handleTableId}
-                    />
-                  </TabPane>
-                )
-              })}
-            </Tabs>)
-          )
+          <Tabs key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
+            {group.sublist.map(_tab => {
+              return (
+                <TabPane tab={
+                  <span>
+                    {_tab.icon ? <Icon type={_tab.icon} /> : null}
+                    {_tab.label}
+                  </span>
+                } key={_tab.uuid}>
+                  <SubTable
+                    Tab={_tab}
+                    MenuID={_tab.linkTab}
+                    mainSearch={_tab.searchPass === 'true' ? search : null}
+                    userConfig={userConfig ? userConfig[_tab.uuid] : null}
+                    SupMenuID={this.props.MenuID}
+                    ContainerId={this.state.ContainerId}
+                    BID={this.state.BIDs[_tab.supMenu] || ''}
+                    BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
+                    handleTableId={this.handleTableId}
+                  />
+                </TabPane>
+              )
+            })}
+          </Tabs>))
         }
-        {debug && options.sysType !== 'cloud' && menuType !== 'HS' ? <Button
+        {menuType !== 'HS' ? <Button
           icon="copy"
           shape="circle"
           className="common-table-copy"
@@ -1072,7 +1069,7 @@
         /> : null}
         <Modal
           className="menu-tree-modal"
-          title={'鑿滃崟缁撴瀯鏍�'}
+          title={'鑿滃崟淇℃伅'}
           width={'650px'}
           maskClosable={false}
           visible={this.state.treevisible}
@@ -1086,9 +1083,7 @@
             <span>鑿滃崟鍚嶇О锛歿this.props.MenuName}</span>
             <span>鑿滃崟鍙傛暟锛歿<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span>
           </div>
-          {this.state.treevisible ? <Tree defaultExpandAll showLine={true}>
-            {this.getTreeNode(config.funcs)}
-          </Tree> : null}
+          {this.state.treevisible ? this.getTreeNode(config.funcs) : null}
         </Modal>
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>

--
Gitblit v1.8.0