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/subtabtable/index.jsx |  116 ++++++++++++++++++----------------------------------------
 1 files changed, 36 insertions(+), 80 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index e059907..5d7d64f 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -13,7 +13,6 @@
 
 import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
-import SubTable from '@/tabviews/zshare/normalTable'
 import SubSearch from '@/tabviews/zshare/topSearch'
 import NotFount from '@/components/404'
 
@@ -21,17 +20,16 @@
 
 const { TabPane } = Tabs
 const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
-const CardComponent = asyncComponent(() => import('@/tabviews/zshare/cardcomponent'))
+const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
+const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
 const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
 
 class SubTabModalTable extends Component {
   static propTpyes = {
-    menuType: PropTypes.any,         // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS
     BID: PropTypes.string,           // 涓婄骇鏁版嵁ID
     BData: PropTypes.any,            // 涓婄骇鏁版嵁
     MenuID: PropTypes.string,        // 鑿滃崟Id
     SupMenuID: PropTypes.string,     // 涓婄骇鑿滃崟Id
-    ContainerId: PropTypes.any,      // 涓夌骇鑿滃崟Container(html) ID
     refreshSupView: PropTypes.any    // 鍒锋柊涓婄骇鑿滃崟
   }
 
@@ -48,6 +46,8 @@
     arr_field: '',        // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆�
     setting: null,        // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑
     data: null,           // 鍒楄〃鏁版嵁闆�
+    selectedData: [],     // 宸查�夎〃鏍兼暟鎹�
+    resetTable: false,    // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆
     total: 0,             // 鎬绘暟
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     pageIndex: 1,         // 椤电爜
@@ -236,10 +236,8 @@
       })
 
       if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
-        _columns.push({
-          ...config.gridBtn,
-          operations: _operations
-        })
+        config.gridBtn.operations = _operations
+        _columns.push(config.gridBtn)
       }
 
       let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉
@@ -248,6 +246,8 @@
           valid = false
         }
       })
+
+      config.setting.tabType = 'subtab'
 
       this.setState({
         loadingview: false,
@@ -580,11 +580,11 @@
    * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃�
    */
   refreshbysearch = (searches) => {
-    this.refs.subTable && this.refs.subTable.resetTable()
-
     this.setState({
       pageIndex: 1,
-      search: searches
+      search: searches,
+      selectedData: [],
+      resetTable: !this.state.resetTable
     }, () => {
       this.loadmaindata()
     })
@@ -603,6 +603,7 @@
     }
 
     this.setState({
+      selectedData: [],
       pageIndex: pagination.current,
       pageSize: pagination.pageSize,
       orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
@@ -615,35 +616,28 @@
    * @description 琛ㄦ牸鍒锋柊
    */
   reloadtable = () => {
-    this.refs.subTable && this.refs.subTable.resetTable()
     this.setState({
-      pageIndex: 1
+      pageIndex: 1,
+      selectedData: [],
+      resetTable: !this.state.resetTable
     }, () => {
       this.loadmaindata()
     })
   }
 
   /**
+   * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹�
+   */
+  changeSelectedData = (selectedData) => {
+    this.setState({selectedData})
+  }
+
+  /**
    * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃�
    */
   reloadview = () => {
-    this.setState({
-      loadingview: true,
-      viewlost: false,
-      lostmsg: '',
-      config: null,
-      searchlist: null,
-      actions: null,
-      columns: null,
-      arr_field: '',
-      setting: null,
-      data: null,
-      total: 0,
-      loading: false,
-      pageIndex: 1,
-      pageSize: 10,
-      orderBy: '',
-      search: '',
+    this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, columns: null,
+      arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '',
       triggerBtn: null
     }, () => {
       this.loadconfig()
@@ -653,30 +647,14 @@
   /**
    * @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.props.refreshSupView()
+    } else if (position === 'view') {
       this.reloadview()
-    } else if (btn.execSuccess === 'view' && type === 'success') {
-      this.reloadtable()
-    } else if (btn.execError === 'view' && type === 'error') {
-      this.reloadview()
-    }
-    if (type === 'success') {
       this.props.refreshSupView()
     }
-  }
-
-  /**
-   * @description 鑾峰彇琛ㄦ牸閫夋嫨椤�
-   */
-  gettableselected = () => {
-    let data = []
-    this.refs.subTable && this.refs.subTable.state.selectedRowKeys.forEach(item => {
-      data.push(this.refs.subTable.props.data[item])
-    })
-    return data
   }
 
   /**
@@ -719,7 +697,7 @@
   }
 
   render() {
-    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId } = this.state
+    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId, selectedData } = this.state
 
     return (
       <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
@@ -747,38 +725,34 @@
                   {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
                   <div style={{minHeight: '25px'}}>
                     <SubAction
-                      type="subtab"
                       triggerBtn={triggerBtn}
-                      menuType={this.props.menuType}
                       setting={setting}
                       actions={actions}
                       BID={this.props.BID}
                       dict={this.state.dict}
                       BData={this.props.BData}
+                      selectedData={selectedData}
                       MenuID={this.props.SupMenuID}
                       logcolumns={this.state.logcolumns}
+                      operations={config.gridBtn.operations || []}
                       refreshdata={this.refreshbyaction}
-                      ContainerId={this.props.ContainerId}
-                      gettableselected={this.gettableselected}
                     />
                   </div>
                   <SubTable
-                    ref="subTable"
-                    menuType={this.props.menuType}
                     tableId=""
-                    dict={this.state.dict}
-                    MenuID={this.props.MenuID}
                     config={config}
                     setting={setting}
                     columns={columns}
                     pageSize={pageSize}
                     data={this.state.data}
+                    dict={this.state.dict}
                     total={this.state.total}
-                    memberLevel={this.props.memberLevel}
+                    MenuID={this.props.MenuID}
                     loading={this.state.loading}
-                    pagination={setting.laypage !== 'false'}
                     refreshdata={this.refreshbytable}
                     buttonTrigger={this.buttonTrigger}
+                    resetTable={this.state.resetTable}
+                    chgSelectData={this.changeSelectedData}
                     handleTableId={() => {}}
                   />
                 </Col>
@@ -795,25 +769,6 @@
                     buttonTrigger={this.buttonTrigger}
                     handleTableId={() => {}}
                   />
-                  <div style={{display: 'none'}}>
-                    <SubAction
-                      type="subtab"
-                      triggerBtn={triggerBtn}
-                      menuType={this.props.menuType}
-                      setting={setting}
-                      actions={actions}
-                      BID={this.props.BID}
-                      dict={this.state.dict}
-                      BData={this.props.BData}
-                      MenuID={this.props.SupMenuID}
-                      permRoles={this.props.permRoles}
-                      dataManager={this.props.dataManager}
-                      logcolumns={this.state.logcolumns}
-                      refreshdata={this.refreshbyaction}
-                      ContainerId={this.props.ContainerId}
-                      gettableselected={() => {}}
-                    />
-                  </div>
                 </Col>
               )
             } else {
@@ -838,6 +793,7 @@
 
 const mapStateToProps = (state) => {
   return {
+    menuType: state.editLevel,
     permAction: state.permAction,
     permRoles: state.permRoles,
     dataManager: state.dataManager,

--
Gitblit v1.8.0