From b5364600d98c8749caba625ec813d4fe670d0a19 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 十二月 2021 17:29:55 +0800 Subject: [PATCH] 2021-12-16 --- src/tabviews/custom/components/card/data-card/index.jsx | 85 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 69 insertions(+), 16 deletions(-) diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index d608b7c..2bbbf72 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -41,7 +41,9 @@ total: null, precards: [], nextcards: [], - selected: 'false' + selected: 'false', + supNodes: [], + supComs: null } UNSAFE_componentWillMount () { @@ -144,7 +146,13 @@ return item }) + let supComs = null + if (_config.wrap.supType === 'multi') { + supComs = _config.supNodes.map(item => item.componentId) + } + this.setState({ + supComs, selected, precards, nextcards, @@ -227,7 +235,7 @@ * @param {*} btn // 鎵ц鐨勬寜閽� */ refreshByButtonResult = (menuId, position, btn, id, lines) => { - const { config, BID } = this.state + const { config, BID, supComs, supNodes } = this.state if (config.uuid !== menuId) return @@ -243,15 +251,38 @@ this.loadData() } - 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) + if (supComs) { + if (btn.syncComponentId && btn.syncComponentId !== config.uuid && !supComs.includes(btn.syncComponentId)) { + MKEmitter.emit('reloadData', btn.syncComponentId) // 鍚岀骇鏍囩鍒锋柊 + } + + if (position === 'mainline' || position === 'popclose') { // 涓昏〃琛屽埛鏂� + let supNode = supNodes[supNodes.length - 1] + supComs.forEach((item, i) => { + setTimeout(() => { + if (supNode && supNode.key === item) { + MKEmitter.emit('reloadData', item, supNode.value) + } else { + MKEmitter.emit('reloadData', item) + } + }, i * 10) + }) + if (position === 'popclose') { // 鏍囩鍏抽棴鍒锋柊 + btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) + } + } + } else { + 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) + } } } @@ -327,13 +358,35 @@ } resetParentParam = (MenuID, id, data) => { - const { config } = this.state + const { config, supComs } = this.state - if (!config.setting.supModule || config.setting.supModule !== MenuID) return - if (id !== this.state.BID || id !== '') { - this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { - this.loadData() - }) + if (supComs) { + if (!supComs.includes(MenuID)) return + + let supNodes = this.state.supNodes.filter(item => item.key !== MenuID) + let bid = '' + let _data = null + + if (id) { + supNodes.push({key: MenuID, value: id, data}) + } + if (supNodes.length > 0) { + bid = supNodes[supNodes.length - 1].value + _data = supNodes[supNodes.length - 1].data + } + + if (bid !== this.state.BID || bid !== '') { + this.setState({ BID: bid, BData: _data, pageIndex: 1 }, () => { + this.loadData() + }) + } + } else { + if (!config.setting.supModule || config.setting.supModule !== MenuID) return + if (id !== this.state.BID || id !== '') { + this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { + this.loadData() + }) + } } } -- Gitblit v1.8.0