From 72419e2f826031a158173f46d723a672064e37cd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 31 八月 2021 22:42:51 +0800
Subject: [PATCH] 2021-08-31

---
 src/tabviews/zshare/actionList/excelInbutton/index.jsx |   62 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index 988d6f9..e943949 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -3,7 +3,7 @@
 import moment from 'moment'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Button, Modal, notification, message } from 'antd'
+import { Button, Modal, notification, message, Icon } from 'antd'
 
 import ExcelIn from './excelin'
 import Utils, { getExcelInSql } from '@/utils/utils.js'
@@ -28,7 +28,23 @@
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     loading: false,
+    disabled: false,
     primaryId: '',
+  }
+
+  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) {
@@ -40,6 +56,24 @@
 
     if (position === 'toolbar') {
       MKEmitter.addListener('triggerBtnId', this.actionTrigger)
+    }
+  }
+
+  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})
     }
   }
 
@@ -74,7 +108,7 @@
 
     if ((triggerId && btn.uuid !== triggerId) || loading) return
 
-    if (Tab && Tab.supMenu && !BID) {
+    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
       notification.warning({
         top: 92,
         message: '闇�瑕佷笂绾т富閿�硷紒',
@@ -408,28 +442,46 @@
 
   render() {
     const { btn, show } = this.props
-    const { loading } = this.state
+    const { loading, disabled } = this.state
 
     if (show === 'actionList') {
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           icon={btn.icon}
           loading={loading}
+          disabled={disabled}
           className={'mk-btn mk-' + btn.class}
           onClick={() => {this.actionTrigger()}}
         >{btn.label}</Button>
         <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
       </div>
     } else { // icon銆乼ext銆� all 鍗$墖
+      let label = ''
+      let icon = ''
+
+      if (show === 'button') {
+        label = btn.label
+        icon = btn.icon || ''
+      } else if (show === 'link') {
+        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+        icon = ''
+      } else if (show === 'icon') {
+        icon = btn.icon || 'upload'
+      // } else if (show === 'text') {
+      } else {
+        label = btn.label
+      }
+
       return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
         <Button
           type="link"
           title={show === 'icon' ? btn.label : ''}
           loading={loading}
+          disabled={disabled}
           style={btn.style}
-          icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'upload') : (btn.icon || ''))}
+          icon={icon}
           onClick={() => {this.actionTrigger()}}
-        >{show === 'icon' ? '' : btn.label}</Button>
+        >{label}</Button>
         <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
       </div>
     }

--
Gitblit v1.8.0