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/actioncomponent/index.jsx |   83 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/menu/actioncomponent/index.jsx b/src/menu/actioncomponent/index.jsx
index aab64b2..0075307 100644
--- a/src/menu/actioncomponent/index.jsx
+++ b/src/menu/actioncomponent/index.jsx
@@ -50,6 +50,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('addButton', this.addButton)
+    MKEmitter.addListener('submitStyle', this.getStyle)
   }
 
   /**
@@ -75,6 +76,41 @@
       return
     }
     MKEmitter.removeListener('addButton', this.addButton)
+    MKEmitter.removeListener('submitStyle', this.getStyle)
+  }
+
+  getStyle = (comIds, style) => {
+    const { config } = this.props
+    const { card, actionlist } = this.state
+
+    if (comIds.length !== 2 || comIds[0] !== config.uuid) return
+
+    let _card = fromJS(card).toJS()
+    _card.btnstyle = style
+
+    let _actionlist = actionlist.map(cell => {
+      if (cell.uuid === _card.uuid) return _card
+      return cell
+    })
+
+    this.setState({
+      actionlist: _actionlist
+    }, () => {
+      this.props.updateaction({...config, action: _actionlist})
+    })
+  }
+
+  changeBtnStyle = (element) => {
+    const { config } = this.props
+
+    let _style = element.btnstyle ? fromJS(element.btnstyle).toJS() : {}
+    let options = ['font', 'border', 'background']
+
+    this.setState({
+      card: element
+    })
+
+    MKEmitter.emit('changeStyle', [config.uuid, element.uuid], options, _style)
   }
 
   addButton = (cardId, element) => {
@@ -225,8 +261,9 @@
    */
   handleSubmit = () => {
     const { config } = this.props
+    let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' }
     let _actionlist = fromJS(this.state.actionlist).toJS()
-
+    
     this.actionFormRef.handleConfirm().then(btn => {
       _actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid)
 
@@ -237,6 +274,17 @@
         }
 
         if (item.uuid === btn.uuid) {
+          btn.btnstyle = item.btnstyle || {}
+
+          if (btn.class !== item.class || btn.show !== item.show || !btn.btnstyle.color) {
+            if (btn.show === 'link' || btn.show === 'icon') {
+              btn.btnstyle.color = color[btn.class]
+              btn.btnstyle.background = 'transparent'
+            } else {
+              btn.btnstyle.color = '#ffffff'
+              btn.btnstyle.background = color[btn.class]
+            }
+          }
           return btn
         } else {
           return item
@@ -417,18 +465,49 @@
     }
   }
 
+  dropButton = (id) => {
+    let config = fromJS(this.props.config).toJS()
+
+    let btn = null
+    if (config.subtype === 'normaltable') {
+      config.cols.forEach(col => {
+        if (col.type !== 'action') return
+
+        col.elements = col.elements.filter(item => {
+          if (item.uuid === id) {
+            btn = item
+          }
+          return item.uuid !== id
+        })
+      })
+    }
+
+    if (!btn) return
+
+    btn.Ot = 'requiredSgl'
+    config.action.push(btn)
+
+    this.setState({
+      actionlist: config.action
+    }, () => {
+      this.props.updateaction(config)
+    })
+  }
+
   render() {
     const { config } = this.props
     const { actionlist, visible, card, dict, profVisible } = this.state
 
     return (
-      <div className={'model-menu-action-list length' + actionlist.length}>
+      <div className={'model-menu-action-list'}>
         <DragElement
           list={actionlist}
           handleList={this.handleList}
+          dropButton={this.dropButton}
           handleMenu={this.handleAction}
           deleteMenu={this.deleteElement}
           profileMenu={this.profileAction}
+          changeBtnStyle={this.changeBtnStyle}
           doubleClickCard={this.btnDoubleClick}
         />
         {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */}

--
Gitblit v1.8.0