From 84804b405cb88f659d055b16eb3bd00b813ccb4a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 10 十二月 2020 10:58:38 +0800 Subject: [PATCH] 2020-12-10 --- src/tabviews/custom/components/tabs/antv-tabs/index.jsx | 35 +++++++++++++++++++++++++---------- 1 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx index b6f55f1..1e004a5 100644 --- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx +++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx @@ -4,7 +4,7 @@ import { Tabs, Icon } from 'antd' import asyncComponent from '@/utils/asyncComponent' - +import MKEmitter from '@/utils/events.js' import './index.scss' const TabTransfer = asyncComponent(() => import('../../share/tabtransfer')) @@ -12,7 +12,7 @@ class antvBarLineChart extends Component { static propTpyes = { - BID: PropTypes.any, // 鐖剁骇Id + bids: PropTypes.any, // 鐖剁骇Id闆� config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 menuType: PropTypes.any, // 鑿滃崟绫诲瀷 @@ -20,22 +20,26 @@ state = { tabs: null, - parentIds: [] + parentIds: [], + bids: {} } UNSAFE_componentWillMount () { - const { config } = this.props + const { config, bids } = this.props this.setState({ tabs: config, - parentIds: config.parentIds || [] + parentIds: config.parentIds || [], + bids: bids ? bids : {} }) } shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } - componentDidMount () {} + componentDidMount () { + MKEmitter.addListener('resetSelectLine', this.resetParentParam) + } /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 @@ -44,18 +48,29 @@ this.setState = () => { return } + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) + } + + resetParentParam = (MenuID, id) => { + const { parentIds, bids } = this.state + + if (!parentIds.includes(MenuID)) return + + this.setState({ + bids: {...bids, [MenuID]: id} + }) } render() { - const { BID, mainSearch } = this.props - const { tabs } = this.state + const { mainSearch } = this.props + const { tabs, bids } = this.state return ( <div className="menu-antv-tabs-wrap" style={tabs.style}> <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> {tabs.subtabs.map(tab => ( <TabPane tab={<span>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}> - <TabTransfer config={tab} BID={BID} mainSearch={mainSearch}/> + <TabTransfer config={tab} bids={bids} mainSearch={mainSearch}/> </TabPane> ))} </Tabs> -- Gitblit v1.8.0