From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 七月 2021 11:39:39 +0800
Subject: [PATCH] 2021-07-28

---
 src/menu/components/card/cardcellcomponent/index.jsx |  114 ++++++++++++++++++++++++---------------------------------
 1 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx
index 58deb61..e46935d 100644
--- a/src/menu/components/card/cardcellcomponent/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/index.jsx
@@ -34,6 +34,7 @@
 
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    appType: sessionStorage.getItem('appType'),
     card: null,          // 缂栬緫涓厓绱�
     formlist: null,      // 琛ㄥ崟淇℃伅
     elements: null,      // 鎸夐挳缁�
@@ -47,16 +48,25 @@
    */
   UNSAFE_componentWillMount () {
     const { elements } = this.props
+    let _elements = fromJS(elements).toJS()
 
     this.setState({
-      elements: fromJS(elements).toJS()
+      elements: _elements.map(item => {
+        if (item.btnstyle) { // 鍏煎
+          item.style = item.style || {}
+          item.style = {...item.style, ...item.btnstyle}
+          delete item.btnstyle
+        }
+
+        return item
+      })
     })
   }
 
   componentDidMount () {
-    MKEmitter.addListener('cardAddElement', this.cardAddElement)
     MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('submitModal', this.handleSave)
+    MKEmitter.addListener('cardAddElement', this.cardAddElement)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -83,9 +93,9 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('cardAddElement', this.cardAddElement)
     MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('submitModal', this.handleSave)
+    MKEmitter.removeListener('cardAddElement', this.cardAddElement)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
   }
 
@@ -126,12 +136,10 @@
     const { cards, cardCell } = this.props
 
     let _style = element.style ? fromJS(element.style).toJS() : {}
-    let options = ['font', 'border', 'padding', 'margin', 'backgroundColor']
+    let options = ['font', 'border', 'padding', 'margin', 'background']
 
     if (element.eleType === 'button') {
-      if (element.btnstyle) {
-        _style = {..._style, ...element.btnstyle}
-      }
+      options.push('width', 'float')
     } else if (element.eleType === 'picture') {
       options = ['border', 'margin']
     } else if (element.eleType === 'slider') {
@@ -187,6 +195,17 @@
       if (line) {
         _card.innerHeight = fontSize * lineHeight * line
       }
+    } else if (_card.eleType === 'sequence') {
+      _card.style = style
+
+      let fontSize = 14
+      let lineHeight = 1.5
+
+      if (_card.style.fontSize) {
+        fontSize = parseInt(_card.style.fontSize)
+      }
+
+      _card.innerHeight = fontSize * lineHeight
     } else if (_card.eleType === 'barcode') {
       _card.style = style
 
@@ -198,47 +217,7 @@
 
       _card.innerHeight = _card.barHeight + (_card.displayValue === 'true' ? fontSize + 2 : 0)
     } else if (_card.eleType === 'button') { // 鎷嗗垎style
-      let _style = fromJS(style).toJS()
-      _card.style = {}
-
-      if (_style.marginTop) {
-        _card.style.marginTop = _style.marginTop
-        delete _style.marginTop
-      }
-      if (_style.marginBottom) {
-        _card.style.marginBottom = _style.marginBottom
-        delete _style.marginBottom
-      }
-      if (_style.marginLeft) {
-        _card.style.marginLeft = _style.marginLeft
-        delete _style.marginLeft
-      }
-      if (_style.marginRight) {
-        _card.style.marginRight = _style.marginRight
-        delete _style.marginRight
-      }
-      if (_style.paddingTop) {
-        _card.style.paddingTop = _style.paddingTop
-        delete _style.paddingTop
-      }
-      if (_style.paddingBottom) {
-        _card.style.paddingBottom = _style.paddingBottom
-        delete _style.paddingBottom
-      }
-      if (_style.paddingLeft) {
-        _card.style.paddingLeft = _style.paddingLeft
-        delete _style.paddingLeft
-      }
-      if (_style.paddingRight) {
-        _card.style.paddingRight = _style.paddingRight
-        delete _style.paddingRight
-      }
-      if (_style.textAlign) {
-        _card.style.textAlign = _style.textAlign
-        delete _style.textAlign
-      }
-
-      _card.btnstyle = _style
+      _card.style = style
     } else {
       _card.style = style
     }
