From 8904592cf12f091aece5d6fc564fd8478fc8988b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 13 二月 2020 20:04:56 +0800
Subject: [PATCH] 2020-02-13

---
 src/tabviews/tableshare/actionList/index.jsx |  109 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 96 insertions(+), 13 deletions(-)

diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx
index 9bfa175..5f897b6 100644
--- a/src/tabviews/tableshare/actionList/index.jsx
+++ b/src/tabviews/tableshare/actionList/index.jsx
@@ -3,6 +3,7 @@
 import moment from 'moment'
 import { Button, Affix, Modal, notification, Spin, message } from 'antd'
 import MutilForm from '@/tabviews/tableshare/mutilform'
+import ExcelIn from '../excelin'
 import Utils from '@/utils/utils.js'
 import Api from '@/api'
 import './index.scss'
@@ -11,17 +12,19 @@
 
 class MainAction extends Component {
   static propTpyes = {
-    BID: PropTypes.string,         // 涓昏〃ID
-    BData: PropTypes.any,          // 涓昏〃鏁版嵁
-    Tab: PropTypes.any,            // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭�
-    type: PropTypes.string,        // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛�
-    MenuID: PropTypes.string,      // 鑿滃崟ID
-    actions: PropTypes.array,      // 鎸夐挳缁�
-    logcolumns: PropTypes.array,   // 鏃ュ織涓樉绀哄垪
-    dict: PropTypes.object,        // 瀛楀吀椤�
-    setting: PropTypes.any,        // 椤甸潰閫氱敤璁剧疆
-    ContainerId: PropTypes.any,    // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
-    triggerPopview: PropTypes.func // 寮圭獥鏍囩椤佃Е鍙�
+    BID: PropTypes.string,            // 涓昏〃ID
+    BData: PropTypes.any,             // 涓昏〃鏁版嵁
+    Tab: PropTypes.any,               // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭�
+    type: PropTypes.string,           // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛�
+    MenuID: PropTypes.string,         // 鑿滃崟ID
+    actions: PropTypes.array,         // 鎸夐挳缁�
+    logcolumns: PropTypes.array,      // 鏃ュ織涓樉绀哄垪
+    dict: PropTypes.object,           // 瀛楀吀椤�
+    setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
+    ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
+    refreshdata: PropTypes.func,      // 鎵ц瀹屾垚鍚庢暟鎹埛鏂�
+    triggerPopview: PropTypes.func,   // 寮圭獥鏍囩椤佃Е鍙�
+    gettableselected: PropTypes.func  // 鑾峰彇琛ㄦ牸涓暟鎹�
   }
 
   state = {
@@ -113,6 +116,16 @@
     } else if (item.OpenType === 'excelOut') {
       this.setState({loadingUuid: item.uuid})
       this.refreshdata(item, 'excelOut')
+    } else if (item.OpenType === 'excelIn') {
+      if (item.verify && item.verify.sheet && item.verify.columns && item.verify.columns.length > 0) {
+        this.refs.excelIn.exceltrigger(item)
+      } else {
+        notification.warning({
+          top: 92,
+          message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒',
+          duration: 10
+        })
+      }
     } else if (item.OpenType === 'popview' && this.props.type !== 'subtab') {
       this.props.triggerPopview(item, data)
     } else if (item.OpenType === 'popview' && this.props.type === 'subtab') {
@@ -525,7 +538,7 @@
    * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
   execSuccess = (btn, res) => {
-    if (btn.OpenType === 'excelOut') { // 瀵煎嚭excel
+    if (btn.OpenType === 'excelOut' || btn.OpenType === 'excelIn') { // 瀵煎嚭excel
       this.setState({
         loadingUuid: ''
       })
@@ -584,7 +597,7 @@
       message.error(res.message || res.ErrMesg)
     }
     
-    if (btn.OpenType === 'excelOut') {
+    if (btn.OpenType === 'excelOut' || btn.OpenType === 'excelIn') {
       this.setState({
         loadingUuid: ''
       })
@@ -778,6 +791,74 @@
     })
   }
 
+  getexceldata = (data, btn, errors) => {
+    if (errors && errors.length > 0) {
+      notification.warning({
+        top: 92,
+        message: errors.join(',') + '琛ㄥご璁剧疆閿欒锛�',
+        duration: 10
+      })
+      return
+    }
+    if (!data || data.length === 0) {
+      notification.warning({
+        top: 92,
+        message: '鏈幏鍙栧埌excel鏁版嵁锛�',
+        duration: 10
+      })
+      return
+    }
+
+    let result = Utils.getExcelInSql(btn, data, this.props.dict)
+    if (result.errors) {
+      notification.warning({
+        top: 92,
+        message: result.errors,
+        duration: 10
+      })
+      return
+    }
+    if (!btn.innerFunc) {
+      let param = { // 绯荤粺瀛樺偍杩囩▼
+        func: 'sPC_TableData_InUpDe',
+        BID: this.props.BID
+      }
+
+      param.LText = Utils.formatOptions(result.sql)
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+      this.setState({loadingUuid: btn.uuid})
+
+      Api.genericInterface(param).then((res) => {
+        if (res.status) {
+          this.execSuccess(btn, res)
+        } else {
+          this.execError(res, btn)
+        }
+      })
+    } else {
+      let param = { // 鑷畾涔夊瓨鍌ㄨ繃绋�
+        func: btn.innerFunc,
+        BID: this.props.BID
+      }
+
+      param.LText = Utils.formatOptions(result.sql)
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+      this.setState({loadingUuid: btn.uuid})
+
+      Api.genericInterface(param).then((res) => {
+        if (res.status) {
+          this.execSuccess(btn, res)
+        } else {
+          this.execError(res, btn)
+        }
+      })
+    }
+  }
+
   /**
    * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁�
    */
@@ -948,6 +1029,7 @@
             })}
             {this.getModels()}
             {btnloading && <Spin size="large" />}
+            <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" />
           </div>
         </Affix>
       )
@@ -978,6 +1060,7 @@
           })}
           {this.getModels()}
           {btnloading && <Spin size="large" />}
+          <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" />
         </div>
       )
     }

--
Gitblit v1.8.0