From 89e7167a83e0d8409ca87698e4c08651a37cc26e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 12 六月 2020 18:19:35 +0800
Subject: [PATCH] 2020-06-12

---
 src/tabviews/commontable/secretKeyTable/index.jsx |   85 +++++++++++++++---------------------------
 1 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/src/tabviews/managetable/secretKeyTable/index.jsx b/src/tabviews/commontable/secretKeyTable/index.jsx
similarity index 81%
rename from src/tabviews/managetable/secretKeyTable/index.jsx
rename to src/tabviews/commontable/secretKeyTable/index.jsx
index 02183ae..89cef32 100644
--- a/src/tabviews/managetable/secretKeyTable/index.jsx
+++ b/src/tabviews/commontable/secretKeyTable/index.jsx
@@ -9,10 +9,12 @@
 import options from '@/store/options.js'
 import { buttonConfig, tabConfig, refCodes } from './config'
 
-import SubTable from '@/tabviews/zshare/normalTable'
+import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import SubAction from './actionList'
 
 import './index.scss'
+
+const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
 
 class VerupSubTabViewTable extends Component {
   static propTpyes = {
@@ -23,7 +25,6 @@
     MenuID: PropTypes.string,        // 鑿滃崟Id
     SupMenuID: PropTypes.string,     // 涓婄骇鑿滃崟Id
     ContainerId: PropTypes.any,      // 涓夌骇鑿滃崟Container(html) ID
-    handleTableId: PropTypes.func,   // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d
     handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃
     refreshtabs:PropTypes.any
   }
@@ -35,6 +36,8 @@
     columns: null,        // 鏄剧ず鍒�
     setting: null,        // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑
     data: null,           // 鍒楄〃鏁版嵁闆�
+    selectedData: [],     // 宸查�夎〃鏍兼暟鎹�
+    resetTable: false,    // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 寮规鏄剧ず闅愯棌鎺у埗
     pickup: false,        // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲
@@ -45,8 +48,13 @@
    */
   UNSAFE_componentWillReceiveProps(nextProps) {
     if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) {
-      this.refs.subTable.resetTable()
-      this.loadmaindata(nextProps.BID, 'refresh')
+      this.setState({
+        pageIndex: 1,
+        selectedData: [],
+        resetTable: !this.state.resetTable,
+      }, () => {
+        this.loadmaindata(nextProps.BID, 'refresh')
+      })
     } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) {
 
       this.reloadtable()
@@ -99,6 +107,8 @@
       }
     })
 
+    config.setting.tabType = 'sub'
+
     this.setState({
       config: config,
       setting: config.setting,
@@ -123,8 +133,6 @@
    * @description 瀛愯〃鏁版嵁鍔犺浇
    */
   async loadmaindata (bid, type) {
-    const { setting } = this.state
-    let param = ''
     let _BID = this.props.BID
     
     if (type === 'refresh') {
@@ -134,19 +142,11 @@
           data: [],
           loading: false
         })
-
         return
       }
     }
 
-    if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) {
-      param = this.getCustomParam(_BID)
-    } else {
-      param = this.getDefaultParam(_BID)
-    }
-
-    this.handleTableId()
-
+    let param = this.getCustomParam(_BID)
     let result = await Api.getLocalConfig(param)
 
     if (result.status) {
@@ -246,16 +246,17 @@
       })
     }
 
-    this.setState({data})
+    this.setState({data: data, selectedData: []})
   }
 
   /**
    * @description 琛ㄦ牸鍒锋柊
    */
   reloadtable = () => {
-    this.refs.subTable.resetTable()
     this.setState({
       loading: true,
+      selectedData: [],
+      resetTable: !this.state.resetTable
     }, () => {
       this.loadmaindata()
     })
@@ -266,12 +267,7 @@
    */
   reloadview = () => {
     this.setState({
-      config: null,
-      actions: null,
-      columns: null,
-      setting: null,
-      data: null,
-      loading: false,
+      config: null, actions: null, columns: null, setting: null, data: null, loading: false, selectedData: []
     }, () => {
       this.loadconfig()
     })
@@ -280,34 +276,19 @@
   /**
    * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤�
    */
-  refreshbyaction = (btn, type) => {
-    if (btn.execSuccess === 'grid' && type === 'success') {
+  refreshbyaction = (position) => {
+    if (position === 'grid') {
       this.reloadtable()
-    } else if (btn.execError === 'grid' && type === 'error') {
-      this.reloadtable()
-    } else if (btn.execSuccess === 'view' && type === 'success') {
-      this.reloadview()
-    } else if (btn.execError === 'view' && type === 'error') {
+    } else if (position === 'view') {
       this.reloadview()
     }
   }
 
   /**
-   * @description 鑾峰彇琛ㄦ牸閫夋嫨椤�
+   * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹�
    */
-  gettableselected = () => {
-    let data = []
-    this.refs.subTable.state.selectedRowKeys.forEach(item => {
-      data.push(this.refs.subTable.props.data[item])
-    })
-    return data
-  }
-
-  /**
-   * @description 琛ㄦ牸Id鍙樺寲
-   */
-  handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => {
-    this.props.handleTableId(type, id, data)
+  changeSelectedData = (selectedData) => {
+    this.setState({selectedData})
   }
 
   /**
@@ -327,7 +308,7 @@
   }
 
   shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑
-    return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState))
+    return !is(fromJS({...this.props, handleMainTable: ''}), fromJS({...nextProps, handleMainTable: ''})) || !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -340,26 +321,22 @@
   }
 
   render() {
-    const { setting, actions, columns, pickup, config } = this.state
+    const { setting, actions, columns, pickup, config, selectedData } = this.state
 
     return (
       <div className="subtable" id={'subtable' + this.props.MenuID}>
         <div className="sub-action">
           <SubAction
-            ref="subButton"
-            type="sub"
             setting={setting}
             actions={actions}
             Tab={this.props.Tab}
             BID={this.props.BID}
             datalist={this.state.data}
             dict={this.state.dict}
+            selectedData={selectedData}
             MenuID={this.props.SupMenuID}
-            logcolumns={[]}
             refreshdata={this.refreshbyaction}
             ContainerId={this.props.ContainerId}
-            getexceloutparam={this.getexceloutparam}
-            gettableselected={this.gettableselected}
           />
         </div>
         <div className="subtable-box">
@@ -367,21 +344,19 @@
             <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
           }
           <SubTable
-            ref="subTable"
-            menuType="HS"
             tableId={this.props.Tab.uuid}
             pickup={pickup}
             config={config}
             setting={setting}
             columns={columns}
-            pagination={false}
             dict={this.state.dict}
             data={this.state.data}
             MenuID={this.props.MenuID}
             loading={this.state.loading}
             refreshdata={this.refreshbytable}
             buttonTrigger={() => {}}
-            handleTableId={this.handleTableId}
+            handleTableId={() => {}}
+            chgSelectData={this.changeSelectedData}
           />
         </div>
       </div>

--
Gitblit v1.8.0