From 1a14ff6035932eadfb6ef7970e3adb24b4e158a6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 18 十二月 2019 18:56:17 +0800
Subject: [PATCH] 2019-12-18

---
 src/tabviews/commontable/mutilform/index.jsx |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/tabviews/commontable/mutilform/index.jsx b/src/tabviews/commontable/mutilform/index.jsx
index 096534e..4ceb1e2 100644
--- a/src/tabviews/commontable/mutilform/index.jsx
+++ b/src/tabviews/commontable/mutilform/index.jsx
@@ -9,10 +9,11 @@
 
 class MainSearch extends Component {
   static propTpyes = {
-    action: PropTypes.object, // 鎼滅储鏉′欢鍒楄〃
-    dict: PropTypes.object, // 瀛楀吀椤�
-    data: PropTypes.any, // 琛ㄦ牸鏁版嵁
-    configMap: PropTypes.object
+    action: PropTypes.object,    // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛�
+    dict: PropTypes.object,      // 瀛楀吀椤�
+    data: PropTypes.any,         // 琛ㄦ牸鏁版嵁
+    configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦
+    inputSubmit: PropTypes.func  // input鍥炶溅鎻愪氦
   }
 
   state = {
@@ -22,6 +23,7 @@
   }
 
   componentDidMount () {
+    const { data } = this.props
     let action = JSON.parse(JSON.stringify(this.props.action))
 
     let datatype = {}
@@ -83,12 +85,18 @@
     formlist = formlist.map(item => {
       if (item.type === 'link') {
         let supItem = formlist.filter(form => form.field === item.linkField)[0]
+
+        if (!supItem && data && data.hasOwnProperty(item.linkField)) {
+          supItem = {initval: data[item.linkField]}
+        }
+        
         if (!supItem) {
           error = true
         } else {
           item.options = item.oriOptions.filter(option => option.parentId === supItem.initval)
         }
       }
+
       return item
     })
 
@@ -104,6 +112,13 @@
       readtype: readtype,
       datatype: datatype,
       formlist: formlist
+    }, () => {
+      if (action.setting && action.setting.focus) {
+        let _item = document.getElementById(action.setting.focus)
+        if (_item) {
+          _item.select()
+        }
+      }
     })
   }
 
@@ -187,14 +202,14 @@
           <Col span={24 / cols} key={index}>
             <Form.Item label={item.label}>
               {getFieldDecorator(item.field, {
-                initialValue: item.initval,
+                initialValue: item.initval || 'text',
                 rules: [
                   {
                     required: item.required === 'true',
                     message: this.props.dict['form.required.input'] + item.label + '!'
                   }
                 ]
-              })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)}
+              })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)}
             </Form.Item>
           </Col>
         )
@@ -217,8 +232,8 @@
                 ]
               })(
                 precision === null ?
-                <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} /> :
-                <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} />
+                <InputNumber initialValue={_initval} min={min} max={max} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> :
+                <InputNumber initialValue={_initval} min={min} max={max} precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />
                 )}
             </Form.Item>
           </Col>
@@ -394,9 +409,9 @@
     })
   }
 
-  handleReset = () => {
-    // 閲嶇疆
-    this.props.form.resetFields()
+  handleSubmit = (e) => {
+    e.preventDefault()
+    this.props.inputSubmit()
   }
 
   render() {

--
Gitblit v1.8.0