From 2bccb9ec7bdefe23292a22bc153463cfa1479a49 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 六月 2024 16:25:42 +0800
Subject: [PATCH] 2024-06-21

---
 src/tabviews/zshare/actionList/excelInbutton/index.jsx |  517 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 336 insertions(+), 181 deletions(-)

diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index 53fd47f..1be21b1 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -1,42 +1,44 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import moment from 'moment'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { Button, Modal, notification, message } from 'antd'
 
 import ExcelIn from './excelin'
-import Utils from '@/utils/utils.js'
-import options from '@/store/options.js'
+import Utils, { getExcelInSql } from '@/utils/utils.js'
 import Api from '@/api'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
-import './index.scss'
+import MKEmitter from '@/utils/events.js'
+import MkIcon from '@/components/mk-icon'
+// import './index.scss'
+
+const { confirm } = Modal
 
 class ExcelInButton extends Component {
   static propTpyes = {
-    show: PropTypes.any,              // 鏄剧ず鏍峰紡
     BID: PropTypes.string,            // 涓昏〃ID
+    BData: PropTypes.any,             // 涓昏〃鏁版嵁
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
-    Tab: PropTypes.any,               // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭�
     btn: PropTypes.object,            // 鎸夐挳
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
-    updateStatus: PropTypes.func,     // 鎸夐挳鐘舵�佹洿鏂�
-    triggerBtn: PropTypes.any,
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     loading: false,
+    selines: null,
+    disabled: false,
+    hidden: false,
     primaryId: '',
+    dict: window.GLOB.dict
   }
 
-  /**
-   * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮
-   */
-  UNSAFE_componentWillReceiveProps(nextProps) {
-    if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) {
-      this.actionTrigger(nextProps.triggerBtn.data)
+  UNSAFE_componentWillMount () {
+    const { btn, selectedData, BData, disabled } = this.props
+
+    if (btn.controlField) {
+      this.setStatus(btn, selectedData || [], BData, disabled)
+    } else if (disabled) {
+      this.setState({disabled: true})
     }
   }
 
@@ -44,73 +46,106 @@
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
-  /**
-   * @description 鎸夐挳鐘舵�佹敼鍙�
-   */
-  updateStatus = (type) => {
-    if (type === 'start') {
-      this.setState({
-        loading: true
-      })
-      this.props.updateStatus('start')
-    } else if (type === 'over') {
-      this.setState({
-        loading: false
-      })
-      this.props.updateStatus('over')
+  componentDidMount () {
+    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
+  }
+
+  UNSAFE_componentWillReceiveProps (nextProps) {
+    const { btn } = this.props
+
+    if (btn.controlField) {
+      this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled)
+    } else {
+      this.setState({disabled: nextProps.disabled === true})
     }
+  }
+
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
+  }
+
+  setStatus = (btn, data, BData, disprop) => {
+    let disabled = false
+    let hidden = false
+
+    if (btn.control !== 'parent') {
+      if (data.length > 0) {
+        data.forEach(item => {
+          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
+          if (btn.controlVals.includes(s) || item.$lock) {
+            disabled = true
+          }
+        })
+      } else if (btn.controlVals.includes('')) {
+        disabled = true
+      }
+    } else {
+      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
+        hidden = true
+      } else {
+        let s = BData[btn.controlField] + ''
+        if (btn.controlVals.includes(s)) {
+          hidden = true
+        }
+      }
+    }
+
+    if (disabled && btn.control === 'hidden') {
+      hidden = true
+    }
+
+    if (disprop) {
+      disabled = true
+    }
+
+    this.setState({hidden, disabled})
   }
   
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (record) => {
-    const { setting, Tab, BID, btn, selectedData } = this.props
+  actionTrigger = (triggerId, record, type, lid) => {
+    const { setting, BID, btn, selectedData, LID } = this.props
+    const { loading, disabled, dict } = this.state
 
-    if (Tab && Tab.supMenu && !BID) {
+    if (loading || disabled) return
+    if (triggerId && btn.uuid !== triggerId) return
+    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
+
+    let data = record || selectedData || []
+
+    if (setting.supModule && !BID) {
       notification.warning({
         top: 92,
-        message: '闇�瑕佷笂绾т富閿�硷紒',
+        message: dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒',
         duration: 5
       })
-      return
-    }
-
-    let data = []
-    
-    if (record) { // 琛ㄦ牸涓Е鍙戞寜閽�
-      data = [record]
-    } else {
-      data = selectedData || []
-    }
-    
-    if (btn.Ot === 'requiredSgl' && data.length !== 1) {
+    } else if (btn.Ot === 'requiredSgl' && data.length !== 1) {
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectSingleLine'],
+        message: dict['select_single_row'] || '璇烽�夋嫨鍗曡鏁版嵁锛�',
         duration: 5
       })
-      return
-    }
-
-    if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) {
+    } else {
       let primaryId = '' // 瀵煎叆鏃惰Id
-      if (btn.Ot === 'requiredSgl') {
+      if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
         primaryId = data[0][setting.primaryKey] || ''
       }
-
+  
       this.setState({
+        selines: data,
         primaryId: primaryId
       }, () => {
         this.refs.excelIn.exceltrigger()
       })
-    } else {
-      notification.warning({
-        top: 92,
-        message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒',
-        duration: 5
-      })
+  
+      if (window.GLOB.systemType === 'production') {
+        MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '瀵煎叆Excel'})
+      }
     }
   }
 
