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/popupbutton/index.jsx |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx
index f089b72..4c8143f 100644
--- a/src/tabviews/zshare/actionList/popupbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx
@@ -7,6 +7,7 @@
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 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 SubTabTable = asyncSpinComponent(() => import('@/tabviews/subtabtable'))
@@ -22,7 +23,6 @@
     btn: PropTypes.object,            // 鎸夐挳
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     updateStatus: PropTypes.func,     // 鎸夐挳鐘舵�佹洿鏂�
-    triggerBtn: PropTypes.any,
   }
 
   state = {
@@ -33,24 +33,33 @@
     loading: 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, Tab, BID, btn, selectedData } = this.props
+    const { loading } = this.state
+
+    if ((triggerId && btn.uuid !== triggerId) || loading) return
 
     if (Tab && Tab.supMenu && !BID) {
       notification.warning({
@@ -61,13 +70,7 @@
       return
     }
 
-    let data = []
-    
-    if (record) { // 琛ㄦ牸涓Е鍙戞寜閽�
-      data = [record]
-    } else {
-      data = selectedData || []
-    }
+    let data = selectedData || []
 
     if (btn.Ot === 'requiredSgl' && data.length !== 1) {
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
@@ -108,7 +111,6 @@
       primaryId: primaryId,
       visible: true
     })
-    this.props.updateStatus('start')
   }
 
   // 鎿嶄綔鍚庡埛鏂颁富琛�
@@ -135,16 +137,19 @@
     const { loading, popData, primaryId } = this.state
 
     return (
-      <div className="mk-btn-wrap">
-        {!show ? <Button
+      <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
+        {show === 'actionList' ? <Button
           className={'mk-btn mk-' + btn.class}
           icon={btn.icon}
           onClick={() => {this.actionTrigger()}}
           loading={loading}
         >{btn.label}</Button> : null}
-        {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null}
-        {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
-        {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
+        {['icon', 'text', 'all'].includes(show) ? <Button
+          type="link"
+          loading={loading}
+          icon={show === 'text' ? '' : (btn.icon || '')}
+          onClick={() => {this.actionTrigger()}}
+        >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null}
         <Modal
           className="popview-modal"
           title={btn.label}

--
Gitblit v1.8.0