From 75623dd039b742dbb44fb4c6b4af563404ed9c7f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 03 二月 2020 16:06:04 +0800
Subject: [PATCH] 2020-02-03

---
 src/tabviews/tableshare/mutilform/index.jsx |   55 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx
index 90be271..b56eea3 100644
--- a/src/tabviews/tableshare/mutilform/index.jsx
+++ b/src/tabviews/tableshare/mutilform/index.jsx
@@ -15,6 +15,7 @@
     action: PropTypes.object,    // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛�
     dict: PropTypes.object,      // 瀛楀吀椤�
     data: PropTypes.any,         // 琛ㄦ牸鏁版嵁
+    BData: PropTypes.any,        // 涓昏〃鏁版嵁
     configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦
     inputSubmit: PropTypes.func  // input鍥炶溅鎻愪氦
   }
@@ -26,7 +27,7 @@
   }
 
   componentDidMount () {
-    const { data } = this.props
+    const { data, BData } = this.props
     let action = JSON.parse(JSON.stringify(this.props.action))
 
     let datatype = {}
@@ -83,7 +84,9 @@
         }
       }
 
-      if (!/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) {
+      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
+        item.initval = BData[item.field]
+      } else if (!/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) {
         item.initval = this.props.data[item.field]
       }
 
@@ -443,16 +446,32 @@
             </Form.Item>
           </Col>
         )
-      } else if (item.type === 'funcvar') {
+      } else if (item.type === 'linkMain') {
         fields.push(
           <Col span={24 / cols} key={index}>
             <Form.Item label={item.label}>
               {getFieldDecorator(item.field, {
-                initialValue: item.linkfield || '',
+                initialValue: item.initval,
+                rules: [
+                  {
+                    required: item.required === 'true',
+                    message: this.props.dict['form.required.input'] + item.label + '!'
+                  }
+                ]
               })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)}
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'funcvar') {
+        // fields.push(
+        //   <Col span={24 / cols} key={index}>
+        //     <Form.Item label={item.label}>
+        //       {getFieldDecorator(item.field, {
+        //         initialValue: item.linkfield || '',
+        //       })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)}
+        //     </Form.Item>
+        //   </Col>
+        // )
       } else if (item.type === 'textarea') {
         let _labelcol = cols !== 3 ? 8 / cols : 3
         let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21
@@ -493,13 +512,23 @@
           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
-            })
+            if (!item.field) return
+
+            if (item.type === 'funcvar') {
+              search.push({
+                type: 'funcvar',
+                readonly: 'true',
+                key: item.field,
+                value: ''
+              })
+            } else if (item.hidden === 'true') {
+              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 => {
@@ -552,8 +581,8 @@
               })
             } else if (this.state.datatype[key] === 'fileupload') {
               let vals = []
-              
-              if (values[key].length > 0) {
+
+              if (values[key] && values[key].length > 0) {
                 values[key].forEach(_val => {
                   if (_val.origin && _val.url) {
                     vals.push(_val.url)

--
Gitblit v1.8.0