From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 21 十月 2021 23:17:08 +0800 Subject: [PATCH] 2021-10-21 --- src/tabviews/formtab/index.jsx | 97 +++++++++++++++--------------------------------- 1 files changed, 31 insertions(+), 66 deletions(-) diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index ed54cf2..f831a71 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -16,7 +16,6 @@ import FormGroup from './formgroup' import FormAction from './actionList' import NotFount from '@/components/404' -import { modifyTabview } from '@/store/action' import './index.scss' const { TabPane } = Tabs @@ -49,11 +48,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction } = this.props + const { permAction, MenuID } = this.props let param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(param) if (result.status) { @@ -104,13 +103,15 @@ config.tabgroups = _tabgroups } - // 鏉冮檺杩囨护 - if (this.props.menuType !== 'HS') { - config.action = config.action.filter(item => permAction[item.uuid]) - config.tabgroups.forEach(group => { - group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) + config.action = config.action.filter(item => permAction[item.uuid]) + config.tabgroups.forEach(group => { + group.sublist = group.sublist.filter(tab => { + if (tab.supMenu === 'mainTable') { + tab.supMenu = MenuID + } + return permAction[tab.linkTab] }) - } + }) // 鎸夐挳绫诲瀷鍏煎 config.action = config.action.map(item => { @@ -142,8 +143,8 @@ primaryId: this.props.param.primaryId || '', data: this.props.param.data || null, BIDs: { - mainTable: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', - mainTabledata: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' + [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', + [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' } }, () => { this.improveSelectOption(config.groups) @@ -341,11 +342,7 @@ this.setState({ data: _data, primaryId: _primaryId, - BIDs: { - ...BIDs, - mainTable: _primaryId, - mainTabledata: _data - } + BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data } }) if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) { @@ -494,11 +491,7 @@ } this.setState({ - BIDs: { - ...BIDs, - mainTable: primaryId, - mainTabledata: data - } + BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data } }) } }) @@ -507,16 +500,7 @@ MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) } - let tabs = this.props.tabviews.filter(tab => { - tab.selected = false - if (tab.MenuID === this.props.param.parentId) { - tab.selected = true - } - - return tab.MenuID !== this.props.MenuID - }) - - this.props.modifyTabview(tabs) + MKEmitter.emit('closeTabView', this.props.MenuID) } else if (type === 'error' && btn.afterExecError === 'notclose') { if (btn.execError === 'refresh') { this.loadmaindata() @@ -525,33 +509,8 @@ if (btn.execError !== 'never') { MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) } - - let tabs = this.props.tabviews.filter(tab => { - tab.selected = false - if (tab.MenuID === this.props.param.parentId) { - tab.selected = true - } - - return tab.MenuID !== this.props.MenuID - }) - - this.props.modifyTabview(tabs) + MKEmitter.emit('closeTabView', this.props.MenuID) } - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) } /** @@ -594,6 +553,14 @@ this.loadmaindata() } + 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() @@ -604,8 +571,9 @@ } componentDidMount () { - MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('changeTableLine', this.changeTableLine) } /** @@ -616,8 +584,9 @@ return } - MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } render() { @@ -673,7 +642,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> </TabPane> ) @@ -682,7 +650,7 @@ ) }) } - {this.props.menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} + {this.props.menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) @@ -692,15 +660,12 @@ const mapStateToProps = (state) => { return { menuType: state.editLevel, - tabviews: state.tabviews, permAction: state.permAction } } -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