From 0bc7d67c80410b9cd763df38093e3a221aafb89a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 19 九月 2023 11:50:32 +0800
Subject: [PATCH] 2023-09-19

---
 src/tabviews/zshare/actionList/exceloutbutton/index.jsx |  229 +++++++++++++++++++++++----------------------------------
 1 files changed, 92 insertions(+), 137 deletions(-)

diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
index 30bcbf7..be84eac 100644
--- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -168,7 +168,7 @@
 
         Api.genericInterface(param).then(result => {
           if (result.status) {
-            this.exportExcel(result.data)
+            this.exportExcel(result.data, result.ErrCode, result.message)
           } else {
             this.execError(result)
           }
@@ -180,9 +180,14 @@
         let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search)
         param.func = btn.innerFunc
 
+        if (btn.recordUser === 'true') {
+          param.username = sessionStorage.getItem('User_Name') || ''
+          param.fullname = sessionStorage.getItem('Full_Name') || ''
+        }
+
         Api.genericInterface(param).then(result => {
           if (result.status) {
-            this.exportExcel(result.data)
+            this.exportExcel(result.data, result.ErrCode, result.message)
           } else {
             this.execError(result)
           }
@@ -193,39 +198,25 @@
       } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟
         let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search)
 
-        if (window.GLOB.mkHS) {
-          if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
-            param.rduri = window.GLOB.cloudServiceApi
-            param.userid = sessionStorage.getItem('CloudUserID') || ''
-            param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-          } else if (btn.sysInterface !== 'true') {
-            if (window.GLOB.systemType === 'production' && btn.proInterface) {
-              param.rduri = btn.proInterface
-            } else {
-              param.rduri = btn.interface
-            }
+        if (btn.sysInterface === 'true') {
+          if (window.GLOB.mainSystemApi) {
+            param.rduri = window.GLOB.mainSystemApi
+          }
+        } else if (btn.sysInterface === 'external') {
+          if (window.GLOB.systemType === 'production') {
+            param.$token = btn.exProInterface || ''
+          } else {
+            param.$token = btn.exInterface || ''
           }
         } else {
-          if (btn.sysInterface === 'true') {
-            if (window.GLOB.mainSystemApi) {
-              param.rduri = window.GLOB.mainSystemApi
-            }
-          } else if (btn.sysInterface === 'external') {
-            if (window.GLOB.systemType === 'production') {
-              param.$token = btn.exProInterface || ''
-            } else {
-              param.$token = btn.exInterface || ''
-            }
+          if (window.GLOB.systemType === 'production' && btn.proInterface) {
+            param.rduri = btn.proInterface
           } else {
-            if (window.GLOB.systemType === 'production' && btn.proInterface) {
-              param.rduri = btn.proInterface
-            } else {
-              param.rduri = btn.interface
-            }
-            let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
-            if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
-              param.$login = true
-            }
+            param.rduri = btn.interface
+          }
+          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
+            param.$login = true
           }
         }
   
@@ -235,7 +226,7 @@
 
         Api.genericInterface(param).then(result => {
           if (result.status) {
-            this.exportExcel(result.data)
+            this.exportExcel(result.data, result.ErrCode, result.message)
           } else {
             this.execError(result)
           }
@@ -254,39 +245,25 @@
             delete res.message
             delete res.status
 
-            if (window.GLOB.mkHS) {
-              if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
-                res.rduri = window.GLOB.cloudServiceApi
-                res.userid = sessionStorage.getItem('CloudUserID') || ''
-                res.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-              } else if (btn.sysInterface !== 'true') {
-                if (window.GLOB.systemType === 'production' && btn.proInterface) {
-                  res.rduri = btn.proInterface
-                } else {
-                  res.rduri = btn.interface
-                }
+            if (btn.sysInterface === 'true') {
+              if (window.GLOB.mainSystemApi) {
+                res.rduri = window.GLOB.mainSystemApi
+              }
+            } else if (btn.sysInterface === 'external') {
+              if (window.GLOB.systemType === 'production') {
+                res.$token = btn.exProInterface || ''
+              } else {
+                res.$token = btn.exInterface || ''
               }
             } else {
-              if (btn.sysInterface === 'true') {
-                if (window.GLOB.mainSystemApi) {
-                  res.rduri = window.GLOB.mainSystemApi
-                }
-              } else if (btn.sysInterface === 'external') {
-                if (window.GLOB.systemType === 'production') {
-                  res.$token = btn.exProInterface || ''
-                } else {
-                  res.$token = btn.exInterface || ''
-                }
+              if (window.GLOB.systemType === 'production' && btn.proInterface) {
+                res.rduri = btn.proInterface
               } else {
-                if (window.GLOB.systemType === 'production' && btn.proInterface) {
-                  res.rduri = btn.proInterface
-                } else {
-                  res.rduri = btn.interface
-                }
-                let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
-                if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
-                  res.$login = true
-                }
+                res.rduri = btn.interface
+              }
+              let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+              if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
+                res.$login = true
               }
             }
   
@@ -296,7 +273,7 @@
       
             Api.genericInterface(res).then(result => {
               if (result.status) {
-                this.exportExcel(result.data)
+                this.exportExcel(result.data, result.ErrCode, result.message)
               } else {
                 this.execError(result)
               }
@@ -340,39 +317,25 @@
         delete res.message
         delete res.status
 
-        if (window.GLOB.mkHS) {
-          if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
-            res.rduri = window.GLOB.cloudServiceApi
-            res.userid = sessionStorage.getItem('CloudUserID') || ''
-            res.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-          } else if (btn.sysInterface !== 'true') {
-            if (window.GLOB.systemType === 'production' && btn.proInterface) {
-              res.rduri = btn.proInterface
-            } else {
-              res.rduri = btn.interface
-            }
+        if (btn.sysInterface === 'true') {
+          if (window.GLOB.mainSystemApi) {
+            res.rduri = window.GLOB.mainSystemApi
+          }
+        } else if (btn.sysInterface === 'external') {
+          if (window.GLOB.systemType === 'production') {
+            res.$token = btn.exProInterface || ''
+          } else {
+            res.$token = btn.exInterface || ''
           }
         } else {
-          if (btn.sysInterface === 'true') {
-            if (window.GLOB.mainSystemApi) {
-              res.rduri = window.GLOB.mainSystemApi
-            }
-          } else if (btn.sysInterface === 'external') {
-            if (window.GLOB.systemType === 'production') {
-              res.$token = btn.exProInterface || ''
-            } else {
-              res.$token = btn.exInterface || ''
-            }
+          if (window.GLOB.systemType === 'production' && btn.proInterface) {
+            res.rduri = btn.proInterface
           } else {
-            if (window.GLOB.systemType === 'production' && btn.proInterface) {
-              res.rduri = btn.proInterface
-            } else {
-              res.rduri = btn.interface
-            }
-            let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
-            if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
-              res.$login = true
-            }
+            res.rduri = btn.interface
+          }
+          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+          if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
+            res.$login = true
           }
         }
 
@@ -390,7 +353,7 @@
               this.getExcelOutDoubleData(viewParam, pageIndex, pageSize, data)
             } else {
               data = data.concat(result.data)
-              this.exportExcel(data)
+              this.exportExcel(data, result.ErrCode, result.message)
             }
           } else {
             this.execError(result)
@@ -420,43 +383,34 @@
       param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
       param.func = btn.innerFunc
 
+      if (btn.recordUser === 'true') {
+        param.username = sessionStorage.getItem('User_Name') || ''
+        param.fullname = sessionStorage.getItem('Full_Name') || ''
+      }
+
     } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟
       param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
 
-      if (window.GLOB.mkHS) {
-        if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
-          param.rduri = window.GLOB.cloudServiceApi
-          param.userid = sessionStorage.getItem('CloudUserID') || ''
-          param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
-        } else if (btn.sysInterface !== 'true') {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            param.rduri = btn.proInterface
-          } else {
-            param.rduri = btn.interface
-          }
+      if (btn.sysInterface === 'true') {
+        if (window.GLOB.mainSystemApi) {
+          param.rduri = window.GLOB.mainSystemApi
+        }
+      } else if (btn.sysInterface === 'external') {
+        if (window.GLOB.systemType === 'production') {
+          param.$token = btn.exProInterface || ''
+        } else {
+          param.$token = btn.exInterface || ''
         }
       } else {
-        if (btn.sysInterface === 'true') {
-          if (window.GLOB.mainSystemApi) {
-            param.rduri = window.GLOB.mainSystemApi
-          }
-        } else if (btn.sysInterface === 'external') {
-          if (window.GLOB.systemType === 'production') {
-            param.$token = btn.exProInterface || ''
-          } else {
-            param.$token = btn.exInterface || ''
-          }
+        if (window.GLOB.systemType === 'production' && btn.proInterface) {
+          param.rduri = btn.proInterface
         } else {
-          if (window.GLOB.systemType === 'production' && btn.proInterface) {
-            param.rduri = btn.proInterface
-          } else {
-            param.rduri = btn.interface
-          }
+          param.rduri = btn.interface
+        }
 
-          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
-          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
-            param.$login = true
-          }
+        let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+        if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
+          param.$login = true
         }
       }
       
@@ -475,7 +429,7 @@
           this.getExcelOutData(viewParam, pageIndex, pageSize, data)
         } else {
           data = data.concat(result.data)
-          this.exportExcel(data)
+          this.exportExcel(data, result.ErrCode, result.message)
         }
       } else {
         this.execError(result)
@@ -489,7 +443,7 @@
   /**
    * @description Excel 鐢熸垚
    */
-  exportExcel = (data) => {
+  exportExcel = (data, ErrCode, msg) => {
     const { btn } = this.props
     
     let imgCol = false
@@ -573,7 +527,7 @@
 
         this.table2excel(column, table)
 
-        this.execSuccess({ErrCode: 'S', message: '瀵煎嚭鎴愬姛锛�'})
+        this.execSuccess({ErrCode: ErrCode || 'S', message: msg || '瀵煎嚭鎴愬姛锛�'})
       } else {
         let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         let cols = []
@@ -710,7 +664,7 @@
   
         XLSX.writeFile(wb, `${btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`)
   
-        this.execSuccess({ErrCode: 'S', message: '瀵煎嚭鎴愬姛锛�'})
+        this.execSuccess({ErrCode: ErrCode || 'S', message: msg || '瀵煎嚭鎴愬姛锛�'})
       }
     } catch (e) {
       this.execError({ErrCode: 'N', message: 'Excel鐢熸垚澶辫触锛�'})
@@ -818,6 +772,10 @@
         _setting.dataresource = ''
       }
 
+      if (/\s/.test(_setting.dataresource)) {
+        _setting.dataresource = '(' + _setting.dataresource + ') tb'
+      }
+
       let _customScript = ''
       let _tailScript = ''
       btn.verify.scripts && btn.verify.scripts.forEach(script => {
@@ -847,10 +805,7 @@
       _setting.tailScript = _tailScript     // 鍚庣疆鑷畾涔夎剼鏈�
 
       _setting.laypage = pagination
-
-      if (_setting.laypage) {
-        _setting.custompage = /@pageSize@/i.test(_setting.dataresource + _setting.customScript)
-      }
+      _setting.custompage = /@pageSize@|@orderBy@/i.test(_setting.dataresource + _setting.customScript)
 
       _setting.queryType = btn.verify.queryType
       _setting.$name = btn.logLabel
@@ -891,18 +846,18 @@
    * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂�
    * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execSuccess = (res = {}) => {
+  execSuccess = (res) => {
     const { btn } = this.props
 
-    if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛
+    if (res.ErrCode === 'S') { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.message || '鎵ц鎴愬姛锛�',
+        message: res.message,
         duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
       })
     } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.message || '鎵ц鎴愬姛锛�'
+        title: res.message
       })
     } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 

--
Gitblit v1.8.0