From 4b6a4e2f04f492d770573cf48ca52d4e748a086a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 18 十月 2021 18:30:50 +0800 Subject: [PATCH] 2021-10-18 --- src/tabviews/treepage/index.jsx | 41 ++++++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index c5ef22b..b80863d 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -56,11 +56,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, param, MenuName } = this.props + const { permAction, param, MenuName, MenuID } = this.props let _param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(_param) @@ -70,7 +70,7 @@ try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - config.MenuID = this.props.MenuID + config.MenuID = MenuID config.MenuName = MenuName config.setting.$name = MenuName } catch (e) { @@ -116,6 +116,9 @@ group.sublist = group.sublist.filter(tab => { if (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0)) { tab.isTreeNode = true + } + if (tab.supMenu === 'mainTable') { + tab.supMenu = MenuID } return permAction[tab.linkTab]} ) @@ -408,7 +411,7 @@ } selectTreeNode = (selectedKeys, {selected, node}) => { - const { config } = this.state + const { config, ContainerId } = this.state let _expandedKeys = fromJS(this.state.expandedKeys).toJS() let _data = fromJS(node.props.dataRef).toJS() @@ -434,7 +437,9 @@ }) delete _data.children - this.handleTableId('mainTable', _data.key, _data) + + MKEmitter.emit('changeTableLine', ContainerId, this.props.MenuID, _data.key, _data) + this.setState({ tabgroups: _tabgroups, expandedKeys: _expandedKeys, @@ -469,21 +474,6 @@ }) } - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) - } - reloadData = (menuId) => { const { MenuID } = this.props @@ -508,6 +498,14 @@ this.setShortcut() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -521,6 +519,7 @@ MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) + MKEmitter.addListener('changeTableLine', this.changeTableLine) } /** @@ -534,6 +533,7 @@ MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } changeExpandedKeys = (expandedKeys) => { @@ -622,7 +622,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> : null} </TabPane> ) -- Gitblit v1.8.0