From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 十月 2021 23:17:08 +0800
Subject: [PATCH] 2021-10-21

---
 src/menu/components/search/main-search/index.jsx |   50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx
index 91421d3..dd3f54d 100644
--- a/src/menu/components/search/main-search/index.jsx
+++ b/src/menu/components/search/main-search/index.jsx
@@ -10,15 +10,17 @@
 import enUS from '@/locales/en-US/model.js'
 import { getSearchForm } from '@/templates/zshare/formconfig'
 import { resetStyle } from '@/utils/utils-custom.js'
+import asyncComponent from '@/utils/asyncComponent'
 import asyncIconComponent from '@/utils/asyncIconComponent'
 import DragElement from './dragsearch'
+import getWrapForm from './options'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { confirm } = Modal
 
-const WrapComponent = asyncIconComponent(() => import('./wrapsetting'))
-const FieldsComponent = asyncIconComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
+const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
+const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
 const SearchForm = asyncIconComponent(() => import('@/templates/sharecomponent/searchcomponent/searchform'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
@@ -75,6 +77,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('submitStyle', this.getStyle)
+    MKEmitter.addListener('plusSearch', this.plusSearch)
   }
 
   /**
@@ -85,6 +88,7 @@
       return
     }
     MKEmitter.removeListener('submitStyle', this.getStyle)
+    MKEmitter.removeListener('plusSearch', this.plusSearch)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -364,10 +368,38 @@
     })
   }
 
-  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 = () => {
+    const { wrap, action } = this.state.card
+
+    return getWrapForm(wrap, action)
+  }
+
+  updateWrap = (res) => {
+    this.updateComponent({...this.state.card, wrap: res})
   }
 
   clickComponent = (e) => {
@@ -383,7 +415,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}
@@ -396,7 +428,9 @@
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
             <Icon className="plus" title="娣诲姞" onClick={this.addSearch} type="plus" />
-            <WrapComponent config={card} updateConfig={this.updateComponent}/>
+            <NormalForm title="鎼滅储璁剧疆" width={800} update={this.updateWrap} getForms={this.getWrapForms}>
+              <Icon type="edit" style={{color: '#1890ff'}} title="缂栬緫"/>
+            </NormalForm>
             <CopyComponent type="mainsearch" card={card}/>
             <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} />
             <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" />

--
Gitblit v1.8.0