From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 17 八月 2023 16:22:15 +0800
Subject: [PATCH] 2023-08-17

---
 src/tabviews/zshare/actionList/excelInbutton/index.jsx |  193 +++++++++++++++++++++++++-----------------------
 1 files changed, 101 insertions(+), 92 deletions(-)

diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index d0cba8c..0104e10 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -6,10 +6,7 @@
 
 import ExcelIn from './excelin'
 import Utils, { getExcelInSql } from '@/utils/utils.js'
-import options from '@/store/options.js'
 import Api from '@/api'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
 // import './index.scss'
@@ -27,7 +24,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     loading: false,
     selines: null,
     disabled: false,
@@ -36,31 +32,11 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData, BData } = this.props
-    let disabled = false
+    const { btn, selectedData, BData, disabled } = this.props
 
-    if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
-      selectedData.forEach(item => {
-        let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          disabled = true
-        }
-      })
-      this.setState({hidden: disabled && btn.control === 'hidden'})
-    } else if (btn.control === 'parent') {
-      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
-        this.setState({hidden: true})
-      } else {
-        let s = BData[btn.controlField] + ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          this.setState({hidden: true})
-        } else {
-          this.setState({hidden: false})
-        }
-      }
-    }
-
-    if (this.props.disabled || disabled) {
+    if (btn.controlField) {
+      this.setStatus(btn, selectedData || [], BData, disabled)
+    } else if (disabled) {
       this.setState({disabled: true})
     }
   }
@@ -74,36 +50,12 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { btn, selectedData, BData } = this.props
+    const { btn } = this.props
 
-    let disabled = false
-    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
-      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
-        nextProps.selectedData.forEach(item => {
-          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
-          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-            disabled = true
-          }
-        })
-      }
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
-    } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) {
-      if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) {
-        this.setState({hidden: true})
-      } else {
-        let s = nextProps.BData[btn.controlField] + ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          this.setState({hidden: true})
-        } else {
-          this.setState({hidden: false})
-        }
-      }
-    }
-
-    if (nextProps.disabled || disabled) {
-      this.setState({disabled: true})
+    if (btn.controlField) {
+      this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled)
     } else {
-      this.setState({disabled: false})
+      this.setState({disabled: nextProps.disabled === true})
     }
   }
 
@@ -112,6 +64,43 @@
       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})
   }
   
   /**
@@ -141,7 +130,7 @@
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectSingleLine'],
+        message: '璇烽�夋嫨鍗曡鏁版嵁锛�',
         duration: 5
       })
       return
@@ -179,20 +168,20 @@
    * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂�
    * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execSuccess = (res) => {
+  execSuccess = (res = {}) => {
     const { btn } = this.props
 
-    if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 鎵ц鎴愬姛
+    if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
+        message: res.message || '鎵ц鎴愬姛锛�',
         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 || '鎵ц鎴愬姛锛�'
       })
-    } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
+    } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
     }
 
@@ -206,12 +195,26 @@
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
     }
     
-    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
-    
+    if (btn.syncComponentId) {
+      if (btn.syncComponentId === 'multiComponent') {
+        btn.syncComponentIds.forEach((id, i) => {
+          setTimeout(() => {
+            MKEmitter.emit('reloadData', id)
+          }, 20 * i)
+        })
+      } 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)
     }
   }
 
@@ -221,28 +224,32 @@
    * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬�
    * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂�
    */
-  execError = (res) => {
+  execError = (res = {}) => {
     const { btn } = this.props
+
+    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 || '鎵ц澶辫触锛�',
       })
     } else if (res.ErrCode === 'N') {
       notification.error({
         top: 92,
-        message: res.message || res.ErrMesg,
+        message: res.message || '鎵ц澶辫触锛�',
         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 || '鎵ц澶辫触锛�',
         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 || '鎵ц澶辫触锛�')
     }
     
     this.setState({
@@ -253,6 +260,10 @@
       MKEmitter.emit('popclose')
     } else if (btn.execError !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
+    }
+
+    if (btn.execError === 'popclose' && btn.$tabId) { // 鏍囩鍏抽棴鍒锋柊
+      MKEmitter.emit('refreshPopButton', btn.$tabId)
     }
   }
 
@@ -303,7 +314,7 @@
       })
     }
 
-    let result = getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''), this.state.primaryId)
+    let result = getExcelInSql(btn, data, (this.props.BID || ''), this.state.primaryId)
 
     if (result.errors) {
       notification.warning({
@@ -326,17 +337,7 @@
 
     if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼
       param.func = 'sPC_TableData_InUpDe'
-      
-      if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-        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.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -384,7 +385,7 @@
           } else if (res.ErrCode === 'C') {
             const _this = this
             confirm({
-              title: '缁х画鎵ц锛�',
+              title: '璇风‘璁�',
               content: res.message,
               onOk() {
                 return new Promise(resolve => {
@@ -405,7 +406,8 @@
           } else {
             this.execError(res)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else {
@@ -415,7 +417,8 @@
           } else {
             this.execError(res)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       }
@@ -428,11 +431,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 => {
         // 鍐呴儴璇锋眰
@@ -456,7 +461,8 @@
               this.execError(res)
               resolve(false)
             }
-          }, () => {
+          }, (error) => {
+            if (error && error.ErrCode === 'LoginError') return
             this.execError({})
           })
         } else {
@@ -468,8 +474,8 @@
         _outParam = fromJS(res).toJS()
 
         if (window.GLOB.mkHS) {
-          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
-            param.rduri = options.cloudServiceApi
+          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') {
@@ -490,6 +496,7 @@
             } else {
               param.$token = btn.exInterface || ''
             }
+            ver_token = true
           } else {
             if (window.GLOB.systemType === 'production' && btn.proInterface) {
               param.rduri = btn.proInterface
@@ -516,9 +523,11 @@
 
         return Api.genericInterface(res)
       }).then(response => {
-        if (!response) return
+        if (!response || response.ErrCode === 'LoginError') return
         // 鍥炶皟璇锋眰
-        if (btn.callbackFunc) {
+        if (ver_token && response.ErrMesg === 'token_error') {
+          this.execError(response)
+        } else if (btn.callbackFunc ) {
           // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤
           delete response.message
           delete response.status
@@ -535,7 +544,7 @@
           }
         }
       }).then(res => {
-        if (!res) return
+        if (!res || res.ErrCode === 'LoginError') return
 
         if (res.status) {
           this.execSuccess(res)

--
Gitblit v1.8.0