@@ -122,20 +157,22 @@
    * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂�
    * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execSuccess = (res) => {
+  execSuccess = (res = {}) => {
     const { btn } = this.props
+    const { dict } = this.state
 
-    if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛
+    if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
+        message: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�',
         duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
       })
-    } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛
+    } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.ErrMesg || this.state.dict['main.action.confirm.success']
+        title: res.message || dict['exc_success'] || '鎵ц鎴愬姛锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�',
       })
-    } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
+    } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
     }
 
@@ -143,7 +180,39 @@
       loading: false
     })
 
-    this.props.updateStatus('refresh', btn.execSuccess)
+    if (btn.execSuccess === 'closepoptab') {
+      MKEmitter.emit('popclose')
+    } else if (btn.execSuccess !== 'never') {
+      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
+    }
+    
+    if (btn.syncComponentId) {
+      if (btn.syncComponentId === 'multiComponent') {
+        btn.syncComponentIds.forEach((id, i) => {
+          setTimeout(() => {
+            if (/\$focus/.test(id)) {
+              MKEmitter.emit('reloadData', id.split('$')[0], id.split('$')[1])
+            } else {
+              MKEmitter.emit('reloadData', id)
+            }
+          }, 20 * i)
+        })
+      } else if (/\$focus/.test(btn.syncComponentId)) {
+        MKEmitter.emit('reloadData', btn.syncComponentId.split('$')[0], btn.syncComponentId.split('$')[1])
+      } else {
+        MKEmitter.emit('reloadData', btn.syncComponentId)
+      }
+    }
+
+    if (btn.switchTab && btn.switchTab.length > 0) {
+      let id = btn.switchTab[btn.switchTab.length - 1]
+      let node = document.getElementById('tab' + id)
+      node && node.click()
+    }
+
+    if (btn.execSuccess === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊
+      MKEmitter.emit('refreshPopButton', btn.$tabId)
+    }
   }
 
   /**
@@ -152,77 +221,87 @@
    * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬�
    * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execError = (res) => {
+  execError = (res = {}) => {
     const { btn } = this.props
+    const { dict } = this.state
+
+    if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) {
+      res.ErrCode = 'E'
+    }
 
     if (res.ErrCode === 'E') {
       Modal.error({
-        title: res.message || res.ErrMesg,
+        title: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
       })
     } else if (res.ErrCode === 'N') {
       notification.error({
         top: 92,
-        message: res.message || res.ErrMesg,
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
       })
     } else if (res.ErrCode === 'F') {
       notification.error({
         className: 'notification-custom-error',
         top: 92,
-        message: res.message || res.ErrMesg,
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
       })
     } else if (res.ErrCode === 'NM') {
-      message.error(res.message || res.ErrMesg)
+      message.error(res.message || dict['exc_fail'] || '鎵ц澶辫触锛�')
     }
     
     this.setState({
       loading: false
     })
 
-    this.props.updateStatus('refresh', btn.execError)
+    if (btn.execError === 'closepoptab') {
+      MKEmitter.emit('popclose')
+    } else if (btn.execError !== 'never') {
+      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
+
+      if (btn.syncComponentId) {
+        if (btn.syncComponentId === 'multiComponent') {
+          btn.syncComponentIds.forEach((id, i) => {
+            setTimeout(() => {
+              if (/\$focus/.test(id)) {
+                MKEmitter.emit('reloadData', id.split('$')[0], id.split('$')[1])
+              } else {
+                MKEmitter.emit('reloadData', id)
+              }
+            }, 20 * i)
+          })
+        } else if (/\$focus/.test(btn.syncComponentId)) {
+          MKEmitter.emit('reloadData', btn.syncComponentId.split('$')[0], btn.syncComponentId.split('$')[1])
+        } else {
+          MKEmitter.emit('reloadData', btn.syncComponentId)
+        }
+      }
+    }
+
+    if (btn.execError === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊
+      MKEmitter.emit('refreshPopButton', btn.$tabId)
+    }
   }
 
   /**
    * @description Excel 瀵煎叆
    */
