From 76427d51a079a5fd1f45bf7188249e7a4647ae05 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 14 九月 2020 10:37:25 +0800
Subject: [PATCH] 2020-09-14

---
 src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx
index 0a57faa..b4481c0 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx
@@ -8,7 +8,6 @@
 class ExcelIn extends Component {
   static propTpyes = {
     btn: PropTypes.object,         // 鎸夐挳淇℃伅
-    MenuID: PropTypes.string,      // 鑿滃崟ID
     returndata: PropTypes.func,    // 鑾峰彇杩斿洖鏁版嵁
     triggerExcelIn: PropTypes.func // 淇敼涓婁紶鐘舵��
   }
@@ -19,7 +18,7 @@
 
   exceltrigger = () => {
     const { excelId } = this.state
-    let _excelInput = document.getElementById(excelId + this.props.MenuID)
+    let _excelInput = document.getElementById(excelId)
     
     if (_excelInput) {
       _excelInput.click()
@@ -43,12 +42,17 @@
         const workbook = XLSX.read(result, { type: 'binary' })
 
         let errors = null
+        let sheetName = btn.verify.sheet
 
-        if (!workbook.Sheets.hasOwnProperty(btn.verify.sheet)) {
+        if (Object.keys(workbook.Sheets).length === 1) {
+          sheetName = Object.keys(workbook.Sheets)[0]
+        }
+
+        if (!workbook.Sheets.hasOwnProperty(sheetName)) {
           errors = 'notexit'
         } else if (range === 1) {
-          let header = XLSX.utils.sheet_to_json(workbook.Sheets[btn.verify.sheet], {header: columns})[0]
-          
+          let header = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns})[0]
+
           if (!header) {
             errors = 'empty'
           } else {
@@ -68,11 +72,11 @@
         let data = []
 
         if (!errors) {
-          data = XLSX.utils.sheet_to_json(workbook.Sheets[btn.verify.sheet], {header: columns, range: (range)})
+          data = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns, range: (range)})
         }
 
         // 鏈�缁堣幏鍙栧埌骞朵笖鏍煎紡鍖栧悗鐨� json 鏁版嵁
-        this.props.returndata(data, errors)
+        this.props.returndata(data, errors, sheetName)
         this.setState({
           excelId: '',
         }, () => {
@@ -90,7 +94,7 @@
         })
         notification.warning({
           top: 92,
-          message: '鏂囦欢瑙f瀽閿欒锛岃妫�鏌ユ枃浠舵牸寮忥紒',
+          message: '鏂囦欢瑙f瀽閿欒锛�',
           duration: 5
         })
         // 閿欒浼犻��
@@ -105,7 +109,7 @@
   render() {
     return (
       <span>
-        {this.state.excelId ? <input className="excel-in-input" id={this.state.excelId + this.props.MenuID} type='file' accept='.xlsx, .xls' onAbort={this.onImportExcel} onChange={this.onImportExcel} /> : null}
+        {this.state.excelId ? <input className="excel-in-input" id={this.state.excelId} type='file' accept='.xlsx, .xls' onAbort={this.onImportExcel} onChange={this.onImportExcel} /> : null}
       </span>
     )
   }

--
Gitblit v1.8.0