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/printbutton/index.jsx |   66 ++++++++++++++++++--------------
 1 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 7e01db0..d7c2078 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -11,6 +11,7 @@
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
@@ -29,7 +30,6 @@
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
     updateStatus: PropTypes.func,     // 鎸夐挳鐘舵�佹洿鏂�
-    triggerBtn: PropTypes.any,
   }
 
   state = {
@@ -42,17 +42,23 @@
     loadingNumber: ''
   }
 
-  /**
-   * @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)
   }
 
   /**
@@ -63,20 +69,21 @@
       this.setState({
         loading: true
       })
-      this.props.updateStatus('start')
     } else if (type === 'over') {
       this.setState({
         loading: false
       })
-      this.props.updateStatus('over')
     }
   }
   
   /**
    * @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({
@@ -88,13 +95,7 @@
     }
 
     let _this = this
-    let data = []
-    
-    if (record) { // 琛ㄦ牸涓Е鍙戞寜閽�
-      data = [record]
-    } else {
-      data = selectedData || []
-    }
+    let data = selectedData || []
 
     if (btn.Ot !== 'notRequired' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
@@ -1269,20 +1270,27 @@
     const { btn, show } = this.props
     const { loadingNumber, loading } = this.state
 
-    return (
-      <div className="mk-btn-wrap">
-        {!show ? <Button
-          className={'mk-btn mk-' + btn.class}
+    if (show === 'actionList') {
+      return <div style={{display: 'inline-block'}}>
+        <Button
           icon={btn.icon}
-          onClick={() => {this.actionTrigger()}}
           loading={loading}
-        >{loadingNumber ? `(${loadingNumber})` : '' + 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}
+          className={'mk-btn mk-' + btn.class}
+          onClick={() => {this.actionTrigger()}}
+        >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button>
         {this.getModels()}
       </div>
-    )
+    } else { // icon銆乼ext銆� all 鍗$墖
+      return <div style={{display: 'inline-block'}}>
+        <Button
+          type="link"
+          loading={loading}
+          icon={show === 'text' ? '' : (btn.icon || '')}
+          onClick={() => {this.actionTrigger()}}
+        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
+        {this.getModels()}
+      </div>
+    }
   }
 }
 

--
Gitblit v1.8.0