-  getexceldata = (data, errors, sheetName) => {
-    const { btn } = this.props
+  getexceldata = (data, error) => {
+    const { btn, BID } = this.props
 
-    if (errors) {
-      if (errors === 'notexit') {
-        notification.warning({
-          top: 92,
-          message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬩笉瀛樺湪锛�',
-          duration: 5
-        })
-      } else if (errors === 'empty') {
-        notification.warning({
-          top: 92,
-          message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬩负绌猴紒',
-          duration: 5
-        })
-      } else if (errors === 'headerError') {
-        notification.warning({
-          top: 92,
-          message: '宸ヤ綔琛ㄣ��' + sheetName + '銆嬭〃澶磋缃敊璇紝璇锋鏌ヨ〃澶翠腑鐨勫悕绉板強椤哄簭锛屼笌鎸夐挳Excel鍒椾俊鎭槸鍚︿竴鑷达紒',
-          duration: 5
-        })
-      }
-
-      this.updateStatus('over')
-      return
-    }
-
-    if (!data || data.length === 0) {
+    if (error) {
       notification.warning({
         top: 92,
-        message: '鏈幏鍙栧埌宸ヤ綔琛ㄣ��' + sheetName + '銆嬫暟鎹紒',
+        message: error,
         duration: 5
       })
-      this.updateStatus('over')
+
+      this.setState({ loading: false })
       return
-    } else if (data.length * btn.verify.columns.length > 30000) {
+    }
+    
+    if (data.length * btn.verify.columns.length > 30000) {
       notification.warning({
         top: 92,
         message: '褰撳墠瀵煎叆鏁版嵁閲忚繃澶э紝濡傞亣閿欒鎻愮ず锛岃鍒嗘壒瀵煎叆锛�',
@@ -230,7 +309,7 @@
       })
     }
 
-    let result = Utils.getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''))
+    let result = getExcelInSql(btn, data, (BID || ''), this.state.primaryId)
 
     if (result.errors) {
       notification.warning({
@@ -238,7 +317,7 @@
         message: result.errors,
         duration: 5
       })
-      this.updateStatus('over')
+      this.setState({ loading: false })
       return
     }
 
@@ -247,44 +326,108 @@
       excel_in: result.lines
     }
 
