From 37a134bd23ec4b227a0e010b08a1a89c2bbaaa0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 03 十一月 2020 17:10:14 +0800
Subject: [PATCH] 2020-11-03

---
 src/menu/components/search/main-search/index.jsx |   72 ++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx
index 8fd76f9..7a700dc 100644
--- a/src/menu/components/search/main-search/index.jsx
+++ b/src/menu/components/search/main-search/index.jsx
@@ -130,15 +130,16 @@
   /**
    * @description 鎼滅储鏉′欢椤哄簭璋冩暣锛屾垨鎷栨嫿娣诲姞
    */
-  handleList = (list, card) => {
-    const { config } = this.props
+  handleList = (list, newcell) => {
+    const { card } = this.state
+    let _card = {...card, search: list}
 
-    if (card) {
-      this.setState({searchlist: list})
-      this.handleSearch(card)
+    if (newcell) {
+      this.setState({card: _card})
+      this.handleSearch(newcell)
     } else {
-      this.setState({searchlist: list}, ()=> {  
-        this.props.updatesearch({...config, search: list})
+      this.setState({card: _card}, ()=> {  
+        this.props.updateConfig(_card)
       })
     }
   }
@@ -170,21 +171,19 @@
    * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎
    */
   editModalCancel = () => {
-    const { card } = this.state
+    const { card, editcard } = this.state
 
-    if (card.focus) {
-      let searchlist = fromJS(this.state.searchlist).toJS()
-
-      searchlist = searchlist.filter(item => item.uuid !== card.uuid)
+    if (editcard.focus) {
+      card.search = card.search.filter(item => item.uuid !== editcard.uuid)
 
       this.setState({
-        card: null,
-        searchlist: searchlist,
+        card: card,
+        editcard: null,
         visible: false
       })
     } else {
       this.setState({
-        card: null,
+        editcard: null,
         visible: false
       })
     }
@@ -192,22 +191,17 @@
 
   /**
    * @description 鎼滅储淇敼鍚庢彁浜や繚瀛�
-   * 1銆佸幓闄ょ郴缁熼粯璁ゆ悳绱㈡潯浠�
-   * 2銆佸瓧娈靛強鎻愮ず鏂囧瓧閲嶅鏍¢獙
-   * 3銆佹洿鏂颁笅鎷夎彍鍗曞彲閫夐泦鍚�
-   * 4銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉
+   * 1銆佸瓧娈靛強鎻愮ず鏂囧瓧閲嶅鏍¢獙
+   * 2銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉
    */
   handleSubmit = () => {
-    const { config } = this.props
-    let _searchlist = fromJS(this.state.searchlist).toJS()
+    let card = fromJS(this.state.card).toJS()
 
     this.searchFormRef.handleConfirm().then(res => {
       let fieldrepet = false // 瀛楁閲嶅
       let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅
 
-      _searchlist = _searchlist.filter(item => !item.origin || item.uuid === res.uuid) // 鍘婚櫎绯荤粺椤�
-
-      _searchlist = _searchlist.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴�
+      card.search = card.search.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴�
         if (item.uuid !== res.uuid && res.field && item.field) {
           let itemFields = []
           if (item.type === 'text') {
@@ -259,7 +253,7 @@
         return
       }
 
-      if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) {
+      if (['select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) {
         this.setState({
           sqlVerifing: true
         })
@@ -282,11 +276,11 @@
         Api.getLocalConfig(param).then(result => {
           if (result.status) {
             this.setState({
+              card: card,
               sqlVerifing: false,
-              searchlist: _searchlist,
               visible: false
             }, ()=> {
-              this.props.updatesearch({...config, search: _searchlist})
+              this.props.updateConfig(card)
             })
           } else {
             this.setState({sqlVerifing: false})
@@ -298,10 +292,10 @@
         })
       } else {
         this.setState({
-          searchlist: _searchlist,
+          card: card,
           visible: false
         }, ()=> { 
-          this.props.updatesearch({...config, search: _searchlist})
+          this.props.updateConfig(card)
         })
       }
     })
@@ -310,22 +304,20 @@
   /**
    * @description 鎼滅储鏉′欢鍒犻櫎
    */
-  deleteElement = (card) => {
-    const { config } = this.props
+  deleteElement = (cell) => {
     const { dict } = this.state
     let _this = this
 
     confirm({
-      content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋,
+      content: dict['model.confirm'] + dict['model.delete'] + ` - ${cell.label} 锛焋,
       onOk() {
-        let _searchlist = fromJS(_this.state.searchlist).toJS()
-
-        _searchlist = _searchlist.filter(item => item.uuid !== card.uuid)
+        let _card = fromJS(_this.state.card).toJS()
+        _card.search = _card.search.filter(item => item.uuid !== cell.uuid)
 
         _this.setState({
-          searchlist: _searchlist
+          card: _card
         }, () => {
-          _this.props.updatesearch({...config, search: _searchlist})
+          _this.props.updateConfig(_card)
         })
       },
       onCancel() {}
@@ -346,7 +338,9 @@
     }
     card.search.push(item)
 
-    this.setState({card})
+    this.setState({card}, () => {
+      this.handleSearch(item)
+    })
   }
 
   render() {
@@ -384,7 +378,7 @@
         >
           <SearchForm
             dict={dict}
-            card={this.state.card}
+            card={this.state.editcard}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
             wrappedComponentRef={(inst) => this.searchFormRef = inst}

--
Gitblit v1.8.0