From ab60d53b67f802878662aaa5a5b52580cca421b8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 26 九月 2020 08:52:46 +0800
Subject: [PATCH] 2020-09-26

---
 src/menu/searchcomponent/index.jsx |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/menu/searchcomponent/index.jsx b/src/menu/searchcomponent/index.jsx
index 7dd780a..0556145 100644
--- a/src/menu/searchcomponent/index.jsx
+++ b/src/menu/searchcomponent/index.jsx
@@ -5,6 +5,7 @@
 import { Modal, notification } from 'antd'
 import moment from 'moment'
 
+import MKEmitter from '@/utils/events.js'
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/model.js'
@@ -41,6 +42,10 @@
     })
   }
 
+  componentDidMount () {
+    MKEmitter.addListener('addSearch', this.addSearch)
+  }
+
   /**
    * @description 鐩戝惉鍒版悳绱㈡潯浠跺鍒舵椂锛岃Е鍙戞悳绱㈡潯浠剁紪杈�
    */
@@ -50,6 +55,29 @@
     if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) {
       this.setState({searchlist: fromJS(nextProps.config.search).toJS()})
     }
+  }
+
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('addSearch', this.addSearch)
+  }
+
+  addSearch = (cardId, element) => {
+    if (cardId !== this.props.config.uuid) return
+
+    const { searchlist } = this.state
+
+    this.setState({searchlist: [...searchlist, element]})
+    this.handleSearch(element)
   }
 
   /**
@@ -255,19 +283,6 @@
       },
       onCancel() {}
     })
-  }
-
-  /**
-   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
-   */
-  componentWillUnmount () {
-    this.setState = () => {
-      return
-    }
-  }
-
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   render() {

--
Gitblit v1.8.0