From c98e45bfac25e9110ad0383faac54a54d98ea9d5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 18 十一月 2021 20:47:04 +0800
Subject: [PATCH] 2021-11-18

---
 src/tabviews/scriptmanage/index.jsx |   57 +++++++++++++++++++++++++++------------------------------
 1 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx
index 12d0fd9..06d760a 100644
--- a/src/tabviews/scriptmanage/index.jsx
+++ b/src/tabviews/scriptmanage/index.jsx
@@ -12,11 +12,12 @@
 import { scriptMainTable, buttonConfig } from './config'
 import MKEmitter from '@/utils/events.js'
 
+import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
-import TopSearch from './topSearch'
 import MainAction from './actionList'
 import './index.scss'
 
+const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
 const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
 
 class ScriptTable extends Component {
@@ -85,8 +86,10 @@
             subcols.push(colMap.get(sub))
           }
         })
-        _col.subcols = subcols
-        _columns.push(_col)
+        if (subcols.length > 0) {
+          _col.subcols = subcols
+          _columns.push(_col)
+        }
       } else {
         _columns.push(col)
       }
@@ -117,6 +120,7 @@
    * @description 涓昏〃鏁版嵁鍔犺浇
    */ 
   async loadmaindata () {
+    const { setting } = this.state
     let param = this.getDefaultParam()
 
     this.setState({
@@ -131,8 +135,8 @@
     if (result.status) {
       this.setState({
         data: result.data.map((item, index) => {
-          item.LongParam = Utils.UnformatOptions(item.LongParam)
           item.key = index
+          item.$$uuid = item[setting.primaryKey] || ''
           return item
         }),
         total: result.total,
@@ -192,7 +196,7 @@
    * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃�
    */
   refreshbysearch = (searches) => {
-    MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆
+    MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆
     this.setState({
       loading: true,
       pageIndex: 1,
@@ -230,7 +234,7 @@
    * @description 琛ㄦ牸鍒锋柊
    */
   reloadtable = () => {
-    MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆
+    MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆
     this.setState({
       loading: true,
       pageIndex: 1,
@@ -252,21 +256,6 @@
   }
 
   /**
-   * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤�
-   */
-  refreshbyaction = (btn, type) => {
-    if (btn.execSuccess === 'grid' && type === 'success') {
-      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') {
-      this.reloadview()
-    }
-  }
-
-  /**
    * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹�
    */
   changeSelectedData = (selectedData) => {
@@ -283,9 +272,21 @@
     })
   }
 
+  reloadMenuView = (menuId) => {
+    const { MenuID } = this.props
+
+    if (MenuID !== menuId) return
+
+    this.reloadview()
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
+  }
+
+  componentDidMount () {
+    MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -299,18 +300,15 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
   }
 
   render() {
-    const { dict, searchlist, setting, actions, columns, pickup, selectedData } = this.state
+    const { searchlist, setting, actions, columns, pickup, selectedData } = this.state
 
     return (
       <div className="script-manage-table" id={this.state.ContainerId}>
-        <TopSearch
-          dict={dict}
-          searchlist={searchlist}
-          refreshdata={this.refreshbysearch}
-        />
+        <MainSearch searchlist={searchlist} menuType="HS" refreshdata={this.refreshbysearch}/>
         <MainAction
           BID=""
           type="main"
@@ -320,7 +318,7 @@
           MenuID={this.props.MenuID}
           selectedData={selectedData}
           ContainerId={this.state.ContainerId}
-          refreshdata={this.refreshbyaction}
+          refreshdata={this.reloadtable}
         />
         <div className="main-table-box">
           {this.state.data && this.state.data.length > 0 ?
@@ -329,7 +327,7 @@
             </div> : null
           }
           <MainTable
-            tableId="mainTable"
+            tableId={this.props.MenuID}
             pickup={pickup}
             setting={setting}
             columns={columns}
@@ -340,7 +338,6 @@
             loading={this.state.loading}
             refreshdata={this.refreshbytable}
             buttonTrigger={() => {}}
-            handleTableId={() => {}}
             chgSelectData={this.changeSelectedData}
           />
         </div>

--
Gitblit v1.8.0