From 81c3fd3ac5017591d987d9c9fe42042fae5c7d7d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 30 十一月 2021 14:30:47 +0800
Subject: [PATCH] 2021-11-30

---
 src/views/mobdesign/index.jsx |   86 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index 0de7b33..d4474f5 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -734,14 +734,6 @@
                 title: cell.label,
               })
             })
-            card.backElements && card.backElements.forEach(cell => {
-              if (cell.eleType !== 'button') return
-              this.checkBtn(cell)
-              m.children.push({
-                key: cell.uuid,
-                title: cell.label,
-              })
-            })
           })
         } else if (item.type === 'carousel' || item.type === 'timeline') {
           item.subcards.forEach(card => {
@@ -835,10 +827,86 @@
   }
 
   getMiniStyle = (config) => {
-    console.log(config)
+    config.miniStyle = this.transferStyle(config.style)
+
+    let traversal = (components) => {
+      return components.map(item => {
+        if (item.style) {
+          item.miniStyle = this.transferStyle(item.style)
+        }
+        if (item.headerStyle) {
+          item.miniHeaderStyle = this.transferStyle(item.headerStyle)
+        }
+
+        if (item.action && item.action.length > 0) {
+          item.action = item.action.map(btn => {
+            btn.miniStyle = this.transferStyle(btn.style)
+            return btn
+          })
+        }
+
+        if (item.type === 'tabs') {
+          item.subtabs.forEach(tab => {
+            tab.components = traversal(tab.components)
+          })
+        } else if (item.type === 'group') {
+          item.components = traversal(item.components)
+        } else if (['card', 'carousel', 'timeline'].includes(item.type) || (item.type === 'table' && item.subtype === 'tablecard')) {
+          item.subcards.forEach(card => {
+            card.miniStyle = this.transferStyle(card.style)
+            card.elements = card.elements.map(cell => {
+              cell.miniStyle = this.transferStyle(cell.style)
+              return cell
+            })
+          })
+        } else if (item.type === 'balcony') {
+          item.elements && item.elements.forEach(cell => {
+            cell.miniStyle = this.transferStyle(cell.style)
+          })
+        } else if (item.type === 'menubar') {
+          item.subMenus = item.subMenus.map(menu => {
+            menu.miniStyle = this.transferStyle(menu.style)
+            return menu
+          })
+        } else if (item.type === 'table' && item.subtype === 'normaltable') {
+          let getCols = (cols) => {
+            return cols.map(col => {
+              if (col.type === 'colspan') {
+                col.subcols = getCols(col.subcols || [])
+              } else if (col.type === 'custom' || col.type === 'action') {
+                col.elements = col.elements.map(cell => {
+                  cell.miniStyle = this.transferStyle(cell.style)
+                  return cell
+                })
+              }
+  
+              return col
+            })
+          }
+          
+          item.cols = getCols(item.cols)
+        }
+
+        return item
+      })
+    }
+
+    config.components = traversal(config.components)
+
     return config
   }
 
+  transferStyle = (style = {}) => {
+    let _style = ''
+    Object.keys(style).forEach(key => {
+      if (['hShadow', 'vShadow', 'shadowBlur', 'shadowColor'].includes(key)) return
+      if (!style[key]) return
+      _style += `${key.replace(/[A-Z]/g, m => '-' + m.toLowerCase())}:${style[key]};`
+    })
+
+    return _style
+  }
+
   submitConfig = () => {
     let config = fromJS(this.state.config).toJS()
 

--
Gitblit v1.8.0