From 54d01e6ef9ac31f10de4a0e92824eba50b77eda6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 27 九月 2021 18:40:51 +0800
Subject: [PATCH] 2021-09-27

---
 src/templates/sharecomponent/actioncomponent/index.jsx |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx
index 2a76df0..3d27967 100644
--- a/src/templates/sharecomponent/actioncomponent/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/index.jsx
@@ -16,6 +16,7 @@
 import CreateInterface from '@/templates/zshare/createinterface'
 import { updateForm } from '@/utils/utils-update.js'
 import DragElement from './dragaction'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { confirm } = Modal
@@ -54,24 +55,22 @@
     })
   }
 
-  /**
-   * @description 鐩戝惉鍒版寜閽鍒舵椂锛岃Е鍙戞寜閽紪杈�
-   */
-  UNSAFE_componentWillReceiveProps (nextProps) {
-    const { actionlist } = this.state
-
-    if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
-      let len = nextProps.config.action.length
-      let item = nextProps.config.action[len - 1]
-      if (item && item.focus) {
-        this.handleAction(item)
-      }
-      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
-    }
-  }
-
   componentDidMount () {
     this.getBillPrintTemp()
+    MKEmitter.addListener('pasteButton', this.pasteButton)
+  }
+
+  pasteButton = (MenuId, btn) => {
+    const { config } = this.props
+    const { actionlist } = this.state
+
+    if (MenuId !== config.uuid) return
+
+    this.setState({
+      actionlist: [...actionlist, btn],
+    }, () => {
+      this.handleAction(btn)
+    })
   }
 
   getBillPrintTemp = () => {
@@ -835,7 +834,7 @@
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -845,6 +844,7 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('pasteButton', this.pasteButton)
   }
 
   render() {

--
Gitblit v1.8.0