From 46f79b491173d284a4900d19e7aecf7509481438 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 一月 2022 17:21:25 +0800
Subject: [PATCH] 2022-01-21

---
 src/tabviews/zshare/actionList/tabbutton/index.jsx |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/src/tabviews/zshare/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx
index 3d77644..42774f4 100644
--- a/src/tabviews/zshare/actionList/tabbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx
@@ -2,21 +2,24 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { Button, notification, Icon } from 'antd'
+import { Button, notification } from 'antd'
 
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import MKEmitter from '@/utils/events.js'
+import MkIcon from '@/components/mk-icon'
 // import './index.scss'
 
 class TabButton extends Component {
   static propTpyes = {
     show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
-    position: PropTypes.any,          // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar
+    BData: PropTypes.any,             // 涓昏〃鏁版嵁
     MenuID: PropTypes.string,         // 鑿滃崟ID
     btn: PropTypes.object,            // 鎸夐挳
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
+    lineId: PropTypes.any,            // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑�
   }
 
   state = {
@@ -27,7 +30,7 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData } = this.props
+    const { btn, selectedData, BData } = this.props
     let disabled = false
 
     if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
@@ -37,7 +40,22 @@
           disabled = true
         }
       })
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+      this.setState({hidden: disabled && btn.control === 'hidden'})
+    } else if (btn.control === 'parent') {
+      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
+        this.setState({hidden: true})
+      } else {
+        let s = BData[btn.controlField] + ''
+        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+          this.setState({hidden: true})
+        } else {
+          this.setState({hidden: false})
+        }
+      }
+    }
+
+    if (this.props.disabled || disabled) {
+      this.setState({disabled: true})
     }
   }
 
@@ -50,11 +68,10 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { btn, selectedData } = this.props
+    const { btn, selectedData, BData } = this.props
 
+    let disabled = false
     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] + ''
@@ -63,7 +80,24 @@
           }
         })
       }
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
+      this.setState({hidden: disabled && btn.control === 'hidden'})
+    } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) {
+      if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) {
+        this.setState({hidden: true})
+      } else {
+        let s = nextProps.BData[btn.controlField] + ''
+        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
+          this.setState({hidden: true})
+        } else {
+          this.setState({hidden: false})
+        }
+      }
+    }
+
+    if (nextProps.disabled || disabled) {
+      this.setState({disabled: true})
+    } else {
+      this.setState({disabled: false})
     }
   }
 
@@ -81,7 +115,13 @@
     const { setting, btn, selectedData } = this.props
     const { disabled } = this.state
 
-    if ((triggerId && btn.uuid !== triggerId) || disabled) return
+    if (disabled) return
+    if (triggerId) {
+      if (btn.uuid !== triggerId) return
+      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
+        return
+      }
+    }
 
     if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
       if (record[0].$Index !== selectedData[0].$Index) {
@@ -189,7 +229,7 @@
         label = btn.label
         icon = btn.icon || ''
       } else if (show === 'link') {
-        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
+        label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
         icon = ''
       } else if (show === 'icon') {
         icon = btn.icon || ''

--
Gitblit v1.8.0