From da7068bd48791cdee966c786ce0dfd46f6e03df9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 08 一月 2021 19:02:24 +0800 Subject: [PATCH] 2021-01-08 --- src/tabviews/custom/components/card/table-card/index.jsx | 57 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 5552c95..a557611 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -102,9 +102,10 @@ } componentDidMount () { - MKEmitter.addListener('syncRefreshComponentId', this.reload) + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('getexceloutparam', this.getexceloutparam) + MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) } shouldComponentUpdate (nextProps, nextState) { @@ -115,9 +116,10 @@ this.setState = () => { return } - MKEmitter.removeListener('syncRefreshComponentId', this.reload) + MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('getexceloutparam', this.getexceloutparam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } /** @@ -149,6 +151,31 @@ } } + /** + * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� + * @param {*} menuId // 鑿滃崟Id + * @param {*} position // 鍒锋柊浣嶇疆 + * @param {*} btn // 鎵ц鐨勬寜閽� + */ + refreshByButtonResult = (menuId, position, btn) => { + const { config, BID } = this.state + + if (config.uuid !== menuId) return + + this.loadData(btn) // 鏁版嵁鍒锋柊 + + if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) { + MKEmitter.emit('reloadData', btn.syncComponentId) // 鍚岀骇鏍囩鍒锋柊 + } + + if (position === 'mainline' && config.setting.supModule) { // 涓昏〃琛屽埛鏂� + MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) + } else if (position === 'popclose') { // 鏍囩鍏抽棴鍒锋柊 + config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) + btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) + } + } + resetParentParam = (MenuID, id) => { const { config } = this.state @@ -160,16 +187,12 @@ } } - reload = (syncId) => { + reloadData = (menuId) => { const { config } = this.state - if (syncId && syncId !== config.uuid) return + if (config.uuid !== menuId) return - this.setState({ - pageIndex: 1 - }, () => { - this.loadData() - }) + this.loadData() } /** @@ -259,20 +282,6 @@ } } - updateStatus = (type, position, btn) => { - const { config } = this.state - - if (type === 'refresh' && position === 'grid') { - this.loadData() - if (btn && btn.syncComponent && btn.syncComponent[0]) { - let syncId = btn.syncComponent.slice(-1)[0] - if (config.uuid !== syncId) { - MKEmitter.emit('syncRefreshComponentId', syncId) - } - } - } - } - changePageIndex = (page) => { this.setState({ pageIndex: page @@ -312,7 +321,7 @@ line.push( <Col key={index} span={24}> <div className="card-item-box" style={item.style}> - <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements} updateStatus={this.updateStatus}/> + <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements}/> </div> </Col> ) -- Gitblit v1.8.0