From 4e570c993e66a47ead0f83de76b63b0a2f8c5446 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 05 六月 2023 17:28:16 +0800
Subject: [PATCH] 2023-06-05

---
 src/tabviews/zshare/actionList/excelInbutton/index.jsx |  200 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 133 insertions(+), 67 deletions(-)

diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index 97a19f4..2abe56f 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -14,6 +14,8 @@
 import MkIcon from '@/components/mk-icon'
 // import './index.scss'
 
+const { confirm } = Modal
+
 class ExcelInButton extends Component {
   static propTpyes = {
     BID: PropTypes.string,            // 涓昏〃ID
@@ -34,31 +36,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})
     }
   }
@@ -72,36 +54,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})
     }
   }
 
@@ -110,6 +68,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})
   }
   
   /**
@@ -204,8 +199,18 @@
       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)
@@ -301,7 +306,7 @@
       })
     }
 
-    let result = getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''))
+    let result = getExcelInSql(btn, data, (this.props.BID || ''), this.state.primaryId)
 
     if (result.errors) {
       notification.warning({
@@ -337,29 +342,86 @@
       
       param.excel_in_type = 'true'
       param.LText1 = Utils.formatOptions(result.insert)
-      param.LText2 = Utils.formatOptions(result.bottom)
-      param.LText = Utils.formatOptions(result.sql)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.LText2 = result.bottom
+      param.LText = result.sql
+
+      let unCheckParam = null
+
+      if (/\$check@|@check\$/ig.test(param.LText2) || /\$check@|@check\$/ig.test(param.LText)) {
+        unCheckParam = fromJS(param).toJS()
+        param.LText = param.LText.replace(/\$check@|@check\$/ig, '')
+        param.LText2 = param.LText2.replace(/\$check@|@check\$/ig, '')
+      }
+
+      param.LText2 = Utils.formatOptions(param.LText2)
+      param.LText = Utils.formatOptions(param.LText)
       param.secretkey = Utils.encrypt(param.LText, param.timestamp)
       if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
       }
 
       param.menuname = btn.logLabel
-
+      
       if (window.GLOB.probation) {
         param.s_debug_type = 'Y'
       }
 
-      Api.genericInterface(param).then((res) => {
-        if (res.status) {
-          this.execSuccess(res)
-        } else {
-          this.execError(res)
+      if (unCheckParam) {
+        unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/')
+        unCheckParam.LText = Utils.formatOptions(unCheckParam.LText)
+        unCheckParam.LText2 = unCheckParam.LText2.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/')
+        unCheckParam.LText2 = Utils.formatOptions(unCheckParam.LText2)
+
+        unCheckParam.secretkey = Utils.encrypt(unCheckParam.LText, 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: '缁х画鎵ц锛�',
+              content: res.message,
+              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)
+          }
+        }, () => {
+          this.execError({})
+        })
+      } else {
+        Api.genericInterface(param).then((res) => {
+          if (res.status) {
+            this.execSuccess(res)
+          } else {
+            this.execError(res)
+          }
+        }, () => {
+          this.execError({})
+        })
+      }
     } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋�
       param.func = btn.innerFunc
 
@@ -374,6 +436,7 @@
       })
     } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛
       let _outParam = null
+      let ver_token = false
 
       new Promise(resolve => {
         // 鍐呴儴璇锋眰
@@ -431,6 +494,7 @@
             } else {
               param.$token = btn.exInterface || ''
             }
+            ver_token = true
           } else {
             if (window.GLOB.systemType === 'production' && btn.proInterface) {
               param.rduri = btn.proInterface
@@ -459,7 +523,9 @@
       }).then(response => {
         if (!response) return
         // 鍥炶皟璇锋眰
-        if (btn.callbackFunc) {
+        if (ver_token && response.ErrMesg === 'token_error') {
+          this.execError(response)
+        } else if (btn.callbackFunc ) {
           // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤
           delete response.message
           delete response.status

--
Gitblit v1.8.0