From 3672b83182a648733ff245bd690f170d68cc80a9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 15 五月 2023 17:38:27 +0800
Subject: [PATCH] 2023-05-15

---
 src/tabviews/custom/index.jsx |  277 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 148 insertions(+), 129 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 01ff70b..1ddc4d0 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -70,8 +70,11 @@
     data: null,           // 鍒楄〃鏁版嵁闆�
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 鏍囩椤垫帶鍒�
-    shortcuts: null       // 蹇嵎閿�
+    shortcuts: null,      // 蹇嵎閿�
+    loadinginter: false
   }
+
+  stepInter = null
 
   /**
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
@@ -93,6 +96,7 @@
         config = window.decodeURIComponent(window.atob(result.LongParam))
         config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
         config = JSON.parse(config)
+        config.MenuID = MenuID
       } catch (e) {
         console.warn('Parse Failure')
         config = ''
@@ -200,7 +204,9 @@
 
       config.$cache = config.cacheLocal === 'true'
 
-      config.interfaces = this.formatInterSetting(config.interfaces, regs)
+      let initInters = []
+
+      config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters)
       config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache)
       
       // 鑾峰彇涓绘悳绱㈡潯浠�
@@ -236,8 +242,17 @@
         config.components = this.filterBalcony(config.components, balMap)
       }
 
+      if (initInters.length > 0) {
+        this.stepInter = {
+          MenuID: MenuID,
+          inters: initInters,
+          params: params
+        }
+      }
+
       this.setState({
         BID: BID,
+        loadinginter: this.stepInter !== null,
         shortcuts: shortcuts.length > 0 ? shortcuts : null,
         config,
         mainSearch
@@ -251,7 +266,10 @@
           ele.innerHTML = config.normalcss
           document.getElementsByTagName('head')[0].appendChild(ele)
         }
-        if (params.length === 0) {
+
+        if (this.stepInter) {
+
+        } else if (params.length === 0) {
           setTimeout(() => { // 寤舵椂鍔犺浇鐘舵��
             this.setState({
               loadingview: false
@@ -482,17 +500,7 @@
               }
             } else if (col.type === 'custom') {
               col.elements = col.elements.map(cell => {
-                if (['text', 'number', 'formula'].includes(cell.eleType)) {
-                  if (!cell.height) {
-                    cell.innerHeight = 'auto'
-                  }
-                  if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                    cell.round = Math.pow(10, cell.decimal)
-                    if (cell.format === 'percent') {
-                      cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                    }
-                  }
-                }
+                cell = this.resetElement(cell)
                 return cell
               })
             }
@@ -530,12 +538,8 @@
         item.action = item.action.filter(cell => {
           if (cell.hidden === 'true') return false
 
-          cell.logLabel = item.$menuname + '-' + cell.label
-          cell.ContainerId = this.state.ContainerId
-          cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-          cell.$menuId = item.uuid
-          cell.$MenuID = this.props.MenuID
-          cell.$view = popview
+          cell = this.resetButton(item, cell, popview)
+
           cell.$toolbtn = true
 
           if (!mutil && cell.syncComponentId === item.setting.supModule) {
@@ -547,19 +551,6 @@
 
           if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
             cell = this.getPrinter(cell, item.uuid)
-          }
-
-          if (cell.btnstyle) { // 鍏煎
-            cell.style = cell.style || {}
-            cell.style = {...cell.style, ...cell.btnstyle}
-          }
-
-          if (cell.controlField) {
-            if (/,/ig.test(cell.controlVal)) {
-              cell.controlVals = cell.controlVal.split(',')
-            } else {
-              cell.controlVals = [(cell.controlVal || '')]
-            }
           }
 
           return skip || permAction[cell.uuid]
@@ -579,13 +570,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true') return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.ContainerId = this.state.ContainerId
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$MenuID = this.props.MenuID
-              cell.$view = popview
+              cell = this.resetButton(item, cell, popview)
 
               if (!mutil && cell.syncComponentId === item.setting.supModule) {
                 cell.syncComponentId = ''
@@ -597,23 +582,8 @@
               if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                 cell = this.getPrinter(cell, item.uuid)
               }
-              if (cell.controlField) {
-                if (/,/ig.test(cell.controlVal)) {
-                  cell.controlVals = cell.controlVal.split(',')
-                } else {
-                  cell.controlVals = [(cell.controlVal || '')]
-                }
-              }
-            } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-              if (!cell.height) {
-                cell.innerHeight = 'auto'
-              }
-              if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                cell.round = Math.pow(10, cell.decimal)
-                if (cell.format === 'percent') {
-                  cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                }
-              }
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return cell.eleType !== 'button' || skip || permAction[cell.uuid]
@@ -625,13 +595,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true') return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.ContainerId = this.state.ContainerId
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$MenuID = this.props.MenuID
-              cell.$view = popview
+              cell = this.resetButton(item, cell, popview)
 
               if (!mutil && cell.syncComponentId === item.setting.supModule) {
                 cell.syncComponentId = ''
@@ -643,23 +607,8 @@
               if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                 cell = this.getPrinter(cell, item.uuid)
               }
-              if (cell.controlField) {
-                if (/,/ig.test(cell.controlVal)) {
-                  cell.controlVals = cell.controlVal.split(',')
-                } else {
-                  cell.controlVals = [(cell.controlVal || '')]
-                }
-              }
-            } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-              if (!cell.height) {
-                cell.innerHeight = 'auto'
-              }
-              if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                cell.round = Math.pow(10, cell.decimal)
-                if (cell.format === 'percent') {
-                  cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                }
-              }
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return cell.eleType !== 'button' || skip || permAction[cell.uuid]
@@ -677,12 +626,7 @@
           if (cell.eleType === 'button') {
             if (cell.hidden === 'true') return false
 
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.ContainerId = this.state.ContainerId
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$MenuID = this.props.MenuID
-            cell.$view = popview
+            cell = this.resetButton(item, cell, popview)
 
             if (cell.syncComponentId === item.wrap.supModule) {
               cell.syncComponentId = ''
@@ -694,23 +638,8 @@
             if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
               cell = this.getPrinter(cell, item.uuid)
             }
-            if (cell.controlField) {
-              if (/,/ig.test(cell.controlVal)) {
-                cell.controlVals = cell.controlVal.split(',')
-              } else {
-                cell.controlVals = [(cell.controlVal || '')]
-              }
-            }
-          } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-            if (!cell.height) {
-              cell.innerHeight = 'auto'
-            }
-            if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-              cell.round = Math.pow(10, cell.decimal)
-              if (cell.format === 'percent') {
-                cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-              }
-            }
+          } else {
+            cell = this.resetElement(cell)
           }
 
           return cell.eleType !== 'button' || skip || permAction[cell.uuid]
@@ -720,14 +649,8 @@
           if (col.type !== 'action') return true
           col.elements = col.elements.filter(cell => {
             if (cell.hidden === 'true') return false
-            
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.Ot = cell.Ot || 'requiredSgl'
-            cell.ContainerId = this.state.ContainerId
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$MenuID = this.props.MenuID
-            cell.$view = popview
+
+            cell = this.resetButton(item, cell, popview)
 
             if (cell.syncComponentId === item.setting.supModule) {
               cell.syncComponentId = ''
@@ -738,19 +661,6 @@
 
             if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
               cell = this.getPrinter(cell, item.uuid)
-            }
-
-            if (cell.btnstyle) { // 鍏煎
-              cell.style = cell.style || {}
-              cell.style = {...cell.style, ...cell.btnstyle}
-            }
-
-            if (cell.controlField) {
-              if (/,/ig.test(cell.controlVal)) {
-                cell.controlVals = cell.controlVal.split(',')
-              } else {
-                cell.controlVals = [(cell.controlVal || '')]
-              }
             }
 
             return skip || permAction[cell.uuid]
@@ -805,6 +715,12 @@
 
           return group
         })
+      } else if (item.subtype === 'voucher') {
+        if (item.wrap.supModule && item.wrap.supModule.length > 0) {
+          item.wrap.supModule = item.wrap.supModule.pop()
+        } else {
+          item.wrap.supModule = ''
+        }
       }
       
       return true
@@ -847,6 +763,66 @@
       
       return true
     })
+  }
+
+  resetButton = (item, cell, popview) => {
+    cell.logLabel = item.$menuname + '-' + cell.label
+    cell.Ot = cell.Ot || 'requiredSgl'
+    cell.ContainerId = this.state.ContainerId
+    cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
+    cell.$menuId = item.uuid
+    cell.$MenuID = this.props.MenuID
+    cell.$view = popview
+
+    if (cell.btnstyle) { // 鍏煎
+      cell.style = cell.style || {}
+      cell.style = {...cell.style, ...cell.btnstyle}
+    }
+
+    if (cell.controlField) {
+      if (/,/ig.test(cell.controlVal)) {
+        cell.controlVals = cell.controlVal.split(',')
+      } else {
+        cell.controlVals = [(cell.controlVal || '')]
+      }
+    }
+
+    return cell
+  }
+
+  resetElement = (cell) => {
+    cell.style = cell.style || {}
+    if (['text', 'number', 'formula'].includes(cell.eleType)) {
+      if (!cell.height) {
+        cell.innerHeight = 'auto'
+      }
+
+      cell.innerHeight = cell.innerHeight || 'auto'
+      cell.alignItems = cell.height > 1 ? cell.alignItems : ''
+
+      if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
+        cell.round = Math.pow(10, cell.decimal)
+        if (cell.format === 'percent') {
+          cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
+        }
+      }
+    } else if (cell.eleType === 'icon') {
+      if (!cell.innerHeight) { // 鍏煎
+        let fontSize = 14
+        let lineHeight = 1.5
+  
+        if (cell.style.fontSize) {
+          fontSize = parseInt(cell.style.fontSize)
+        }
+        if (cell.style.lineHeight) {
+          lineHeight = parseFloat(cell.style.lineHeight)
+        }
+  
+        cell.innerHeight = fontSize * lineHeight
+      }
+    }
+
+    return cell
   }
 
   getPrinter = (item, parentId) => {
@@ -989,13 +965,24 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatInterSetting = (inters, regs) => {
+  formatInterSetting = (inters, regs, MenuID, initInters) => {
     if (!inters) return []
 
-    let interfaces = inters.filter(m => m.status === 'true')
+    let initlimit = false
+    let interfaces = inters.filter(m => {
+      if (m.status !== 'true') return false
+
+      if (m.setting.loadlevel === 'init') {
+        initlimit = true
+        initInters.push(m.uuid)
+      }
+
+      return true
+    })
 
     let delay = 15
     return interfaces.map(inter => {
+      inter.MenuID = MenuID
       inter.setting.delay = delay
       delay += 15
 
@@ -1006,6 +993,10 @@
         } else {
           inter.setting.supModule = ''
         }
+      }
+
+      if (initlimit && inter.setting.loadlevel !== 'init') {
+        inter.setting.onload = 'false'
       }
 
       if (inter.setting.interType !== 'system') return inter
@@ -1122,6 +1113,7 @@
   }
 
   componentDidMount () {
+    MKEmitter.addListener('interFinish', this.interFinish)
     MKEmitter.addListener('debugChange', this.debugChange)
     MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu)
@@ -1134,6 +1126,7 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('interFinish', this.interFinish)
     MKEmitter.removeListener('debugChange', this.debugChange)
     MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu)
@@ -1144,6 +1137,30 @@
       this.state.config.interfaces.forEach(m => {
         window.GLOB.CacheData.delete(m.uuid)
       })
+    }
+  }
+
+  interFinish = (MenuID, interId) => {
+    if (!this.stepInter || this.stepInter.MenuID !== MenuID) return
+
+    this.stepInter.inters = this.stepInter.inters.filter(item => item !== interId)
+
+    if (this.stepInter.inters.length === 0) {
+      this.setState({loadinginter: false})
+
+      if (this.stepInter.params.length === 0) {
+        setTimeout(() => { // 寤舵椂鍔犺浇鐘舵��
+          this.setState({
+            loadingview: false
+          })
+        }, 1000)
+      } else {
+        this.loadmaindata(this.stepInter.params)
+      }
+
+      MKEmitter.emit('initFinish', this.stepInter.MenuID)
+
+      this.stepInter = null
     }
   }
 
@@ -1175,6 +1192,8 @@
       })
     }
 
+    this.stepInter = null
+
     this.setState({
       BID: '',              // 椤甸潰璺宠浆鏃舵惡甯D
       loadingview: true,    // 椤甸潰鍔犺浇涓�
@@ -1195,9 +1214,9 @@
   }
 
   getComponents = () => {
-    const { config, BID, data, mainSearch } = this.state
+    const { config, BID, data, mainSearch, loadinginter } = this.state
 
-    if (!config || !config.components) return
+    if (!config || !config.components || loadinginter) return
 
     return config.components.map(item => {
       let style = null

--
Gitblit v1.8.0