-    if (this.props.BID) {
-      param.BID = this.props.BID
+    if (BID) {
+      param.BID = BID
     }
 
     if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼
       param.func = 'sPC_TableData_InUpDe'
-      
-      if (this.props.dataManager) { // 鏁版嵁鏉冮檺
-        result.sql = result.sql.replace(/\$@/ig, '/*')
-        result.sql = result.sql.replace(/@\$/ig, '*/')
-        result.bottom = result.bottom.replace(/\$@/ig, '/*')
-        result.bottom = result.bottom.replace(/@\$/ig, '*/')
-      } else {
-        result.sql = result.sql.replace(/@\$|\$@/ig, '')
-        result.bottom = result.bottom.replace(/@\$|\$@/ig, '')
-      }
-      
-      param.excel_in_type = 'true'
-      param.LText1 = Utils.formatOptions(result.insert)
-      param.LText2 = Utils.formatOptions(result.bottom)
-      param.LText = Utils.formatOptions(result.sql)
+
+      delete param.excel_in
+
+      // param.excel_in_type = 'true'
+      param.exec_type = window.GLOB.execType || 'y'
+      param.LText = result.sql
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-      if (this.props.menuType === 'HS' && param.timestamp) { // 浜戠楠岃瘉
+
+      let unCheckParam = null
+
+      if (/\$check@|@check\$/ig.test(param.LText)) {
+        unCheckParam = fromJS(param).toJS()
+        param.LText = param.LText.replace(/\$check@|@check\$/ig, '')
+      }
+
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
+      param.secretkey = Utils.encrypt('', param.timestamp)
+      if (window.GLOB.mkHS) { // 浜戠楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
       }
 
-      Api.genericInterface(param).then((res) => {
-        if (res.status) {
-          this.execSuccess(res)
-        } else {
-          this.execError(res)
+      if (btn.database === 'sso' && window.GLOB.mainSystemApi) {
+        param.rduri = window.GLOB.mainSystemApi
+      }
+
+      param.menuname = btn.logLabel
+      
+      if (window.GLOB.probation) {
+        param.s_debug_type = 'Y'
+      }
+
+      if (unCheckParam) {
+        unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/')
+        unCheckParam.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type)
+        unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp)
+        unCheckParam.menuname = btn.logLabel
+
+        if (window.GLOB.probation) {
+          unCheckParam.s_debug_type = 'Y'
         }
-      }, () => {
-        this.execError({})
-      })
+
+        Api.genericInterface(param).then(res => {
+          if (res.status) {
+            this.execSuccess(res)
+          } else if (res.ErrCode === 'C') {
+            const _this = this
+            confirm({
+              title: window.GLOB.dict['exec_sure'] || '璇风‘璁�',
+              content: res.message,
+              okText: window.GLOB.dict['ok'] || '纭畾',
+              cancelText: window.GLOB.dict['cancel'] || '鍙栨秷',
+              onOk() {
+                return new Promise(resolve => {
+                  Api.genericInterface(unCheckParam).then(result => {
+                    if (result.status) {
+                      _this.execSuccess(result)
+                    } else {
+                      _this.execError(result)
+                    }
+                    resolve()
+                  })
+                })
+              },
+              onCancel() {
+                _this.execError(res)
+              }
+            })
+          } else {
+            this.execError(res)
+          }
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
+          this.execError({})
+        })
+      } else {
+        Api.genericInterface(param).then((res) => {
+          if (res.status) {
+            this.execSuccess(res)
+          } else {
+            this.execError(res)
+          }
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
+          this.execError({})
+        })
+      }
     } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋�
       param.func = btn.innerFunc
