From aaaf56d7ca060f7c681d6b8a67aac46aa89a4dbc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 09 五月 2020 14:50:39 +0800
Subject: [PATCH] 2020-05-09

---
 src/tabviews/zshare/topSearch/index.jsx |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx
index 2844062..5281aba 100644
--- a/src/tabviews/zshare/topSearch/index.jsx
+++ b/src/tabviews/zshare/topSearch/index.jsx
@@ -21,6 +21,7 @@
     label: null,            // 鎻愮ず鏂囧瓧
     required: null,         // 鏄惁蹇呭~
     searchlist: null,       // 鎼滅储椤�
+    groups: null,           // 缁勫悎鎼滅储椤�
     formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id
   }
 
@@ -51,6 +52,7 @@
       _list.push(item)
     })
 
+    let _groups = []
     _list = _list.map(item => {
       if (item.type === 'link') {
         let supItem = _list.filter(form => form.field === item.linkField)[0]
@@ -64,6 +66,8 @@
         } else {
           item.options = item.oriOptions.filter(option => option.parentId === supItem.initval)
         }
+      } else if (item.type === 'group') {
+        _groups.push(JSON.parse(JSON.stringify(item)))
       }
 
       return item
@@ -74,7 +78,8 @@
       label: label,
       style: style,
       required: required,
-      searchlist: _list
+      searchlist: _list,
+      groups: _groups
     })
   }
 
@@ -240,6 +245,7 @@
                 <Select
                   showSearch
                   mode="multiple"
+                  onChange={this.searchChange}
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   getPopupContainer={() => document.getElementById(this.state.formId)}
                 >
@@ -343,8 +349,8 @@
       } else if (item.type === 'group') {
         fields.push(
           <Col span={item.ratio || 6} key={index}>
-            <Form.Item label={item.label} className={item.required ? 'group-required' : ''}>
-              <DateGroup card={item} />
+            <Form.Item label={item.label} className={item.required === 'true' ? 'group-required' : ''}>
+              <DateGroup ref={item.uuid} card={item} onGroupChange={this.searchChange} />
             </Form.Item>
           </Col>
         )
@@ -385,16 +391,29 @@
     })
   }
 
+  /**
+   * @description 鎼滅储鏉′欢閲嶇疆
+   */
   handleReset = () => {
-    // 閲嶇疆
+    const { groups } = this.state
+
+    if (groups.length > 0) {
+      groups.forEach(item => {
+        this.refs[item.uuid].reset()
+      })
+    }
     this.props.form.resetFields()
     this.props.form.validateFields((err, values) => {
-      let searches = this.getFieldsValues(values)
-      this.props.refreshdata(searches)
+      // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁�
+      this.setState({}, () => {
+        let searches = this.getFieldsValues(values)
+        this.props.refreshdata(searches)
+      })
     })
   }
 
   getFieldsValues = (values) => {
+    const { groups } = this.state
     // 鑾峰彇鎼滅储鏉′欢鍊�
     let search = []
     Object.keys(values).forEach(key => {
@@ -432,6 +451,14 @@
         required: this.state.required[key]
       })
     })
+
+    if (groups.length > 0) {
+      groups.forEach(item => {
+        let items = this.refs[item.uuid].getSearchItems()
+        search.push(...items)
+      })
+    }
+
     return search
   }
 

--
Gitblit v1.8.0