From 06404e701a89955958cbf56213e2eec618d8644d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 16 十二月 2020 18:36:16 +0800
Subject: [PATCH] 2020-12-16

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |  129 ++++++++++++++++++------------------------
 1 files changed, 56 insertions(+), 73 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index bae524d..35ea599 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -20,11 +20,12 @@
 class NormalButton extends Component {
   static propTpyes = {
     show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
+    position: PropTypes.any,          // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar
     BID: PropTypes.string,            // 涓昏〃ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
+    style: PropTypes.any,             // 鎸夐挳鏍峰紡
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
     Tab: PropTypes.any,               // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭�
-    MenuID: PropTypes.string,         // 鑿滃崟ID
     btn: PropTypes.object,            // 鎸夐挳
     columns: PropTypes.any,           // 瀛楁鍒�
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
@@ -48,9 +49,9 @@
   }
 
   componentDidMount () {
-    const { show } = this.props
+    const { position } = this.props
 
-    if (show === 'actionList') {
+    if (position === 'toolbar') {
       MKEmitter.addListener('triggerBtnId', this.actionTrigger)
     }
   }
@@ -81,7 +82,7 @@
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (triggerId) => {
+  actionTrigger = (triggerId, record) => {
     const { setting, Tab, BID, btn, selectedData } = this.props
     const { loading } = this.state
 
@@ -97,7 +98,7 @@
     }
 
     let _this = this
-    let data = selectedData || []
+    let data = record || selectedData || []
 
     if (btn.Ot !== 'notRequired' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
@@ -176,8 +177,10 @@
       this.execSubmit(data, () => { this.setState({loading: false})})
     } else if (btn.OpenType === 'pop') {
       this.updateStatus('start')
+
       this.setState({
-        tabledata: data
+        tabledata: data,
+        btnconfig: btn.modal ? btn.modal : this.state.btnconfig
       }, () => {
         this.improveAction()
       })
@@ -223,21 +226,17 @@
             param.ID = primaryId
             param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
 
-            if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+            if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
               param.LText = param.LText.replace(/\$@/ig, '/*')
               param.LText = param.LText.replace(/@\$/ig, '*/')
             } else {
               param.LText = param.LText.replace(/@\$|\$@/ig, '')
             }
 
-            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-            param.LText2 = LText2
-            param.LText1 = LText1
-            param.LText = LText
-
+            param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+            param.secretkey = Utils.encrypt('', param.timestamp)
+            param.LText = Utils.formatOptions(param.LText)
           }
         } else if (btn.OpenType === 'pop') { // 琛ㄥ崟
           if (btn.innerFunc) {
@@ -264,40 +263,32 @@
             param.ID = primaryId || Utils.getguid()
             param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
             
-            if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+            if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
               param.LText = param.LText.replace(/\$@/ig, '/*')
               param.LText = param.LText.replace(/@\$/ig, '*/')
             } else {
               param.LText = param.LText.replace(/@\$|\$@/ig, '')
             }
 
-            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-            param.LText2 = LText2
-            param.LText1 = LText1
-            param.LText = LText
-
+            param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+            param.secretkey = Utils.encrypt('', param.timestamp)
+            param.LText = Utils.formatOptions(param.LText)
           } else if (btn.sql) {
             param.ID = primaryId
             param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
             
-            if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+            if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
               param.LText = param.LText.replace(/\$@/ig, '/*')
               param.LText = param.LText.replace(/@\$/ig, '*/')
             } else {
               param.LText = param.LText.replace(/@\$|\$@/ig, '')
             }
 
-            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-            param.LText2 = LText2
-            param.LText1 = LText1
-            param.LText = LText
-            
+            param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+            param.secretkey = Utils.encrypt('', param.timestamp)
+            param.LText = Utils.formatOptions(param.LText)
           }
         }
 
@@ -307,6 +298,10 @@
           param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
           param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
           param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+        }
+
+        if (param.func === 'sPC_TableData_InUpDe') {
+          param.menuname = btn.logLabel
         }
 
         Api.genericInterface(param).then((res) => {
@@ -351,20 +346,17 @@
               param.ID = primaryId
               param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 鏁版嵁婧�
               
-              if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+              if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
                 param.LText = param.LText.replace(/\$@/ig, '/*')
                 param.LText = param.LText.replace(/@\$/ig, '*/')
               } else {
                 param.LText = param.LText.replace(/@\$|\$@/ig, '')
               }
 
-              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-              param.LText2 = LText2
-              param.LText1 = LText1
-              param.LText = LText
+              param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+              param.secretkey = Utils.encrypt('', param.timestamp)
+              param.LText = Utils.formatOptions(param.LText)
             }
           } else if (btn.OpenType === 'pop') { // 琛ㄥ崟
             if (index !== 0) {
@@ -390,40 +382,32 @@
               param.ID = _formPrimaryId || Utils.getguid()
               param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧�
               
-              if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+              if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
                 param.LText = param.LText.replace(/\$@/ig, '/*')
                 param.LText = param.LText.replace(/@\$/ig, '*/')
               } else {
                 param.LText = param.LText.replace(/@\$|\$@/ig, '')
               }
 
-              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-              param.LText2 = LText2
-              param.LText1 = LText1
-              param.LText = LText
-
+              param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+              param.secretkey = Utils.encrypt('', param.timestamp)
+              param.LText = Utils.formatOptions(param.LText)
             } else if (btn.sql) {
               param.ID = primaryId
               param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧�
               
-              if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+              if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
                 param.LText = param.LText.replace(/\$@/ig, '/*')
                 param.LText = param.LText.replace(/@\$/ig, '*/')
               } else {
                 param.LText = param.LText.replace(/@\$|\$@/ig, '')
               }
 
