From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 15 一月 2021 17:04:42 +0800
Subject: [PATCH] Merge branch 'master' into bms

---
 src/tabviews/custom/index.jsx |  290 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 184 insertions(+), 106 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 10940f8..ac068c0 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import { connect } from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { notification, Spin, Row, Col, Button, message } from 'antd'
+import { notification, Spin, Row, Col } from 'antd'
 import moment from 'moment'
 import md5 from 'md5'
 
@@ -26,10 +26,13 @@
 const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
 const NormalTable = asyncComponent(() => import('./components/table/normal-table'))
 const NormalGroup = asyncComponent(() => import('./components/group/normal-group'))
+const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
+const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
 
 class CustomPage extends Component {
   static propTpyes = {
     param: PropTypes.any,        // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟
+    Tab: PropTypes.string,       // 寮圭獥鏍囩
     MenuID: PropTypes.string,    // 鑿滃崟Id
     MenuNo: PropTypes.string,    // 鑿滃崟鍙傛暟
     MenuName: PropTypes.string   // 鑿滃崟鍚嶇О
@@ -49,7 +52,7 @@
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 鏍囩椤垫帶鍒�
     treevisible: false,   // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒�
-    debug: sessionStorage.getItem('debug') === 'true'
+    shortcuts: null       // 蹇嵎閿�
   }
 
   /**
@@ -66,7 +69,7 @@
 
     if (result.status) {
       let config = ''
-      let userConfig = null
+      let shortcuts = []
 
       try { // 閰嶇疆淇℃伅瑙f瀽
         config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
@@ -78,10 +81,15 @@
       // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆
       if (result.LongParamUser && this.props.menuType !== 'HS') {
         try { // 閰嶇疆淇℃伅瑙f瀽
-          userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
+          let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
+          if (userConfig) {
+            shortcuts = userConfig.action
+            userConfig.printers.forEach(item => {
+              window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
+            })
+          }
         } catch (e) {
           console.warn('Parse Failure')
-          userConfig = null
         }
       }
 
@@ -153,7 +161,7 @@
 
       this.setState({
         BID: BID,
-        userConfig: userConfig,
+        shortcuts,
         config,
         mainSearch
       }, () => {
@@ -166,6 +174,10 @@
         } else {
           this.loadmaindata(params)
         }
+
+        if (!this.props.Tab) {
+          this.setShortcut()
+        }
       })
     } else {
       this.setState({
@@ -176,6 +188,41 @@
         top: 92,
         message: result.message,
         duration: 5
+      })
+    }
+  }
+
+  setShortcut = () => {
+    const { shortcuts } = this.state
+
+    if (!shortcuts || shortcuts.length === 0) {
+      document.onkeydown = () => {}
+      return
+    }
+
+    document.onkeydown = (event) => {
+      let e = event || window.event
+      let keyCode = e.keyCode || e.which || e.charCode
+      let preKey = ''
+
+      if (e.ctrlKey) {
+        preKey = 'ctrl'
+      } else if (e.shiftKey) {
+        preKey = 'shift'
+      } else if (e.altKey) {
+        preKey = 'alt'
+      }
+
+      if (!preKey || !keyCode) return
+
+      let _shortcut = `${preKey}+${keyCode}`
+
+      shortcuts.some(item => {
+        if (item.$shortcut === _shortcut) {
+          MKEmitter.emit('triggerBtnId', item.uuid)
+          return true
+        }
+        return false
       })
     }
   }
@@ -248,90 +295,117 @@
       }
 
       // 鏉冮檺杩囨护
-      if (this.props.menuType !== 'HS') {
-        if (item.action && item.action.length > 0) {
-          item.action = item.action.filter(cell => {
-            cell.logLabel = item.name + '-' + cell.label
-            cell.ContainerId = this.state.ContainerId
-            cell.$menuId = item.uuid
+      let isHS = this.props.menuType === 'HS'
+      let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 寮圭獥鏍囩鎸夐挳Id
+      if (item.action && item.action.length > 0) {
+        item.action = item.action.filter(cell => {
+          cell.logLabel = item.name + '-' + cell.label
+          cell.ContainerId = this.state.ContainerId
+          cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : ''
+          cell.$menuId = item.uuid
+          cell.$tabId = tabId
+          cell.$type = 'CustomPage'
 
-            return permAction[cell.uuid]
-          })
-        }
-        if (item.type === 'card') {
-          item.subcards.forEach(card => {
-            let _hasheight = card.style.height && card.style.height !== 'auto'
+          if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
+            cell = this.getPrinter(cell, item.uuid)
+          }
 
-            if (card.style.shadow) { // 鍗$墖闃村奖
-              card.style.boxShadow = '0 0 4px ' + card.style.shadow
-              delete card.style.shadow
-            }
+          return isHS || permAction[cell.uuid]
+        })
+      }
+      if (item.type === 'card') {
+        item.subcards.forEach(card => {
+          let _hasheight = card.style.height && card.style.height !== 'auto'
 
-            card.elements = card.elements.filter(cell => {
-              if (cell.eleType === 'button') {
-                cell.logLabel = item.name + '-' + cell.label
-                cell.Ot = 'requiredSgl'
-                cell.ContainerId = this.state.ContainerId
-                cell.$menuId = item.uuid
-              } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
-                cell.innerHeight = 'auto'
-              }
+          if (card.style.shadow) { // 鍗$墖闃村奖
+            card.style.boxShadow = '0 0 4px ' + card.style.shadow
+            delete card.style.shadow
+          }
 
-              return cell.eleType !== 'button' || permAction[cell.uuid]
-            })
-            card.backElements = card.backElements.filter(cell => {
-              if (cell.eleType === 'button') {
-                cell.logLabel = item.name + '-' + cell.label
-                cell.Ot = 'requiredSgl'
-                cell.ContainerId = this.state.ContainerId
-                cell.$menuId = item.uuid
-              } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
-                cell.innerHeight = 'auto'
-              }
-              return cell.eleType !== 'button' || permAction[cell.uuid]
-            })
-          })
-        } else if (item.type === 'table' && item.subtype === 'tablecard') {
-          item.subcards.forEach(card => {
-            let _hasheight = card.style.height && card.style.height !== 'auto'
-            card.elements = card.elements.filter(cell => {
-              if (cell.eleType === 'button') {
-                cell.logLabel = item.name + '-' + cell.label
-                cell.Ot = 'requiredSgl'
-                cell.ContainerId = this.state.ContainerId
-                cell.$menuId = item.uuid
-              } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
-                cell.innerHeight = 'auto'
-              }
-              return cell.eleType !== 'button' || permAction[cell.uuid]
-            })
-          })
-        } else if (item.type === 'table' && item.subtype === 'normaltable') {
-          item.cols = item.cols.filter(col => {
-            if (col.type !== 'action') return true
-            col.elements = col.elements.filter(cell => {
+          card.elements = card.elements.filter(cell => {
+            if (cell.eleType === 'button') {
               cell.logLabel = item.name + '-' + cell.label
               cell.Ot = 'requiredSgl'
               cell.ContainerId = this.state.ContainerId
+              cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : ''
               cell.$menuId = item.uuid
+              cell.$tabId = tabId
+              cell.$type = 'CustomPage'
 
-              return permAction[cell.uuid]
-            })
-            return col.elements.length !== 0
+              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
+                cell = this.getPrinter(cell, item.uuid)
+              }
+            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
+              cell.innerHeight = 'auto'
+            }
+
+            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
           })
-        } 
-      } else {
-        if (item.action && item.action.length > 0) {
-          item.action = item.action.map(cell => {
+          card.backElements = card.backElements.filter(cell => {
+            if (cell.eleType === 'button') {
+              cell.logLabel = item.name + '-' + cell.label
+              cell.Ot = 'requiredSgl'
+              cell.ContainerId = this.state.ContainerId
+              cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : ''
+              cell.$menuId = item.uuid
+              cell.$tabId = tabId
+              cell.$type = 'CustomPage'
+
+              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
+                cell = this.getPrinter(cell, item.uuid)
+              }
+            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
+              cell.innerHeight = 'auto'
+            }
+            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+          })
+        })
+      } else if (item.type === 'table' && item.subtype === 'tablecard') {
+        item.subcards.forEach(card => {
+          let _hasheight = card.style.height && card.style.height !== 'auto'
+          card.elements = card.elements.filter(cell => {
+            if (cell.eleType === 'button') {
+              cell.logLabel = item.name + '-' + cell.label
+              cell.Ot = 'requiredSgl'
+              cell.ContainerId = this.state.ContainerId
+              cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : ''
+              cell.$menuId = item.uuid
+              cell.$tabId = tabId
+              cell.$type = 'CustomPage'
+
+              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
+                cell = this.getPrinter(cell, item.uuid)
+              }
+            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
+              cell.innerHeight = 'auto'
+            }
+            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+          })
+        })
+      } else if (item.type === 'table' && item.subtype === 'normaltable') {
+        item.cols = item.cols.filter(col => {
+          if (col.type !== 'action') return true
+          col.elements = col.elements.filter(cell => {
             cell.logLabel = item.name + '-' + cell.label
+            cell.Ot = 'requiredSgl'
+            cell.ContainerId = this.state.ContainerId
+            cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : ''
             cell.$menuId = item.uuid
-            return cell
+            cell.$tabId = tabId
+            cell.$type = 'CustomPage'
+
+            if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
+              cell = this.getPrinter(cell, item.uuid)
+            }
+
+            return isHS || permAction[cell.uuid]
           })
-        }
-      }
+          return col.elements.length !== 0
+        })
+      } 
 
       if (item.setting && item.setting.supModule) {
-        let pid = item.setting.supModule.slice(-1)[0]
+        let pid = item.setting.supModule.pop()
         if (pid && pid !== 'empty') {
           item.setting.supModule = pid
         } else {
@@ -349,6 +423,24 @@
     })
   }
 
+  getPrinter = (item, parentId) => {
+    let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
+
+    if (_item) {
+      item.printer = _item.printer || ''
+      item.verify.defaultPrinter = _item.printer || ''
+      if (item.verify.printerTypeList && _item.printerList) {
+        item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
+          cell.printer = _item.printerList[cell.Value] || ''
+
+          return cell
+        })
+      }
+    }
+
+    return item
+  }
+
   getCols = (cols, roleId, permMenus) => {
     return cols.filter(col => {
       if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
@@ -364,7 +456,7 @@
       }
 
       if (col.linkmenu && col.linkmenu.length > 0) {
-        let menu_id = col.linkmenu.slice(-1)[0]
+        let menu_id = col.linkmenu.pop()
         col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
       } else {
         col.linkThdMenu = ''
@@ -604,33 +696,20 @@
     })
   }
 
-  handleviewconfig = (e) => {
-    e.stopPropagation()
-
-    const { MenuNo } = this.props
-    const { config } = this.state
-
-    if (config && config.funcs && config.funcs.length > 0) {
-      this.setState({
-        treevisible: true
-      })
-    } else {
-      let oInput = document.createElement('input')
-      oInput.value = MenuNo || ''
-      document.body.appendChild(oInput)
-      oInput.select()
-      document.execCommand('Copy')
-      document.body.removeChild(oInput)
-      message.success(this.state.dict['main.copy.success'])
-    }
-  }
-
   reloadMenuView = (menuId) => {
     const { MenuID } = this.props
 
     if (MenuID !== menuId) return
 
     this.reloadview()
+  }
+
+  resetActiveMenu = (menuId) => {
+    const { MenuID, Tab } = this.props
+
+    if (MenuID !== menuId || Tab) return
+
+    this.setShortcut()
   }
 
   UNSAFE_componentWillMount () {
@@ -644,6 +723,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
+    MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu)
   }
 
   /**
@@ -654,6 +734,7 @@
       return
     }
     MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
+    MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu)
   }
 
   reloadview = () => {
@@ -662,7 +743,8 @@
       loadingview: true,    // 椤甸潰鍔犺浇涓�
       viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
       config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
-      loading: false        // 鍒楄〃鏁版嵁鍔犺浇涓�
+      loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
+      shortcuts: null
     }, () => {
       this.loadconfig()
     })
@@ -747,19 +829,15 @@
   }
 
   render() {
-    const { menuType, MenuNo } = this.props
-    const { debug, loadingview, viewlost, config, loading } = this.state
+    const { menuType } = this.props
+    const { loadingview, viewlost, config, loading, shortcuts } = this.state
 
     return (
       <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
         {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null}
         <Row>{this.getComponents()}</Row>
-        {debug && MenuNo && options.sysType !== 'cloud' && menuType !== 'HS' ? <Button
-          icon="copy"
-          shape="circle"
-          className="common-table-copy"
-          onClick={this.handleviewconfig}
-        /> : null}
+        {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
+        {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>
     )

--
Gitblit v1.8.0