From efad1f9eff8d6af31f5b15edceee7b855b3db957 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 十二月 2021 00:00:28 +0800 Subject: [PATCH] 2021-12-22 --- src/tabviews/custom/components/tree/antd-tree/index.jsx | 34 ++++++++++++++++++++++++---------- 1 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 7ead72b..ebbd2d7 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -49,6 +49,8 @@ _sync = false } + _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%' + this.setState({ config: _config, data: _data, @@ -57,9 +59,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,7 +79,7 @@ } this.setState({sync: false, data: _data}, () => { - this.handleData() + this.handleData('init') }) } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({}, () => { @@ -170,7 +172,7 @@ const { config } = this.state if (!config.setting.supModule || config.setting.supModule !== MenuID) return - if (id !== this.state.BID) { + if (id !== this.state.BID || id !== '') { this.setState({ BID: id }, () => { this.loadData() }) @@ -180,7 +182,7 @@ /** * @description 鏁版嵁鍔犺浇 */ - async loadData (hastimer) { + async loadData (hastimer, type) { const { mainSearch, menuType } = this.props const { config, arr_field, BID } = this.state @@ -215,7 +217,7 @@ data: result.data, loading: false }, () => { - this.handleData() + this.handleData(type) }) } else { this.setState({ @@ -230,7 +232,7 @@ } } - handleData = () => { + handleData = (type) => { const { data, searchkey, config } = this.state if (!data || data.length === 0) { this.setState({ @@ -252,14 +254,14 @@ logMap.set(val, true) if (pval === config.wrap.mark) { parentNodes.push({ - // ...item, + ...item, $title: item[config.wrap.labelField] || '', $key: val, $parentId: '' }) } else if (pval) { _options.push({ - // ...item, + ...item, $title: item[config.wrap.labelField] || '', $key: val, $parentId: pval @@ -277,9 +279,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) => { @@ -405,6 +418,7 @@ } if (selected) { + delete _data.children MKEmitter.emit('resetSelectLine', config.uuid, (_data ? _data.$key : ''), _data) } @@ -429,7 +443,7 @@ <span className="title">{config.wrap.title}</span> {config.wrap.searchable === 'true' ? <Search allowClear onSearch={this.treeFilter} /> : null} </div> : null} - {treeNodes && treeNodes.length > 0 ? <div className="tree-box"> + {treeNodes && treeNodes.length > 0 ? <div className="tree-box" style={{height: config.wrap.contentHeight}}> <Tree blockNode onSelect={this.selectTreeNode} -- Gitblit v1.8.0