From 08cce3334a2dc81d690b518136b0aaea64e48b0b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 14 六月 2023 09:55:50 +0800
Subject: [PATCH] 2023-06-14

---
 src/tabviews/custom/popview/index.jsx |  375 +++++++++++++++++++++++++---------------------------
 1 files changed, 180 insertions(+), 195 deletions(-)

diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx
index 6149fc0..0093459 100644
--- a/src/tabviews/custom/popview/index.jsx
+++ b/src/tabviews/custom/popview/index.jsx
@@ -97,7 +97,7 @@
 
     // 鏁版嵁缂撳瓨璁剧疆
     if (config.cacheUseful === 'true') {
-      if (!['day', 'hour'].includes(config.timeUnit)) {
+      if (!['day', 'hour', 'minute'].includes(config.timeUnit)) {
         config.timeUnit = 'day'
       }
       config.cacheTime = config.cacheTime || 1
@@ -302,6 +302,29 @@
         item.search = Utils.initSearchVal(item.search)
       }
 
+      if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢
+        item.setting.supModule = item.supNodes[0].componentId
+      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
+        let pid = item.setting.supModule.pop()
+        if (pid && pid !== 'empty') {
+          item.setting.supModule = pid
+        } else {
+          item.setting.supModule = ''
+        }
+      }
+
+      // 鏉冮檺杩囨护
+      if (item.action && item.action.length > 0) {
+        item.action = item.action.filter(cell => {
+          if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
+
+          cell = this.resetButton(item, cell, Tab)
+          cell.$toolbtn = true
+
+          return true
+        })
+      }
+
       if (item.type === 'table') {
         let statFields = []
         let getCols = (cols) => {
@@ -310,6 +333,8 @@
               return false
             } else if (col.Hide === 'true') {
               return false
+            } else if (col.type === 'action') {
+              col.type = 'custom'
             }
             
             if (col.type === 'number') {
@@ -322,26 +347,31 @@
                   col.decimal = col.decimal > 2 ? col.decimal - 2 : 0
                 }
               }
+            } else if (col.type === 'formula') {
+              if (typeof(col.decimal) === 'number') {
+                col.round = Math.pow(10, col.decimal)
+              }
             } else if (col.type === 'colspan') {
               col.subcols = getCols(col.subcols || [])
               if (col.subcols.length === 0) {
                 return false
               }
             } 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
-                    }
-                  }
+              col.elements = col.elements.filter(cell => {
+                if (cell.eleType === 'button') {
+                  if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
+            
+                  cell = this.resetButton(item, cell, Tab)
+                } else {
+                  cell = this.resetElement(cell)
                 }
-                return cell
+
+                return true
               })
+
+              if (col.elements.length === 0) {
+                return false
+              }
             }
       
             if (col.linkmenu && col.linkmenu.length > 0) {
@@ -357,57 +387,20 @@
         
         item.cols = getCols(item.cols)
         item.statFields = statFields
-      }
 
