From 42fae277ae5ebe794fc070bf38482a919eb661fc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 25 十一月 2020 14:36:02 +0800
Subject: [PATCH] 2020-11-25

---
 src/templates/sharecomponent/searchcomponent/index.jsx |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx
index 6c70ffb..73306fc 100644
--- a/src/templates/sharecomponent/searchcomponent/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/index.jsx
@@ -18,10 +18,7 @@
 
 class SearchComponent extends Component {
   static propTpyes = {
-    menu: PropTypes.object,          // 褰撳墠鑿滃崟淇℃伅
     config: PropTypes.object,        // 閰嶇疆淇℃伅
-    pasteContent: PropTypes.object,  // 绮樿创閰嶇疆淇℃伅
-    sysRoles: PropTypes.array,       // 瑙掕壊鍒楄〃锛岄粦鍚嶅崟
     updatesearch: PropTypes.func     // 鏇存柊
   }
 
@@ -48,10 +45,12 @@
   UNSAFE_componentWillReceiveProps (nextProps) {
     const { searchlist } = this.state
 
-    if (nextProps.pasteContent && nextProps.pasteContent.copyType === 'search') {
-      this.setState({searchlist: [...searchlist, nextProps.pasteContent]})
-      this.handleSearch(nextProps.pasteContent)
-    } else if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) {
+    if (!is(fromJS(nextProps.config.search), fromJS(this.props.config.search)) && !is(fromJS(nextProps.config.search), fromJS(searchlist))) {
+      let len = nextProps.config.search.length
+      let item = nextProps.config.search[len - 1]
+      if (item.copyType && item.focus) {
+        this.handleSearch(item)
+      }
       this.setState({searchlist: fromJS(nextProps.config.search).toJS()})
     }
   }
@@ -91,7 +90,7 @@
     this.setState({
       visible: true,
       card: card,
-      formlist: getSearchForm(card, this.props.sysRoles, linkableFields)
+      formlist: getSearchForm(card, linkableFields)
     })
   }
 
@@ -99,18 +98,18 @@
    * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎
    */
   editModalCancel = () => {
-    const { card } = this.state
+    const { config } = this.props
+    const { card, searchlist } = this.state
 
     if (card.focus) {
-      let searchlist = fromJS(this.state.searchlist).toJS()
-
-      searchlist = searchlist.filter(item => item.uuid !== card.uuid)
+      let _searchlist = searchlist.filter(item => item.uuid !== card.uuid)
 
       this.setState({
         card: null,
-        searchlist: searchlist,
+        searchlist: _searchlist,
         visible: false
       })
+      this.props.updatesearch({...config, search: _searchlist})
     } else {
       this.setState({
         card: null,

--
Gitblit v1.8.0