From a0a285c90987eb9b1591f90333f3aeb15659ded2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 17 一月 2020 19:04:57 +0800
Subject: [PATCH] 2020-01-17

---
 src/tabviews/tableshare/mutilform/index.jsx |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx
index 064cd74..8e141ae 100644
--- a/src/tabviews/tableshare/mutilform/index.jsx
+++ b/src/tabviews/tableshare/mutilform/index.jsx
@@ -139,7 +139,7 @@
     })
   }
 
-  resetform = (formlist, supfields, index) => {
+  resetform = (formlist, supfields, index, fieldsvalue) => {
     index++
     let subfields = []
 
@@ -148,7 +148,8 @@
         if (item.type === 'link' && item.linkField === supfield.field) {
           item.options = item.oriOptions.filter(option => option.parentId === supfield.initval)
           item.initval = item.options[0] ? item.options[0].Value : ''
-          item.hiden = true
+
+          fieldsvalue[item.field] = item.initval
   
           subfields.push(item)
         }
@@ -157,9 +158,10 @@
     })
 
     if (subfields.length === 0 || index > 6) {
+      this.props.form.setFieldsValue(fieldsvalue)
       return formlist
     } else {
-      return this.resetform(formlist, subfields, index)
+      return this.resetform(formlist, subfields, index, fieldsvalue)
     }
   }
 
@@ -167,11 +169,13 @@
     let formlist = JSON.parse(JSON.stringify(this.state.formlist))
 
     let subfields = []
+    let fieldsvalue = {}
     formlist = formlist.map(item => {
       if (item.type === 'link' && item.linkField === _field.field) {
         item.options = item.oriOptions.filter(option => option.parentId === value)
         item.initval = item.options[0] ? item.options[0].Value : ''
-        item.hiden = true
+
+        fieldsvalue[item.field] = item.initval
 
         subfields.push(item)
       }
@@ -190,16 +194,10 @@
 
     if (subfields.length === 0) return
 
-    formlist = this.resetform(formlist, subfields, 0)
+    formlist = this.resetform(formlist, subfields, 0, fieldsvalue)
+
     this.setState({
       formlist: formlist
-    }, () => {
-      this.setState({
-        formlist: formlist.map(item => {
-          item.hiden = false
-          return item
-        })
-      })
     })
   }
 
@@ -226,8 +224,8 @@
     }
 
     this.state.formlist.forEach((item, index) => {
-      if ((!item.field && item.type !== 'title') || item.hiden) return
-
+      if ((!item.field && item.type !== 'title') || item.hidden === 'true') return
+      
       if (item.type === 'title') {
         fields.push(
           <Col span={24} key={index}>
@@ -500,6 +498,17 @@
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
           let search = []
+          // 闅愯棌琛ㄥ崟
+          this.state.formlist.forEach(item => {
+            if (item.hidden !== 'true' || !item.field) return
+            search.push({
+              type: this.state.datatype[item.field],
+              readonly: this.state.readtype[item.field],
+              key: item.field,
+              value: item.initval
+            })
+          })
+
           Object.keys(values).forEach(key => {
             if (this.state.datatype[key] === 'datetime') {
               let _value = ''

--
Gitblit v1.8.0