From 54d01e6ef9ac31f10de4a0e92824eba50b77eda6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 27 九月 2021 18:40:51 +0800
Subject: [PATCH] 2021-09-27

---
 src/menu/components/search/main-search/index.jsx |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx
index 92fce35..79505bb 100644
--- a/src/menu/components/search/main-search/index.jsx
+++ b/src/menu/components/search/main-search/index.jsx
@@ -76,6 +76,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('submitStyle', this.getStyle)
+    MKEmitter.addListener('plusSearch', this.plusSearch)
   }
 
   /**
@@ -86,6 +87,7 @@
       return
     }
     MKEmitter.removeListener('submitStyle', this.getStyle)
+    MKEmitter.removeListener('plusSearch', this.plusSearch)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -365,10 +367,28 @@
     })
   }
 
-  updatefields = (config) => {
-    this.setState({card: config}, ()=> {
-      this.props.updateConfig(config)
-    })
+  plusSearch = (MenuId, item, type) => {
+    const { card } = this.state
+
+    if (MenuId !== card.uuid) return
+
+    let _card = fromJS(card).toJS()
+
+    if (type === 'simple') {
+      _card.search.push(item)
+      this.setState({
+        card: _card,
+      }, () => {
+        this.props.updateConfig(_card)
+      })
+    } else if (type === 'multil') {
+      _card.search.push(...item)
+      this.setState({
+        card: _card,
+      }, () => {
+        this.props.updateConfig(_card)
+      })
+    }
   }
 
   getWrapForms = () => {
@@ -394,7 +414,7 @@
 
     return (
       <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}>
-        <FieldsComponent config={card} type="search" updatefield={this.updatefields} />
+        <FieldsComponent config={card} type="search" />
         <Switch checkedChildren={dict['model.switch.open']} size="small" unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} />
         <DragElement
           list={card.search}

--
Gitblit v1.8.0