-              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
-
-              param.LText2 = LText2
-              param.LText1 = LText1
-              param.LText = LText
-
+              param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+              param.secretkey = Utils.encrypt('', param.timestamp)
+              param.LText = Utils.formatOptions(param.LText)
             }
           }
 
@@ -433,6 +417,10 @@
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
             param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
             param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+          }
+
+          if (param.func === 'sPC_TableData_InUpDe') {
+            param.menuname = btn.logLabel
           }
 
           return param
@@ -737,7 +725,7 @@
       this.sendMessage()
     }
 
-    this.props.updateStatus('refresh', btn.execSuccess)
+    this.props.updateStatus('refresh', btn.execSuccess, btn)
   }
 
   sendMessage = () => {
@@ -879,7 +867,7 @@
       loading: false
     })
 
-    this.props.updateStatus('refresh', btn.execError)
+    this.props.updateStatus('refresh', btn.execError, btn)
   }
 
   /**
@@ -939,6 +927,7 @@
           })
           this.updateStatus('over')
         } else {
+          let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
           if (_LongParam.groups.length > 0) {
             _LongParam.groups.forEach(group => {
               group.sublist = group.sublist.map(cell => {
@@ -946,11 +935,15 @@
                 if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                   let _option = Utils.getSelectQueryOptions(cell)
 
-                  if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+                  if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
                     _option.sql = _option.sql.replace(/\$@/ig, '/*')
                     _option.sql = _option.sql.replace(/@\$/ig, '*/')
                   } else {
                     _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
+                  }
+                  // 澶栬仈鏁版嵁搴撴浛鎹�
+                  if (window.GLOB.externalDatabase !== null) {
+                    _option.sql = _option.sql.replace(/@db@/ig, `[${window.GLOB.externalDatabase}]..`)
                   }
 
                   cell.data_sql = Utils.formatOptions(_option.sql)
@@ -960,12 +953,7 @@
 
                 // 瀛楁鏉冮檺榛戝悕鍗�
                 if (!cell.blacklist || cell.blacklist.length === 0) return cell
-
-                let _black = cell.blacklist.filter(v => {
-                  return this.props.permRoles.indexOf(v) !== -1
-                })
-
-                if (_black.length > 0) {
+                if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                   cell.hidden = 'true'
                 }
 
@@ -978,7 +966,7 @@
               if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                 let _option = Utils.getSelectQueryOptions(cell)
 
-                if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+                if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
                   _option.sql = _option.sql.replace(/\$@/ig, '/*')
                   _option.sql = _option.sql.replace(/@\$/ig, '*/')
                 } else {
@@ -992,12 +980,7 @@
 
               // 瀛楁鏉冮檺榛戝悕鍗�
               if (!cell.blacklist || cell.blacklist.length === 0) return cell
-
-              let _black = cell.blacklist.filter(v => {
-                return this.props.permRoles.indexOf(v) !== -1
-              })
-
-              if (_black.length > 0) {
+              if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                 cell.hidden = 'true'
               }
 
@@ -1164,12 +1147,13 @@
   }
 
   render() {
-    const { btn, show } = this.props
+    const { btn, show, style } = this.props
     const { loadingNumber, loading } = this.state
 
     if (show === 'actionList') {
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
+          style={style}
           icon={btn.icon}
           loading={loading}
           className={'mk-btn mk-' + btn.class}
@@ -1193,6 +1177,7 @@
         <Button
           type="link"
           loading={loading}
+          style={btn.btnstyle || style}
           icon={show === 'text' ? '' : (btn.icon || '')}
           onClick={() => {this.actionTrigger()}}
         >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
@@ -1205,9 +1190,7 @@
 const mapStateToProps = (state) => {
   return {
     tabviews: state.tabviews,
-    menuType: state.editLevel,
-    permRoles: state.permRoles,
-    dataManager: state.dataManager
+    menuType: state.editLevel
   }
 }
 

--
Gitblit v1.8.0