From 46f79b491173d284a4900d19e7aecf7509481438 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 一月 2022 17:21:25 +0800
Subject: [PATCH] 2022-01-21

---
 src/tabviews/custom/components/tabs/antv-tabs/index.jsx |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx
index 6ad66b0..4b8ef58 100644
--- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx
+++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx
@@ -1,9 +1,10 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Tabs, Icon } from 'antd'
+import { Tabs } from 'antd'
 
 import asyncComponent from '@/utils/asyncComponent'
+import MkIcon from '@/components/mk-icon'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
@@ -28,8 +29,9 @@
 
   UNSAFE_componentWillMount () {
     const { config, bids } = this.props
+
     this.setState({
-      tabs: config,
+      tabs: fromJS(config).toJS(),
       parentIds: config.parentIds || [],
       bids: bids ? bids : {}
     })
@@ -60,13 +62,33 @@
   }
 
   resetParentParam = (MenuID, id, data) => {
-    const { parentIds, bids } = this.state
+    const { parentIds, bids, tabs } = this.state
 
-    if (!parentIds.includes(MenuID)) return
+    if (parentIds.includes(MenuID)) {
+      this.setState({
+        bids: {...bids, [MenuID]: id, [MenuID + '_data']: data}
+      })
+    }
 
-    this.setState({
-      bids: {...bids, [MenuID]: id, [MenuID + '_data']: data}
-    })
+    if (tabs.setting.supModule === MenuID) {
+      if (!data || data[tabs.setting.controlField] === undefined) {
+        this.setState({
+          tabs: {...tabs, subtabs: this.props.config.subtabs}
+        })
+      } else {
+        let val = data[tabs.setting.controlField]
+        this.setState({
+          tabs: {...tabs, subtabs: this.props.config.subtabs.filter(tab => {
+            if (tab.controlVal === val) {
+              return false
+            } else if (/,/ig.test(tab.controlVal)) {
+              return tab.controlVal.split(',').includes(val)
+            }
+            return true
+          })}
+        })
+      }
+    }
   }
 
   autoSwitch = (interval) => {
@@ -101,7 +123,7 @@
       <div className={'menu-antv-tabs-wrap ' + tabs.setting.tabLabel} style={tabs.style}>
         <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}>
           {tabs.subtabs.map(tab => (
-            <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}>
+            <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}>
               <TabTransfer BID={BID} config={tab} bids={bids} mainSearch={mainSearch}/>
             </TabPane>
           ))}

--
Gitblit v1.8.0