From d3a618f09ab510de5c4ca772c44f60c218b61964 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 18 九月 2021 15:12:30 +0800
Subject: [PATCH] 2021-09-18

---
 src/tabviews/custom/components/tree/antd-tree/index.jsx |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 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..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,7 +77,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({}, () => {
@@ -180,7 +180,7 @@
   /**
    * @description 鏁版嵁鍔犺浇
    */
-  async loadData (hastimer) {
+  async loadData (hastimer, type) {
     const { mainSearch, menuType } = this.props
     const { config, arr_field, BID } = this.state
 
@@ -215,7 +215,7 @@
         data: result.data,
         loading: false
       }, () => {
-        this.handleData()
+        this.handleData(type)
       })
     } else {
       this.setState({
@@ -230,7 +230,7 @@
     }
   }
 
-  handleData = () => {
+  handleData = (type) => {
     const { data, searchkey, config } = this.state
     if (!data || data.length === 0) {
       this.setState({
@@ -277,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