From d6dfba48678e1107a9e7c6524e1dfa2d3fdff03c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 十月 2021 19:29:21 +0800
Subject: [PATCH] 2021-10-08

---
 src/tabviews/custom/components/share/normalTable/index.jsx |   66 +++++++++++++++++---------------
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx
index 46eba22..800a973 100644
--- a/src/tabviews/custom/components/share/normalTable/index.jsx
+++ b/src/tabviews/custom/components/share/normalTable/index.jsx
@@ -5,7 +5,6 @@
 import { is, fromJS } from 'immutable'
 import { Table, Typography, Icon, Col, Switch, message } from 'antd'
 
-import { modifyTabview } from '@/store/action'
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -51,7 +50,7 @@
           try {
             originVal = parseFloat(originVal)
             contrastVal = parseFloat(contrastVal)
-          } catch {
+          } catch (e) {
             originVal = NaN
           }
   
@@ -62,7 +61,7 @@
           try {
             originVal = parseFloat(originVal)
             contrastVal = parseFloat(contrastVal)
-          } catch {
+          } catch (e) {
             originVal = NaN
           }
   
@@ -120,7 +119,7 @@
         try {
           originVal = parseFloat(originVal)
           contrastVal = parseFloat(contrastVal)
-        } catch {
+        } catch (e) {
           originVal = NaN
         }
 
@@ -131,7 +130,7 @@
         try {
           originVal = parseFloat(originVal)
           contrastVal = parseFloat(contrastVal)
-        } catch {
+        } catch (e) {
           originVal = NaN
         }
 
@@ -223,7 +222,7 @@
         if (isNaN(content)) {
           content = ''
         }
-      } catch {
+      } catch (e) {
         content = ''
       }
 
@@ -283,7 +282,7 @@
 
       resProps.children = (
         <div>
-          {photos.map((url, i) => (
+          {photos && photos.map((url, i) => (
             <Col key={i} span={cols}>
               <div className={'ant-mk-picture' + (scale ? ' scale' : '')} onClick={() => {
                 if (!scale) return
@@ -332,7 +331,7 @@
         
         try {
           _param = window.btoa(_quary)
-        } catch {
+        } catch (e) {
           _param = window.btoa(window.encodeURIComponent(_quary))
         }
         
@@ -500,6 +499,7 @@
   }
 
   componentDidMount () {
+    MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine)
     MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.addListener('resetTable', this.resetTable)
   }
@@ -511,8 +511,23 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
     MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
     MKEmitter.removeListener('resetTable', this.resetTable)
+  }
+
+  mkCheckTopLine = (menuId) => {
+    const { MenuID, data, setting } = this.props
+
+    if (MenuID !== menuId || !data || data.length === 0) return
+
+    this.changedata(0)
+    this.setState({ selectedRowKeys: [0], activeIndex: 0 })
+    this.props.chgSelectData([data[0]])
+
+    if (setting.$hasSyncModule) {
+      MKEmitter.emit('syncBalconyData', MenuID, [data[0]], data.length === 1)
+    }
   }
 
   mkCheckAll = (menuId, checked) => {
@@ -548,7 +563,6 @@
 
   // 瀛楁閫忚
   triggerLink = (e, item, record) => {
-    const { tabviews } = this.props
     e.stopPropagation()
 
     let __param = {
@@ -567,21 +581,12 @@
       let tabmenu = item.linkThdMenu
 
       tabmenu.param = __param
-      tabmenu.selected = true
-  
-      let tabs = tabviews.filter((tab, i) => {
-        tab.selected = false
-        return tab.MenuID !== tabmenu.MenuID
-      })
-  
-      if (tabviews.length > tabs.length) {
-        this.props.modifyTabview(fromJS(tabs).toJS())
+
+      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
+        MKEmitter.emit('modifyTabs', tabmenu, 'replace')
+      } else {
+        MKEmitter.emit('modifyTabs', tabmenu, 'plus', true)
       }
-  
-      this.setState({}, () => {
-        tabs.push(tabmenu)
-        this.props.modifyTabview(tabs)
-      })
     } else if (item.linkurl) {
       let src = item.linkurl
 
@@ -594,7 +599,7 @@
           _param.User_Name = sessionStorage.getItem('User_Name')
           _param.param = __param
           src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
-        } catch {
+        } catch (e) {
           console.warn('鑿滃崟鍙傛暟瑙f瀽閿欒锛�')
         }
       } else {
@@ -853,8 +858,10 @@
       _footer = statFValue.map(f => `${f.label}(鍚堣)锛�${f.value}`).join('锛�')
     }
 
+    let height = setting.height || false
+
     return (
-      <div className={`normal-custom-table ${setting.tableHeader || ''} ${setting.mode || ''}`} id={tableId}>
+      <div className={`normal-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}>
         {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ?
           <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null
         }
@@ -867,7 +874,7 @@
           columns={this.state.columns}
           dataSource={_data}
           loading={this.props.loading}
-          scroll={{ x: '100%', y: false }}
+          scroll={{ x: '100%', y: height }}
           onRow={(record, index) => {
             return {
               lineMarks,
@@ -889,15 +896,12 @@
 const mapStateToProps = (state) => {
   return {
     menuType: state.editLevel,
-    tabviews: state.tabviews,
     memberLevel: state.memberLevel
   }
 }
 
-const mapDispatchToProps = (dispatch) => {
-  return {
-    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
-  }
+const mapDispatchToProps = () => {
+  return {}
 }
 
 export default connect(mapStateToProps, mapDispatchToProps)(NormalTable)
\ No newline at end of file

--
Gitblit v1.8.0