From f895e8af9e6a393f71fec0dc26fdf1b9b6616cb4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 11 十二月 2020 18:53:04 +0800
Subject: [PATCH] 2020-12-11

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

diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx
index ed96872..76e3bd6 100644
--- a/src/menu/components/card/cardcellcomponent/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/index.jsx
@@ -65,6 +65,7 @@
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
+    const { cards } = this.props
     if (this.props.side !== nextProps.side) {
       this.setState({
         elements: fromJS(nextProps.elements).toJS()
@@ -72,6 +73,10 @@
     } else if (nextProps.elements.length === 0 && this.state.elements.length > 0) {
       this.setState({
         elements: []
+      })
+    } else if (cards.subtype === 'normaltable' && this.state.elements.length > nextProps.elements.length) { // 琛ㄦ牸涓寜閽Щ鍑�
+      this.setState({
+        elements: fromJS(nextProps.elements).toJS()
       })
     }
   }
@@ -416,12 +421,26 @@
    */
   handleActionSubmit = () => {
     const { elements } = this.state
+    let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' }
 
     this.actionFormRef.handleConfirm().then(res => {
       let _elements = elements.map(cell => {
         if (cell.uuid === res.uuid) {
           res = {...cell, ...res}
           delete res.focus
+          let btnstyle = {}
+
+          if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) {
+            if (res.show === 'link' || res.show === 'icon') {
+              btnstyle.color = color[res.class]
+              btnstyle.backgroundColor = 'transparent'
+            } else {
+              btnstyle.color = '#ffffff'
+              btnstyle.backgroundColor = color[res.class]
+            }
+          }
+          res.btnstyle = {...res.btnstyle, ...btnstyle}
+
           return res
         }
         return cell
@@ -541,6 +560,25 @@
     })
   }
 
+  dropButton = (id) => {
+    const { cards } = this.props
+    let index = cards.action.findIndex(item => item.uuid === id)
+
+    if (index === -1) return
+
+    let btn = cards.action[index]
+    btn.eleType = 'button'
+
+    let _elements = [...this.state.elements, btn]
+    let _action = cards.action.filter(item => item.uuid !== id)
+
+    this.setState({
+      elements: _elements
+    }, () => {
+      this.props.updateElement(_elements, _action)
+    })
+  }
+
   render() {
     const { cards } = this.props
     const { elements, visible, actvisible, profVisible, card, dict } = this.state
@@ -552,6 +590,7 @@
           handleList={this.handleList}
           handleMenu={this.handleElement}
           handleStyle={this.handleStyle}
+          dropButton={this.dropButton}
           profileAction={this.profileAction}
           handleSubConfig={this.handleSubConfig}
           deleteMenu={this.deleteElement}

--
Gitblit v1.8.0