+
+      if (btn.recordUser === 'true') {
+        param.username = sessionStorage.getItem('User_Name') || ''
+        param.fullname = sessionStorage.getItem('Full_Name') || ''
+      }
+      if (btn.dataM === 'true') {
+        param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
+      }
 
       Api.genericInterface(param).then((res) => {
         if (res.status) {
@@ -292,11 +435,13 @@
         } else {
           this.execError(res)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') return
         this.execError({})
       })
     } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛
       let _outParam = null
+      let ver_token = false
 
       new Promise(resolve => {
         // 鍐呴儴璇锋眰
@@ -320,7 +465,8 @@
               this.execError(res)
               resolve(false)
             }
-          }, () => {
+          }, (error) => {
+            if (error && error.ErrCode === 'LoginError') return
             this.execError({})
           })
         } else {
@@ -331,17 +477,26 @@
         // 澶栭儴璇锋眰
         _outParam = fromJS(res).toJS()
 
-        if (this.props.menuType === 'HS') {
-          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
-            param.rduri = options.cloudServiceApi
-          } else if (btn.sysInterface !== 'true') {
+        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 || ''
+          }
+          ver_token = true
+        } else {
+          if (window.GLOB.systemType === 'production' && btn.proInterface) {
+            param.rduri = btn.proInterface
+          } else {
             param.rduri = btn.interface
           }
-        } else {
-          if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
-            param.rduri = window.GLOB.mainSystemApi
-          } else if (btn.sysInterface !== '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
           }
         }
 
@@ -349,8 +504,9 @@
           res.func = btn.outerFunc
         }
         
-        if (this.props.menuType === 'HS' && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉
-          param.LText = Utils.formatOptions(result.sql)
+        if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉
+          let sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)`
+          param.LText = Utils.formatOptions(sql)
           param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
           param.secretkey = Utils.encrypt(param.LText, param.timestamp)
           param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -358,9 +514,12 @@
 
         return Api.genericInterface(res)
       }).then(response => {
-        if (!response) return
+        if (!response || response.ErrCode === 'LoginError') return
         // 鍥炶皟璇锋眰
-        if (btn.callbackFunc) {
+        if (ver_token && response.ErrCode === 'token_error') {
+          response.ErrCode = 'E'
+          this.execError(response)
+        } else if (btn.callbackFunc ) {
           // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤
           delete response.message
           delete response.status
@@ -377,7 +536,7 @@
           }
         }
       }).then(res => {
-        if (!res) return
+        if (!res || res.ErrCode === 'LoginError') return
 
         if (res.status) {
           this.execSuccess(res)
@@ -389,39 +548,35 @@
   }
 
   render() {
-    const { btn, show } = this.props
-    const { loading } = this.state
+    const { btn } = this.props
+    const { loading, disabled, hidden } = this.state
 
-    return (
-      <div className="mk-btn-wrap">
-        {!show ? <Button
-          className={'mk-btn mk-' + btn.class}
-          icon={btn.icon}
-          onClick={() => {this.actionTrigger()}}
-          loading={loading}
-        >{btn.label}</Button> : null}
-        {show === 'icon' ? <Button
-          className="import-icon"
-          icon="upload"
-          onClick={() => {this.actionTrigger()}}
-          loading={loading}
-          title={btn.label}
-        ></Button> : null}
-        <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
-      </div>
-    )
+    if (hidden) return null
+
+    let label = ''
+
+    if (btn.show === 'link') {
+      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
+    } else if (btn.show === 'icon') {
+      label = !loading ? <MkIcon type={btn.icon} /> : null
+    } else {
+      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span>
+    }
+
+    return <>
+      <Button
+        type="link"
+        id={'button' + btn.uuid}
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        loading={loading}
+        disabled={disabled}
+        style={btn.style}
+        className={btn.hover || ''}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+      <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" />
+    </>
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menuType: state.editLevel,
-    dataManager: state.dataManager
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(ExcelInButton)
\ No newline at end of file
+export default ExcelInButton
\ No newline at end of file

--
Gitblit v1.8.0