From 87c445887fe8d724ea124535234df974d3e1d58e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 19 六月 2021 13:17:48 +0800
Subject: [PATCH] 2021-06-19

---
 src/tabviews/zshare/actionList/popupbutton/index.jsx |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx
index 8861cad..c519a94 100644
--- a/src/tabviews/zshare/actionList/popupbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx
@@ -31,7 +31,23 @@
     visible: false,
     popData: null,
     primaryId: '',
+    disabled: false,
     loading: false,
+  }
+
+  UNSAFE_componentWillMount () {
+    const { btn, selectedData } = this.props
+    let disabled = false
+
+    if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
+      selectedData.forEach(item => {
+        let s = item[btn.controlField] + ''
+        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+          disabled = true
+        }
+      })
+      this.setState({disabled})
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -46,6 +62,24 @@
     }
     MKEmitter.addListener('openNewTab', this.openNewTab)
     MKEmitter.addListener('refreshPopButton', this.refreshPopButton)
+  }
+
+  UNSAFE_componentWillReceiveProps (nextProps) {
+    const { btn, selectedData } = this.props
+
+    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
+      let disabled = false
+
+      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
+        nextProps.selectedData.forEach(item => {
+          let s = item[btn.controlField] + ''
+          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+            disabled = true
+          }
+        })
+      }
+      this.setState({disabled})
+    }
   }
 
   componentWillUnmount () {
@@ -160,13 +194,14 @@
 
   render() {
     const { btn, show } = this.props
-    const { loading, popData, primaryId } = this.state
+    const { loading, popData, primaryId, disabled } = this.state
 
     return (
       <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         {show === 'actionList' ? <Button
           className={'mk-btn mk-' + btn.class}
           icon={btn.icon}
+          disabled={disabled}
           onClick={() => {this.actionTrigger()}}
           loading={loading}
         >{btn.label}</Button> : null}
@@ -174,6 +209,7 @@
           type="link"
           title={show === 'icon' ? btn.label : ''}
           loading={loading}
+          disabled={disabled}
           style={btn.style}
           icon={show === 'text' ? '' : (btn.icon || '')}
           onClick={() => {this.actionTrigger()}}

--
Gitblit v1.8.0