From 432b788acf901b0720184b8ee8bc81a2e6fa47e0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 28 九月 2021 18:22:02 +0800 Subject: [PATCH] 2021-09-28 --- src/tabviews/custom/components/tree/antd-tree/index.jsx | 50 ++++++++++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 743a5af..889398a 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -57,9 +57,9 @@ sync: _sync }, () => { if (config.setting.sync !== 'true' && config.setting.onload === 'true') { - this.loadData() + this.loadData(null, 'init') } else if (config.setting.sync === 'true' && _data) { - this.handleData() + this.handleData('init') } }) } @@ -77,14 +77,12 @@ } this.setState({sync: false, data: _data}, () => { - this.handleData() + this.handleData('init') }) - } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { - if (config.setting.syncRefresh === 'true') { - this.setState({}, () => { - this.loadData() - }) - } + } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + this.setState({}, () => { + this.loadData() + }) } } @@ -115,7 +113,7 @@ if (!config.timer) return - const _change = { '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } + const _change = { '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 } let timer = _change[config.timer] @@ -182,7 +180,7 @@ /** * @description 鏁版嵁鍔犺浇 */ - async loadData (hastimer) { + async loadData (hastimer, type) { const { mainSearch, menuType } = this.props const { config, arr_field, BID } = this.state @@ -195,21 +193,10 @@ return } - let searches = [] - if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 - let keys = searches.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { - searches.push(item) - } - }) - } + let searches = config.setting.useMSearch && mainSearch ? mainSearch : [] - let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) + let requireFields = searches.filter(item => item.required && item.value === '') if (requireFields.length > 0) { - this.setState({ - loading: false - }) return } @@ -228,7 +215,7 @@ data: result.data, loading: false }, () => { - this.handleData() + this.handleData(type) }) } else { this.setState({ @@ -243,7 +230,7 @@ } } - handleData = () => { + handleData = (type) => { const { data, searchkey, config } = this.state if (!data || data.length === 0) { this.setState({ @@ -290,9 +277,20 @@ } this.setState({ + expandedKeys: _treeNodes[0] ? [_treeNodes[0].$key] : [], treedata: _treedata, treeNodes: _treeNodes, }) + + if (type === 'init' && _treeNodes[0] && config.wrap.selected === 'true') { + this.setState({ + selectedKeys: [_treeNodes[0].$key] + }) + + setTimeout(() => { + MKEmitter.emit('resetSelectLine', config.uuid, _treeNodes[0].$key, '') + }, 200) + } } treeFilter = (value) => { -- Gitblit v1.8.0