-      let mutil = false
-      if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢
-        mutil = true
-        item.setting.supModule = item.supNodes[0].componentId
-      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
-        let pid = item.setting.supModule.pop()
-        if (pid && pid !== 'empty') {
-          item.setting.supModule = pid
-        } else {
-          item.setting.supModule = ''
+        if (item.subtype === 'editable') {
+          item.submit.logLabel = item.$menuname + '-鎻愪氦'
+          item.submit.$menuId = item.uuid
+          item.submit.syncComponentId = item.submit.syncComponent ? (item.submit.syncComponent.pop() || '') : ''
+
+          if (item.submit.syncComponentId && item.submit.syncComponentId === item.setting.supModule) {
+            item.submit.syncComponentId = ''
+            if (item.submit.execSuccess === 'grid') {
+              item.submit.execSuccess = 'mainline'
+            }
+          }
         }
-      }
-
-      // 鏉冮檺杩囨护
-      if (item.action && item.action.length > 0) {
-        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.$tabId = Tab.uuid
-          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 || '')]
-            }
-          }
-
-          return true
-        })
-      }
-
-      if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
+      } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
         item.subcards && item.subcards.forEach(card => {
           if (card.style.boxShadow) {
             delete card.style.hShadow
@@ -418,78 +411,49 @@
 
           card.elements = card.elements.filter(cell => {
             if (cell.eleType === 'button') {
-              if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+              if (cell.hidden === 'true' || cell.OpenType === 'popview') 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.$tabId = Tab.uuid
-
-              if (!mutil && cell.syncComponentId === item.setting.supModule) {
-                cell.syncComponentId = ''
-                if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
-                  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
-                }
-              }
+              cell = this.resetButton(item, cell, Tab)
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return true
           })
 
+          if (card.setting.click === 'menus') {
+            if (card.menus) {
+              card.menus = card.menus.filter(m => !!m.MenuID)
+              if (card.menus.length === 0) {
+                card.menus = null
+              }
+            }
+            if (!card.menus || item.subtype !== 'datacard' || card.$cardType === 'extendCard') {
+              card.setting.click = ''
+            }
+          } else if (card.setting.click === 'menu') {
+            if (!Array.isArray(card.setting.menu)) {
+              card.setting.click = ''
+            }
+          }
+
+          if (item.subtype === 'dualdatacard' && card.$cardType !== 'extendCard') {
+            if (card.backSetting && card.backSetting.click === 'menu') {
+              if (!Array.isArray(card.backSetting.menu)) {
+                card.backSetting.click = ''
+              }
+            }
+          }
+
           if (!card.backElements || card.backElements.length === 0) return
 
           card.backElements = card.backElements.filter(cell => {
             if (cell.eleType === 'button') {
-              if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+              if (cell.hidden === 'true' || cell.OpenType === 'popview') 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.$tabId = Tab.uuid
-
-              if (!mutil && cell.syncComponentId === item.setting.supModule) {
-                cell.syncComponentId = ''
-                if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
-                  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
-                }
-              }
+              cell = this.resetButton(item, cell, Tab)
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return true
@@ -505,81 +469,15 @@
         }
         item.elements = item.elements.filter(cell => {
           if (cell.eleType === 'button') {
-            if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+            if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
 
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$tabId = Tab.uuid
-
-            if (cell.syncComponentId === item.wrap.supModule) {
-              cell.syncComponentId = ''
-              if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
-                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
-              }
-            }
+            cell = this.resetButton(item, cell, Tab)
+          } else {
+            cell = this.resetElement(cell)
           }
 
           return true
         })
-      } else if (item.type === 'table') {
-        item.cols = item.cols.filter(col => {
-          if (col.type !== 'action') return true
-          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.$tabId = Tab.uuid
-
-            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 || '')]
-              }
-            }
-
-            return true
-          })
-          return col.elements.length !== 0
-        })
-
-        if (item.subtype === 'editable') {
-          item.submit.logLabel = item.$menuname + '-鎻愪氦'
-          item.submit.$menuId = item.uuid
-        }
       } else if (item.type === 'form') {
         item.subcards = item.subcards.map(group => {
           group.subButton.uuid = group.uuid
@@ -593,9 +491,9 @@
             group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
           }
 
-          group.subButton.syncComponentId = group.subButton.syncComponent ? group.subButton.syncComponent.pop() : ''
+          group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
 
-          if (group.subButton.syncComponentId === item.setting.supModule) {
+          if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) {
             group.subButton.syncComponentId = ''
             if (group.subButton.execSuccess === 'grid') {
               group.subButton.execSuccess = 'mainline'
@@ -666,6 +564,93 @@
     })
   }
 
+  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 || '')]
+      }
+    }
+
+    if (cell.syncComponentId) {
+      if (cell.syncComponentId === item.setting.supModule) {
+        cell.syncComponentId = ''
+        if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
+          cell.execSuccess = 'mainline'
+        }
+      } else if (cell.syncComponentId === 'multiComponent') {
+        let ids = cell.syncComponents.map(m => {
+          return m.syncComId.pop() || ''
+        })
+
+        if (item.setting.supModule && ids.includes(item.setting.supModule)) {
+          if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
+            cell.execSuccess = 'mainline'
+          }
+          ids = ids.filter(id => id !== item.setting.supModule)
+        }
+        
+        if (ids.length === 0) {
+          cell.syncComponentId = ''
+        } else {
+          cell.syncComponentIds = ids
+        }
+      }
+    }
+
+    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.type === 'formula' && typeof(cell.decimal) === 'number') {
+        cell.round = Math.pow(10, cell.decimal)
+      }
+    } 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