From 46aa44856bcb0e262d98918e06b4f83d2c11777a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 15 四月 2023 14:32:02 +0800
Subject: [PATCH] 2023-04-15

---
 src/tabviews/custom/popview/index.jsx |  188 +++++++++++++++++-----------------------------
 1 files changed, 71 insertions(+), 117 deletions(-)

diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx
index 7c3ba68..903d3c9 100644
--- a/src/tabviews/custom/popview/index.jsx
+++ b/src/tabviews/custom/popview/index.jsx
@@ -329,17 +329,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
               })
             }
@@ -377,30 +367,13 @@
         item.action = item.action.filter(cell => {
           if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
 
-          cell.logLabel = item.$menuname + '-' + cell.label
-          cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-          cell.$menuId = item.uuid
-          cell.$MenuID = Tab.$MenuID
-          cell.$tabId = Tab.uuid
+          cell = this.resetButton(item, cell, Tab)
           cell.$toolbtn = true
 
           if (!mutil && cell.syncComponentId === item.setting.supModule) {
             cell.syncComponentId = ''
             if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
               cell.execSuccess = 'mainline'
-            }
-          }
-
-          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 || '')]
             }
           }
 
@@ -421,12 +394,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$MenuID = Tab.$MenuID
-              cell.$tabId = Tab.uuid
+              cell = this.resetButton(item, cell, Tab)
 
               if (!mutil && cell.syncComponentId === item.setting.supModule) {
                 cell.syncComponentId = ''
@@ -434,23 +402,8 @@
                   cell.execSuccess = 'mainline'
                 }
               }
-              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 true
@@ -462,12 +415,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$MenuID = Tab.$MenuID
-              cell.$tabId = Tab.uuid
+              cell = this.resetButton(item, cell, Tab)
 
               if (!mutil && cell.syncComponentId === item.setting.supModule) {
                 cell.syncComponentId = ''
@@ -475,24 +423,8 @@
                   cell.execSuccess = 'mainline'
                 }
               }
-
-              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 true
@@ -510,11 +442,7 @@
           if (cell.eleType === 'button') {
             if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
 
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$MenuID = Tab.$MenuID
-            cell.$tabId = Tab.uuid
+            cell = this.resetButton(item, cell, Tab)
 
             if (cell.syncComponentId === item.wrap.supModule) {
               cell.syncComponentId = ''
@@ -522,23 +450,8 @@
                 cell.execSuccess = 'mainline'
               }
             }
-            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 true
@@ -549,30 +462,12 @@
           col.elements = col.elements.filter(cell => {
             if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
             
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.Ot = cell.Ot || 'requiredSgl'
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$MenuID = Tab.$MenuID
-            cell.$tabId = Tab.uuid
+            cell = this.resetButton(item, cell, Tab)
 
             if (cell.syncComponentId === item.setting.supModule) {
               cell.syncComponentId = ''
               if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
                 cell.execSuccess = 'mainline'
-              }
-            }
-
-            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 || '')]
               }
             }
 
@@ -671,6 +566,65 @@
     })
   }
 
+  resetButton = (item, cell, Tab) => {
+    cell.logLabel = item.$menuname + '-' + cell.label
+    cell.Ot = cell.Ot || 'requiredSgl'
+    cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
+    cell.$menuId = item.uuid
+    cell.$MenuID = Tab.$MenuID
+    cell.$tabId = Tab.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 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