From ae46c8e640ed64abd7605b289554377e0cdc0cb7 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 04 十月 2023 22:10:30 +0800
Subject: [PATCH] 2023-10-04

---
 src/tabviews/zshare/actionList/exceloutbutton/index.jsx |  255 ++++++++++++++++++++++----------------------------
 1 files changed, 112 insertions(+), 143 deletions(-)

diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
index 30bcbf7..7e032ca 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,13 +443,11 @@
   /**
    * @description Excel 鐢熸垚
    */
-  exportExcel = (data) => {
+  exportExcel = (data, ErrCode, msg) => {
     const { btn } = this.props
     
     let imgCol = false
-    let columns = btn.verify.columns.filter(col => {
-      if (col.output === 'false') return false
-
+    let columns = btn.verify.columns.map(col => {
       if (col.type === 'image') {
         imgCol = true
       }
@@ -510,6 +462,7 @@
     if (data && data[0]) {
       let errors = []
       columns.forEach(col => {
+        if (col.output === 'false') return
         if (col.Column && data[0][col.Column] === undefined) {
           errors.push(col.Text)
         }
@@ -555,7 +508,13 @@
   
           columns.forEach((col, i) => {
             let val = item[col.Column]
-            if (col.type === 'number' && typeof(val) === 'number') {
+            if (col.output === 'false') {
+              if (col.type === 'number') {
+                val = 0
+              } else {
+                val = ''
+              }
+            } else if (col.type === 'number' && typeof(val) === 'number') {
               if (col.abs === 'true') {
                 val = Math.abs(val)
               }
@@ -573,7 +532,7 @@
 
         this.table2excel(column, table)
 
-        this.execSuccess({ErrCode: 'S', message: '瀵煎嚭鎴愬姛锛�'})
+        this.execSuccess({ErrCode: ErrCode || 'S', message: msg || '瀵煎嚭鎴愬姛锛�'})
       } else {
         let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         let cols = []
@@ -640,7 +599,13 @@
           columns.forEach((col, i) => {
             let val = item[col.Column]
 
-            if (col.type === 'number' && typeof(val) === 'number') {
+            if (col.output === 'false') {
+              if (col.type === 'number') {
+                val = 0
+              } else {
+                val = ''
+              }
+            } else if (col.type === 'number' && typeof(val) === 'number') {
               if (col.abs === 'true') {
                 val = Math.abs(val)
               }
@@ -710,7 +675,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鐢熸垚澶辫触锛�'})
@@ -812,10 +777,14 @@
       _setting.arr_field = _setting.arr_field.join(',')
       _setting.execute = btn.verify.defaultSql !== 'false'
       _setting.dataresource = btn.verify.dataresource || ''
-      _setting.primaryKey = _setting.primaryKey || setting.primaryKey || 'ID'
+      _setting.primaryKey = btn.verify.primaryKey || setting.primaryKey || 'ID'
 
       if (!_setting.execute) {
         _setting.dataresource = ''
+      }
+
+      if (/\s/.test(_setting.dataresource)) {
+        _setting.dataresource = '(' + _setting.dataresource + ') tb'
       }
 
       let _customScript = ''
@@ -847,10 +816,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
@@ -858,8 +824,11 @@
       _orderBy = btn.verify.order || ''
     } else {
       _setting = {...setting}
+      _setting.$name = btn.logLabel
       _setting.laypage = pagination
       _setting.arr_field = _setting.all_field || _setting.arr_field
+
+      delete _setting.sub_field
     }
 
     let primaryId = ''
@@ -891,18 +860,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