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/index.jsx |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index eb03ae3..0325d43 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -248,7 +248,7 @@
 
     let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${setting.dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows`
     let DateCount = `select count(1) as total from ${setting.dataresource} ${_search}`
-    console.log(LText)
+
     param.LText = Utils.formatOptions(LText)
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
     param.secretkey = Utils.encrypt(param.LText, param.timestamp)
@@ -368,7 +368,33 @@
       this.reloadtable()
     } else if (btn.execError === 'view' && type === 'error') {
       this.reloadview()
+    } else if (type === 'excelOut') {
+      this.handleExcelout()
     }
+  }
+
+  handleExcelout = () => {
+    const { arr_field, orderColumn, orderType, search, setting } = this.state
+
+    let _search = Utils.joinMainSearchkey(search)
+    _search = _search ? 'where (' + _search + ')' : ''
+    // 鑾峰彇鍒楄〃鏁版嵁
+    let param = {
+      func: setting.innerFunc || 'sPC_Get_TableData',
+      obj_name: 'data',
+      arr_field: arr_field
+    }
+
+    let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order
+
+    let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${setting.dataresource} ${_search}) tmptable order by tmptable.rows`
+
+    param.LText = Utils.formatOptions(LText)
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+    param.DateCount = ''
+
+    Api.genericInterface(param)
   }
 
   gettableselected = () => {
@@ -378,6 +404,10 @@
       data.push(this.refs.mainTable.props.data[item])
     })
     return data
+  }
+
+  buttonTrigger = (btn, record) => {
+    this.refs.mainButton.actionTrigger(btn, record)
   }
 
   UNSAFE_componentWillMount () {
@@ -404,6 +434,7 @@
         }
         {actions &&
           <MainAction
+            ref="mainButton"
             MenuID={this.props.MenuID}
             setting={setting}
             refreshdata={this.refreshbyaction}
@@ -415,14 +446,15 @@
         {columns &&
           <MainTable
             ref="mainTable"
+            dict={this.state.dict}
             MenuID={this.props.MenuID}
             setting={setting}
-            refreshdata={this.refreshbytable}
             columns={columns}
             data={this.state.data}
             total={this.state.total}
             loading={this.state.loading}
-            dict={this.state.dict}
+            refreshdata={this.refreshbytable}
+            buttonTrigger={this.buttonTrigger}
           />
         }
         <BackTop>

--
Gitblit v1.8.0