From e9e8b1c7b481415714fff9a0d83099fd5a7d6ff0 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 18 五月 2023 17:25:11 +0800
Subject: [PATCH] 2023-05-18

---
 src/views/mobdesign/index.jsx |  104 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 79 insertions(+), 25 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index 1504072..404d210 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -232,6 +232,8 @@
       _btn.config.MenuID = _btn.uuid
       _btn.config.ParentId = card.uuid
       _btn.config.MenuName = _btn.label
+
+      _btn.config.components = this.updateComponents(_btn.config.components || [])
     } else {
       _btn.config = {
         uuid: _btn.uuid,
@@ -298,15 +300,23 @@
       })
     })
 
-    config.cols && config.cols.forEach(col => {
-      if (col.type === 'action') {
-        col.elements.forEach(cell => {
-          if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
-            cell.config = popbtns[cell.uuid]
+    if (config.cols) {
+      let loopCol = (cols) => {
+        cols.forEach(col => {
+          if (col.type === 'colspan') {
+            loopCol(col.subcols)
+          } else if (col.type === 'custom') {
+            col.elements.forEach(cell => {
+              if (cell.eleType !== 'button') return
+              if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
+                cell.config = popbtns[cell.uuid]
+              }
+            })
           }
         })
       }
-    })
+      loopCol(config.cols)
+    }
 
     config.elements && config.elements.forEach(cell => {
       if (cell.eleType !== 'button') return
@@ -604,6 +614,8 @@
           this.setState({
             needUpdate: true
           })
+        } else {
+          config.components = this.updateComponents(config.components)
         }
 
         let navItem = null
@@ -823,6 +835,8 @@
           this.setState({
             needUpdate: true
           })
+        } else {
+          config.components = this.updateComponents(config.components)
         }
 
         config.enabled = false
@@ -921,6 +935,27 @@
     })
   }
 
+  updateComponents = (components) => { // 鍏煎鎬у崌绾� table
+    return components.map(item => {
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(tab => {
+          tab.components = this.updateComponents(tab.components)
+        })
+      } else if (item.type === 'group') {
+        item.components = this.updateComponents(item.components)
+      } else if (item.type === 'table') {
+        item.cols = item.cols.map(col => {
+          if (col.type === 'action') {
+            col.type = 'custom'
+          }
+          return col
+        })
+      }
+
+      return item
+    })
+  }
+
   collectTB = (components) => {
     return components.map(item => {
       if (item.type === 'tabs') {
@@ -939,6 +974,13 @@
 
       if (item.subtype === 'tablecard') { // 鍏煎
         item.type = 'card'
+      } else if (item.type === 'table') {
+        item.cols = item.cols.map(col => {
+          if (col.type === 'action') {
+            col.type = 'custom'
+          }
+          return col
+        })
       }
 
       delete item.tabId
@@ -1081,17 +1123,22 @@
               title: btn.label,
             })
           })
-          item.cols && item.cols.forEach(col => {
-            if (col.type !== 'action') return
-            col.elements.forEach(btn => {
-              if (btn.hidden === 'true') return
-
-              m.children.push({
-                key: btn.uuid,
-                title: btn.label,
-              })
+          let loopCol = (cols) => {
+            cols.forEach(col => {
+              if (col.type === 'colspan') {
+                loopCol(col.subcols)
+              } else if (col.type === 'custom') {
+                col.elements.forEach(cell => {
+                  if (cell.eleType !== 'button' || cell.hidden === 'true') return
+                  m.children.push({
+                    key: cell.uuid,
+                    title: cell.label,
+                  })
+                })
+              }
             })
-          })
+          }
+          loopCol(item.cols)
         }
 
         list.push(m)
@@ -1226,16 +1273,23 @@
               menus.push(menuObj[btn.openmenu])
             }
           })
-          item.cols && item.cols.forEach(col => {
-            if (col.type !== 'action') return
-            col.elements.forEach(btn => {
-              if (btn.linkmenu && menuObj[btn.linkmenu]) {
-                menus.push(menuObj[btn.linkmenu])
-              } else if (btn.openmenu && menuObj[btn.openmenu]) {
-                menus.push(menuObj[btn.openmenu])
+          let loopCol = (cols) => {
+            cols.forEach(col => {
+              if (col.type === 'colspan') {
+                loopCol(col.subcols)
+              } else if (col.type === 'custom') {
+                col.elements.forEach(cell => {
+                  if (cell.eleType !== 'button') return
+                  if (cell.linkmenu && menuObj[cell.linkmenu]) {
+                    menus.push(menuObj[cell.linkmenu])
+                  } else if (cell.openmenu && menuObj[cell.openmenu]) {
+                    menus.push(menuObj[cell.openmenu])
+                  }
+                })
               }
             })
-          })
+          }
+          loopCol(item.cols)
         }
       })
     }
@@ -1299,7 +1353,7 @@
             return cols.map(col => {
               if (col.type === 'colspan') {
                 col.subcols = getCols(col.subcols || [])
-              } else if (col.type === 'custom' || col.type === 'action') {
+              } else if (col.type === 'custom') {
                 col.elements = col.elements.map(cell => {
                   cell.miniStyle = this.transferStyle(cell.style)
                   return cell

--
Gitblit v1.8.0