From 28d65cf7ebfe0dd30ade6973e0634e1c8f663b63 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 十月 2020 16:12:20 +0800
Subject: [PATCH] 2020-10-28

---
 src/tabviews/zshare/actionList/newpagebutton/index.jsx |   60 ++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
index c506d7b..45f5a18 100644
--- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx
+++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -5,6 +5,7 @@
 
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { confirm } = Modal
@@ -16,7 +17,6 @@
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     updateStatus: PropTypes.func,     // 鎸夐挳鐘舵�佹洿鏂�
-    triggerBtn: PropTypes.any,
   }
 
   state = {
@@ -24,32 +24,35 @@
     visible: false
   }
 
-  /**
-   * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮
-   */
-  UNSAFE_componentWillReceiveProps(nextProps) {
-    if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) {
-      this.actionTrigger(nextProps.triggerBtn.data)
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  componentDidMount () {
+    const { show } = this.props
+
+    if (show === 'actionList') {
+      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
     }
   }
 
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
   }
   
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (record) => {
+  actionTrigger = (triggerId) => {
     const { setting, btn, selectedData } = this.props
     const _this = this
-    let data = []
 
-    if (record) { // 琛ㄦ牸涓Е鍙戞寜閽�
-      data = [record]
-    } else {
-      data = selectedData || []
-    }
+    if (triggerId && btn.uuid !== triggerId) return
+
+    let data = selectedData || []
 
     if (btn.Ot === 'requiredSgl' && data.length !== 1) {
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
@@ -128,18 +131,23 @@
   render() {
     const { btn, show } = this.props
 
-    return (
-      <div className="mk-btn-wrap">
-        {!show ? <Button
+    if (show === 'actionList') {
+      return (
+        <Button
           className={'mk-btn mk-' + btn.class}
           icon={btn.icon}
-          onClick={() => {this.actionTrigger()}}
-        >{btn.label}</Button> : null}
-        {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} onClick={() => {this.actionTrigger()}}></Button> : null}
-        {show === 'text' ? <Button className="action-cell" onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
-        {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
-      </div>
-    )
+          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+        >{btn.label}</Button>
+      )
+    } else { // icon銆乼ext銆� all 鍗$墖
+      return (
+        <Button
+          type="link"
+          icon={show === 'text' ? '' : (btn.icon || '')}
+          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
+      )
+    }
   }
 }
 

--
Gitblit v1.8.0