From 9e716f3bd30820a08757845b592db73363faa48c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 25 四月 2022 14:53:37 +0800 Subject: [PATCH] 2022-04-25 --- src/tabviews/custom/components/card/data-card/index.jsx | 48 +++++++++++++++++++++++++++++------------------- 1 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 735190a..3176642 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -115,6 +115,8 @@ let selected = 'false' if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init') { selected = _config.wrap.selected + } else { + _config.wrap.selected = 'false' } if (_data) { @@ -264,7 +266,7 @@ * @param {*} position // 鍒锋柊浣嶇疆 * @param {*} btn // 鎵ц鐨勬寜閽� */ - refreshByButtonResult = (menuId, position, btn, id, lines) => { + refreshByButtonResult = (menuId, position, btn, id = '', lines) => { const { config, BID, supComs, supNodes } = this.state if (config.uuid !== menuId) return @@ -290,16 +292,16 @@ if (lines && lines.length === 1) { this.loadLinedata(lines[0].$$uuid) } else { - this.loadData() + this.loadData(id) } } else if (!btn || btn.resetPageIndex !== 'false') { this.setState({ pageIndex: 1 }, () => { - this.loadData() + this.loadData(id) }) } else { - this.loadData() + this.loadData(id) } } } else { @@ -312,22 +314,22 @@ if (lines && lines.length === 1) { this.loadLinedata(lines[0].$$uuid) } else { - this.loadData() + this.loadData(id) } } else if (position === 'mainline' || position === 'popclose') { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� if (supModule && BID) { MKEmitter.emit('reloadData', supModule, BID) } else { - this.loadData() + this.loadData(id) } } else if (!btn || btn.resetPageIndex !== 'false') { this.setState({ pageIndex: 1 }, () => { - this.loadData() + this.loadData(id) }) } else { - this.loadData() + this.loadData(id) } } } @@ -337,7 +339,7 @@ } } - checkTopLine = () => { + checkTopLine = (id) => { const { config, data } = this.state if (!data || data.length === 0 || data[0].$disabled) { @@ -354,15 +356,23 @@ return } + let index = 0 + if (id) { + index = data.findIndex(item => item.$$uuid === id) + if (index === -1) { + index = 0 + } + } + this.setState({ - activeKey: 0, - selectKeys: [0], - selectedData: [data[0]] + activeKey: index, + selectKeys: [index], + selectedData: [data[index]] }) - MKEmitter.emit('resetSelectLine', config.uuid, data[0].$$uuid, data[0]) + MKEmitter.emit('resetSelectLine', config.uuid, data[index].$$uuid, data[index]) if (config.setting.$hasSyncModule) { - MKEmitter.emit('syncBalconyData', config.uuid, [data[0]], data.length === 1) + MKEmitter.emit('syncBalconyData', config.uuid, [data[index]], data.length === 1) } } @@ -468,7 +478,7 @@ }) } - async loadData () { + async loadData (id) { const { mainSearch, menuType } = this.props const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state @@ -483,9 +493,9 @@ loading: false }) - if (selected !== 'false') { + if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { setTimeout(() => { - this.checkTopLine() + this.checkTopLine(id) }, 200) if (selected === 'init') { this.setState({selected: 'false'}) @@ -528,9 +538,9 @@ start = config.setting.pageSize * (pageIndex - 1) + 1 } - if (selected !== 'false') { + if (selected !== 'false' || (id && config.wrap.selected !== 'false')) { setTimeout(() => { - this.checkTopLine() + this.checkTopLine(id) }, 200) if (selected === 'init') { this.setState({selected: 'false'}) -- Gitblit v1.8.0