From e48aea038c964573854c6479999d7838830f1f26 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 11 四月 2023 15:01:38 +0800
Subject: [PATCH] 2023-04-11

---
 src/tabviews/custom/index.jsx |  196 ++++++++++++++++++------------------------------
 1 files changed, 74 insertions(+), 122 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 01ff70b..1074471 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -482,17 +482,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 +520,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 +533,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 +552,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 +564,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 +577,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 +589,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 +608,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 +620,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 +631,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 +643,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]
@@ -849,6 +741,66 @@
     })
   }
 
+  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) => {
     let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
 

--
Gitblit v1.8.0