@@ -259,7 +238,7 @@
    * @description 鍏冪礌缂栬緫锛岃幏鍙栧厓绱犺〃鍗曚俊鎭�
    */
   handleElement = (card) => {
-    const { cards } = this.props
+    const { cards, cardCell } = this.props
 
     if (card.eleType === 'button') {
       this.handleAction(card)
@@ -267,7 +246,7 @@
       this.setState({
         visible: true,
         card: card,
-        formlist: getCardCellForm(card, cards.type)
+        formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell)
       })
     }
   }
@@ -310,7 +289,7 @@
     this.setState({
       actvisible: true,
       card: card,
-      formlist: getActionForm(card, functip, cards.setting, usefulFields, 'card', menulist, modules)
+      formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules)
     })
   }
 
@@ -404,18 +383,18 @@
         if (cell.uuid === res.uuid) {
           res = {...cell, ...res}
           delete res.focus
-          let btnstyle = {}
+          let style = {}
 
-          if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) {
+          if (res.class !== cell.class || res.show !== cell.show || !res.style) {
             if (res.show === 'link' || res.show === 'icon') {
-              btnstyle.color = color[res.class]
-              btnstyle.backgroundColor = 'transparent'
+              style.color = color[res.class]
+              style.backgroundColor = 'transparent'
             } else {
-              btnstyle.color = '#ffffff'
-              btnstyle.backgroundColor = color[res.class]
+              style.color = '#ffffff'
+              style.backgroundColor = color[res.class]
             }
           }
-          res.btnstyle = {...res.btnstyle, ...btnstyle}
+          res.style = {...res.style, ...style}
 
           return res
         }
@@ -436,17 +415,14 @@
    */
   deleteElement = (card) => {
     const { cards, cardCell, side } = this.props
-    const { dict, elements } = this.state
+    const { dict, elements, appType } = this.state
     let _this = this
 
     confirm({
       content: dict['model.confirm'] + dict['model.delete'] + '鍏冪礌鍚楋紵',
       onOk() {
         let _elements = elements.filter(item => item.uuid !== card.uuid)
-
-        if (card.eleType === 'button') {
-          MKEmitter.emit('delButtons', [card.uuid])
-        }
+        
         if (card.OpenType === 'popview' || card.verify || card.modal) {
           card.$parentId = cardCell.uuid
           card.$side = side || ''
@@ -459,6 +435,11 @@
         }, () => {
           _this.props.updateElement(_elements)
         })
+
+        if (card.eleType !== 'button') return
+        if (appType === 'mob' || (appType === 'pc' && card.OpenType !== 'popview')) return
+        
+        MKEmitter.emit('delButtons', [card.uuid])
       },
       onCancel() {}
     })
@@ -500,15 +481,16 @@
 
   handleSubConfig = (item) => {
     const { cards } = this.props
+    const { appType } = this.state
     let btn = fromJS(item).toJS()
 
-    if ((sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') !== 'false')) return
+    if ((sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') === 'true')) return
 
     if (btn.eleType === 'button') {
       if (btn.OpenType === 'pop') {
         if (!btn.modal) {
           btn.modal = {
-            setting: { title: btn.label, width: 60, cols: '2', container: 'view', focus: '', finish: 'close', clickouter: 'unclose', display: 'modal' },
+            setting: { title: btn.label, width: appType === 'mob' ? 100 : 60, cols: '2', container: 'view', focus: '', finish: 'close', clickouter: 'unclose', display: 'modal' },
             tables: [],
             groups: [],
             fields: []
@@ -647,7 +629,7 @@
         >
           <ActionForm
             dict={dict}
-            type="card"
+            type={cards.type === 'balcony' ? '' : 'card'}
             card={card}
             formlist={this.state.formlist}
             inputSubmit={this.handleActionSubmit}

--
Gitblit v1.8.0