From e293f4b0edc825382a57e91f9288e387ca53e37c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 15 六月 2025 12:05:52 +0800
Subject: [PATCH] 2025-06-15

---
 src/tabviews/zshare/actionList/exceloutbutton/index.jsx |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
index 053530d..1a7e8c1 100644
--- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -437,7 +437,7 @@
    * @description Excel 鐢熸垚
    */
   exportExcel = (data = [], ErrCode, msg, search) => {
-    const { btn } = this.props
+    const { btn, BID } = this.props
     const { dict } = this.state
     
     let imgCol = false
@@ -521,6 +521,17 @@
         })
         
         return
+      }
+    }
+
+    let excelName = btn.verify.excelName || ''
+    if (/@.*@/.test(excelName)) {
+      excelName = excelName.replace(/@bid@/ig, BID)
+      if (data[0]) {
+        Object.keys(data[0]).forEach(key => {
+          let reg = new RegExp('@' + key + '@', 'ig')
+          excelName = excelName.replace(reg, data[0][key])
+        })
       }
     }
     
@@ -608,7 +619,7 @@
           table.push(_row)
         })
 
-        this.table2excel(column, table)
+        this.table2excel(column, table, btn, excelName)
 
         this.execSuccess({ErrCode: ErrCode || 'S', message: msg || dict['exc_success'] || '瀵煎嚭鎴愬姛锛�'})
       } else {
@@ -768,7 +779,7 @@
         const wb = XLSX.utils.book_new()
         XLSX.utils.book_append_sheet(wb, ws, btn.verify.sheet || 'Sheet1')
   
-        XLSX.writeFile(wb, `${btn.verify.excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`)
+        XLSX.writeFile(wb, `${excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`)
   
         this.execSuccess({ErrCode: ErrCode || 'S', message: msg || dict['exc_success'] || '瀵煎嚭鎴愬姛锛�'})
       }
@@ -778,7 +789,7 @@
     }
   }
 
-  table2excel = (column, data) => {
+  table2excel = (column, data, btn, excelName) => {
     let thead = column.reduce((result, item) => {
       return result + `<th>${item.title}</th>`
     }, '')
@@ -812,7 +823,7 @@
     // let url = 'data:application/vnd.ms-excel;base64,' + window.btoa(unescape(encodeURIComponent(html)))
     let link = document.createElement('a')
     link.href = url
-    link.download = `${this.props.btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xls`
+    link.download = `${excelName || btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xls`
     document.body.appendChild(link)
     link.click()
     document.body.removeChild(link)

--
Gitblit v1.8.0