From 28d65cf7ebfe0dd30ade6973e0634e1c8f663b63 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 十月 2020 16:12:20 +0800
Subject: [PATCH] 2020-10-28

---
 src/tabviews/zshare/normalTable/index.jsx |  126 ++++++++++++++++++++++++++++-------------
 1 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx
index da89069..6ef7187 100644
--- a/src/tabviews/zshare/normalTable/index.jsx
+++ b/src/tabviews/zshare/normalTable/index.jsx
@@ -3,14 +3,21 @@
 import md5 from 'md5'
 import { is, fromJS } from 'immutable'
 import {connect} from 'react-redux'
-import { Table, message, Affix, Button, Typography, Modal, Icon } from 'antd'
+import { Table, message, Affix, Typography, Modal, Icon } from 'antd'
 
 import Utils from '@/utils/utils.js'
 import { modifyTabview } from '@/store/action'
+import asyncComponent from '@/utils/asyncComponent'
+import MKEmitter from '@/utils/events.js'
 import '@/assets/css/table.scss'
 import './index.scss'
 
 const { Paragraph } = Typography
+
+const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton'))
+const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
+const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
+const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
 
 class NormalTable extends Component {
   static defaultProps = {
@@ -18,23 +25,26 @@
   }
 
   static propTpyes = {
-    tableId: PropTypes.string,     // 鍒楄〃Id
-    resetTable: PropTypes.bool,    // 琛ㄦ牸閲嶇疆
-    statFValue: PropTypes.any,     // 鍚堣瀛楁鏁版嵁
-    pageSize: PropTypes.any,       // 姣忛〉鏁版嵁
-    dict: PropTypes.object,        // 瀛楀吀椤�
-    config: PropTypes.object,      // 椤甸潰閰嶇疆
-    MenuID: PropTypes.string,      // 鑿滃崟Id
-    setting: PropTypes.object,     // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乧olumnfixed锛堝垪鍥哄畾锛夈�乤ctionfixed锛堟寜閽浐瀹氾級
-    pickup: PropTypes.any,         // 鏁版嵁鏀惰捣
-    columns: PropTypes.array,      // 琛ㄦ牸鍒�
-    data: PropTypes.any,           // 琛ㄦ牸鏁版嵁
-    total: PropTypes.any,          // 鎬绘暟
-    loading: PropTypes.bool,       // 琛ㄦ牸鍔犺浇涓�
-    refreshdata: PropTypes.func,   // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
-    buttonTrigger: PropTypes.func, // 琛ㄦ牸涓寜閽Е鍙戞搷浣�
-    handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲
-    chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲
+    tableId: PropTypes.string,       // 鍒楄〃Id
+    statFValue: PropTypes.any,       // 鍚堣瀛楁鏁版嵁
+    pageSize: PropTypes.any,         // 姣忛〉鏁版嵁
+    dict: PropTypes.object,          // 瀛楀吀椤�
+    config: PropTypes.object,        // 椤甸潰閰嶇疆
+    MenuID: PropTypes.string,        // 鑿滃崟Id
+    setting: PropTypes.object,       // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乧olumnfixed锛堝垪鍥哄畾锛夈�乤ctionfixed锛堟寜閽浐瀹氾級
+    pickup: PropTypes.any,           // 鏁版嵁鏀惰捣
+    columns: PropTypes.array,        // 琛ㄦ牸鍒�
+    logcolumns: PropTypes.array,     // 瀛楁鍒�
+    BID: PropTypes.any,              // 涓昏〃Id
+    ContainerId: PropTypes.any,      // 鏍囩椤靛灞侷d
+    BData: PropTypes.any,            // 涓昏〃鏁版嵁
+    data: PropTypes.any,             // 琛ㄦ牸鏁版嵁
+    total: PropTypes.any,            // 鎬绘暟
+    loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
+    refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
+    handleTableId: PropTypes.func,   // 鏁版嵁鍒囨崲
+    chgSelectData: PropTypes.func,   // 鏁版嵁鍒囨崲
+    refreshbyaction: PropTypes.func, // 鏁版嵁鍒囨崲
   }
 
   state = {
@@ -177,13 +187,8 @@
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
-  /**
-   * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁
-   */
-  UNSAFE_componentWillReceiveProps(nextProps) {
-    if (this.props.resetTable !== nextProps.resetTable) {
-      this.resetTable()
-    }
+  componentDidMount () {
+    MKEmitter.addListener('resetTable', this.resetTable)
   }
 
   /**
@@ -193,6 +198,7 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('resetTable', this.resetTable)
   }
 
   // 瀛楁閫忚
@@ -558,14 +564,57 @@
       )
     } else if (item.type === 'action') {
       return (
-        <div className={item.style} style={{ minWidth: (item.Width || 120) + 'px' }}>
+        <div className="action-col" style={{ minWidth: (item.Width || 120) + 'px' }}>
           {item.operations.map(btn => {
-            return <Button
-              className={'mk-btn mk-' + btn.class}
-              icon={btn.icon}
-              key={btn.uuid}
-              onClick={(e) => {this.actionTrigger(e, btn, record)}}
-            >{btn.label}</Button>
+            if (['exec', 'prompt', 'pop'].includes(btn.OpenType)) {
+              return (
+                <NormalButton
+                  key={btn.uuid}
+                  btn={btn}
+                  BID={this.props.BID}
+                  selectedData={[record]}
+                  BData={this.props.BData}
+                  setting={this.props.setting}
+                  columns={this.props.logcolumns}
+                  ContainerId={this.props.ContainerId}
+                  updateStatus={this.props.refreshbyaction}
+                />
+              )
+            } else if (btn.OpenType === 'popview') {
+              return (
+                <PopupButton
+                  key={btn.uuid}
+                  btn={btn}
+                  BID={this.props.BID}
+                  selectedData={[record]}
+                  BData={this.props.BData}
+                  setting={this.props.setting}
+                  updateStatus={this.props.refreshbyaction}
+                />
+              )
+            } else if (btn.OpenType === 'tab' || btn.OpenType === 'blank') {
+              return (
+                <TabButton
+                  key={btn.uuid}
+                  btn={btn}
+                  selectedData={[record]}
+                  MenuID={this.props.MenuID}
+                  setting={this.props.setting}
+                  updateStatus={this.props.refreshbyaction}
+                />
+              )
+            } else if (btn.OpenType === 'innerpage' || btn.OpenType === 'outerpage') {
+              return (
+                <NewPageButton
+                  key={btn.uuid}
+                  btn={btn}
+                  selectedData={[record]}
+                  setting={this.props.setting}
+                  updateStatus={this.props.refreshbyaction}
+                />
+              )
+            }
+            return null
           })}
         </div>
       )
@@ -816,11 +865,6 @@
     }
   }
 
-  actionTrigger = (e, btn, record) => {
-    e.stopPropagation()
-    this.props.buttonTrigger(btn, record)
-  }
-
   copycontent = (e, content) => {
     // 琛ㄦ牸涓唴瀹瑰鍒�
     e.stopPropagation()
@@ -906,8 +950,6 @@
   changedata = (index) => {
     const { data, setting } = this.props
 
-    if (!this.props.tableId) return
-
     let _id = ''
     let _data = ''
 
@@ -919,7 +961,11 @@
     this.props.handleTableId(this.props.tableId, _id, _data)
   }
 
-  resetTable = () => {
+  resetTable = (id) => {
+    const { MenuID, tableId } = this.props
+
+    if (id !== (MenuID + tableId)) return
+
     this.setState({
       pageIndex: 1,
       selectedRowKeys: [],

--
Gitblit v1.8.0