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/normalbutton/index.jsx |   97 ++++++++++++++++++++++++++----------------------
 1 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 21966a1..bae524d 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/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 = {
@@ -43,17 +43,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)
   }
 
   /**
@@ -64,21 +70,22 @@
       this.setState({
         loading: true
       })
-      this.props.updateStatus('start')
     } else if (type === 'over') {
       this.setState({
         loading: false,
         visible: 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({
@@ -90,13 +97,7 @@
     }
 
     let _this = this
-    let data = []
-    
-    if (record) { // 琛ㄦ牸涓Е鍙戞寜閽�
-      data = [record]
-    } else {
-      data = selectedData || []
-    }
+    let data = selectedData || []
 
     if (btn.Ot !== 'notRequired' && data.length === 0) {
       // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹�
@@ -725,21 +726,18 @@
 
     }
     
-    let _unclose = false
     if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
       this.setState({
         loading: false,
         visible: false
       })
-    } else {
-      _unclose = true
     }
 
     if (btn.verify && btn.verify.noteEnable === 'true') {
       this.sendMessage()
     }
 
-    this.props.updateStatus('refresh', btn.execSuccess, _unclose)
+    this.props.updateStatus('refresh', btn.execSuccess)
   }
 
   sendMessage = () => {
@@ -855,7 +853,6 @@
    */
   execError = (res) => {
     const { btn } = this.props
-    const { btnconfig } = this.state
 
     if (res.ErrCode === 'E') {
       Modal.error({
@@ -878,16 +875,11 @@
       message.error(res.message || res.ErrMesg)
     }
 
-    let _unclose = false
-    if (btn.OpenType === 'pop' && btnconfig && btnconfig.setting.display !== 'prompt') {
-      _unclose = true
-    } else {
-      this.setState({
-        loading: false
-      })
-    }
+    this.setState({
+      loading: false
+    })
 
-    this.props.updateStatus('refresh', btn.execError, _unclose)
+    this.props.updateStatus('refresh', btn.execError)
   }
 
   /**
@@ -1175,21 +1167,38 @@
     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'}} onClick={(e) => e.stopPropagation()}>
+        <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}
-        {show && show.indexOf('plus') > -1 ? <Button className="action-cell" style={{fontSize: show.substring(4) + 'px'}} icon={btn.icon || 'plus'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null}
+          className={'mk-btn mk-' + btn.class}
+          onClick={() => {this.actionTrigger()}}
+        >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button>
         {this.getModels()}
       </div>
-    )
+    } else if (show && show.indexOf('plus') > -1) {
+      return <div className="mk-btn-wrap">
+        <Button
+          type="link"
+          loading={loading}
+          icon={btn.icon || 'plus'}
+          style={{fontSize: show.substring(4) + 'px'}}
+          onClick={() => {this.actionTrigger()}}
+        ></Button>
+        {this.getModels()}
+      </div>
+    } else { // icon銆乼ext銆� all 鍗$墖
+      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
+        <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