From 95afd40fc2741ac0ce59c2091f6cfce1f98877d4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 24 六月 2021 09:15:45 +0800
Subject: [PATCH] 2021-06-24

---
 src/tabviews/zshare/topSearch/index.jsx |  131 +++++++++++++++++++++----------------------
 1 files changed, 63 insertions(+), 68 deletions(-)

diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx
index be6e6fe..0401534 100644
--- a/src/tabviews/zshare/topSearch/index.jsx
+++ b/src/tabviews/zshare/topSearch/index.jsx
@@ -7,6 +7,7 @@
 import Api from '@/api'
 import options from '@/store/options.js'
 import DateGroup from '@/tabviews/zshare/dategroup'
+import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import Utils from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -16,6 +17,7 @@
 const { MonthPicker, WeekPicker, RangePicker } = DatePicker
 
 const MutilForm = asyncSpinComponent(() => import('./advanceform'))
+const CheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard'))
 
 class MainSearch extends Component {
   static propTpyes = {
@@ -96,7 +98,7 @@
 
       item.required = item.required === 'true'
 
-      if (['select', 'link', 'multiselect'].includes(item.type)) {
+      if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type)) {
         if (item.setAll === 'true' && item.type !== 'multiselect') {
           item.options.unshift({
             key: Utils.getuuid(),
@@ -382,41 +384,51 @@
       delete result.message
       delete result.status
 
-      let _searchlist = this.state.searchlist.map(item => {
-        if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
-          let options = result[item.field].map(cell => {
-            let _item = {
-              key: Utils.getuuid(),
-              Value: cell[item.valueField],
-              Text: cell[item.valueText]
-            }
+      this.resetSearch(result)
+    })
+  }
 
-            if (item.type === 'link') {
-              _item.ParentID = cell[item.linkField]
-            }
-
-            return _item
-          })
-
-          item.oriOptions = [...item.oriOptions, ...options]
-        }
-        return item
-      })
-
-      this.setState({
-        searchlist: _searchlist.map(item => {
-          if (item.type === 'link') {
-            if (item.supInitVal) {
-              item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
-            } else {
-              item.options = item.oriOptions
-            }
-          } else if (item.type === 'select' || item.type === 'multiselect') {
-            item.options = item.oriOptions
+  resetSearch = (result) => {
+    let _searchlist = this.state.searchlist.map(item => {
+      if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
+        let options = result[item.field].map(cell => {
+          let _item = {
+            key: Utils.getuuid()
           }
 
-          return item
+          if (item.type !== 'checkcard') {
+            _item.Value = cell[item.valueField]
+            _item.Text = cell[item.valueText]
+          } else {
+            _item.$value = cell[item.cardValField]
+            _item = {..._item, ...cell}
+          }
+
+          if (item.type === 'link') {
+            _item.ParentID = cell[item.linkField]
+          }
+
+          return _item
         })
+
+        item.oriOptions = [...item.oriOptions, ...options]
+      }
+      return item
+    })
+
+    this.setState({
+      searchlist: _searchlist.map(item => {
+        if (item.type === 'link') {
+          if (item.supInitVal) {
+            item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
+          } else {
+            item.options = item.oriOptions
+          }
+        } else if (item.type === 'select' || item.type === 'multiselect' || item.type === 'checkcard') {
+          item.options = item.oriOptions
+        }
+
+        return item
       })
     })
   }
@@ -468,42 +480,7 @@
       delete result.message
       delete result.status
 
-      let _searchlist = this.state.searchlist.map(item => {
-        if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
-          let options = result[item.field].map(cell => {
-            let _item = {
-              key: Utils.getuuid(),
-              Value: cell[item.valueField],
-              Text: cell[item.valueText]
-            }
-
-            if (item.type === 'link') {
-              _item.ParentID = cell[item.linkField]
-            }
-
-            return _item
-          })
-
-          item.oriOptions = [...item.oriOptions, ...options]
-        }
-        return item
-      })
-
-      this.setState({
-        searchlist: _searchlist.map(item => {
-          if (item.type === 'link') {
-            if (item.supInitVal) {
-              item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '')
-            } else {
-              item.options = item.oriOptions
-            }
-          } else if (item.type === 'select' || item.type === 'multiselect') {
-            item.options = item.oriOptions
-          }
-
-          return item
-        })
-      })
+      this.resetSearch(result)
     })
   }
 
@@ -748,6 +725,24 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'checkcard') { // 澶氶�夋
+        fields.push(
+          <Col span={item.ratio || 6} key={index}>
+            <Form.Item label={item.labelShow !== 'false' ? item.label : ''}>
+              {getFieldDecorator(item.field, {
+                initialValue: item.initval,
+                rules: [
+                  {
+                    required: item.required,
+                    message: dict['form.required.select'] + item.label + '!'
+                  }
+                ]
+              })(
+                <CheckCard card={item} onChange={this.searchChange} />
+              )}
+            </Form.Item>
+          </Col>
+        )
       }
     })
 

--
Gitblit v1.8.0