From 910e22f4bccbe5e5d8951398bd53a7d6d636b852 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 16 十月 2019 11:42:37 +0800
Subject: [PATCH] complete-datamanage

---
 src/tabviews/tabform/index.jsx |   48 +++++++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/src/tabviews/tabform/index.jsx b/src/tabviews/tabform/index.jsx
index 48fefca..17767f1 100644
--- a/src/tabviews/tabform/index.jsx
+++ b/src/tabviews/tabform/index.jsx
@@ -20,28 +20,35 @@
   }
 
   handleOk = () => {
-    this.setState({
-      loading: true
-    })
+    
     this.formRef.handleConfirm().then(res => {
+      this.setState({
+        loading: true
+      })
       let values = []
       this.props.param.formdata.forEach(column => {
         let value = ''
-        if (res[column.FieldName] || res[column.FieldName] === 0) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佽〃鏍兼暟鎹�笺�佸垵濮嬪��
+        if (res.hasOwnProperty(column.FieldName)) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佸垵濮嬪��
           value = res[column.FieldName]
-        } else if (this.state.tabledata && this.state.tabledata[column.FieldName]) {
-          value = this.state.tabledata[column.FieldName]
         } else if (column.InitVal) {
           value = column.InitVal
         }
         values.push(column.FieldName + 'equal\'' + value + '\'')
       })
-      Api.submitInterface({
+
+      let queryparam = { // 璇锋眰鍙傛暟
         func: this.props.param.execAction.AuditProc || this.props.param.defaultproc[this.props.param.execAction.Action],
-        UptLongText: values.join(','), // 琛ㄥ崟鏁版嵁
         ID: (this.props.param.tabledata && this.props.param.primarykey) ? this.props.param.tabledata[this.props.param.primarykey] : '', // 涓婚敭瀛楁
         BID: (this.props.param.tabledata && this.props.param.bidkey) ? this.props.param.tabledata[this.props.param.bidkey] : '' // BID瀛楁
-      }).then(result => {
+      }
+      // 娣诲姞鍜屼慨鏀硅姹傚弬鏁板瓧娈典笉鍚�
+      if (this.props.param.execAction.Action === 'Add') {
+        queryparam.AddLongText = values.join(',')
+      } else if (this.props.param.execAction.Action === 'Update') {
+        queryparam.UptLongText = values.join(',')
+      }
+
+      Api.submitInterface(queryparam).then(result => {
         if (result.status) {
           notification.success({
             top: 92,
@@ -49,24 +56,24 @@
           })
           
           // 鍒锋柊涓诲垪琛ㄩ〉闈�
-          if (this.props.param.execAction.ReloadForm && this.props.param.execAction.ReloadForm !== 'false' && this.props.param.execAction.ReloadForm !== 'singlegrid') {
-            this.props.refreshTabView({
-              MenuNo: this.props.MenuNo,
-              ReloadForm: this.props.param.execAction.ReloadForm
-            })
-          }
+          this.props.refreshTabView({
+            MenuNo: this.props.MenuNo,
+            ReloadForm: this.props.param.execAction.ReloadForm
+          })
 
-          this.handleCancel()
+          if (this.props.param.execAction.BackPre !== 'false') { // 椤甸潰杩斿洖
+            this.handleCancel()
+          }
         } else {
           notification.error({
             top: 92,
             message: result.message,
             duration: 15
           })
+          this.setState({
+            loading: false
+          })
         }
-        this.setState({
-          loading: false
-        })
       })
     }, () => {})
   }
@@ -83,6 +90,9 @@
       return tab.MenuID !== this.props.MenuID
     })
     this.props.modifyTabview(tabs)
+    // 鎻愪氦鎴愬姛鎴栬繑鍥炴椂锛屾粴鍔ㄨ嚦椤堕儴
+    document.body.scrollTop = 0
+    document.documentElement.scrollTop = 0
   }
 
   shouldComponentUpdate (nextProps, nextState) {

--
Gitblit v1.8.0