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/printbutton/index.jsx |   87 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 65 insertions(+), 22 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index e16fd39..90ae0dd 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/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, Icon } from 'antd'
+import { Button, Modal, notification, message } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -13,6 +13,7 @@
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
+import MkIcon from '@/components/mk-icon'
 // import './index.scss'
 
 const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
@@ -22,7 +23,6 @@
 class PrintButton extends Component {
   static propTpyes = {
     show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
-    position: PropTypes.any,          // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar
     BID: PropTypes.string,            // 涓昏〃ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
@@ -31,6 +31,8 @@
     btn: PropTypes.object,            // 鎸夐挳
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     ContainerId: PropTypes.any,       // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒�
+    disabled: PropTypes.any,          // 琛屾寜閽鐢�
+    lineId: PropTypes.any,            // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑�
   }
 
   state = {
@@ -47,7 +49,7 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData } = this.props
+    const { btn, selectedData, BData } = this.props
     let disabled = false
 
     if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
@@ -57,7 +59,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})
     }
   }
 
@@ -76,11 +93,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] + ''
@@ -90,6 +106,23 @@
         })
       }
       this.setState({disabled, 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})
     }
   }
 
@@ -116,7 +149,13 @@
     const { Tab, BID, btn, selectedData, setting } = this.props
     const { loading, disabled } = this.state
 
-    if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return
+    if (loading || disabled) return
+    if (triggerId) {
+      if (btn.uuid !== triggerId) return
+      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
+        return
+      }
+    }
 
     if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
       notification.warning({
@@ -1349,7 +1388,7 @@
     const { btnconfig, autoMatic } = this.state
 
     if (btnconfig) {
-      if (!autoMatic && btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+      if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
         this.modelconfirm()
       } else {
         this.setState({
@@ -1393,7 +1432,7 @@
           this.setState({
             btnconfig: _LongParam
           }, () => {
-            if (!autoMatic && _LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+            if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
               this.modelconfirm()
             } else {
               this.setState({
@@ -1500,15 +1539,19 @@
       })
     })
 
-    confirm({
-      title: this.state.dict['main.action.confirm.tip'],
-      onOk() {
-        _this.triggerPrint(selines, result)
-      },
-      onCancel() {
-        _this.setState({ loading: false })
-      }
-    })
+    if (btnconfig.setting.display === 'exec') {
+      this.execSubmit(selines, () => {}, result)
+    } else {
+      confirm({
+        title: this.state.dict['main.action.confirm.tip'],
+        onOk() {
+          _this.triggerPrint(selines, result)
+        },
+        onCancel() {
+          _this.setState({ loading: false })
+        }
+      })
+    }
   }
 
   /**
@@ -1521,7 +1564,7 @@
     if (!this.state.visible || !btnconfig || !btnconfig.setting) return null
 
     let title = btnconfig.setting.title
-    let width = btnconfig.setting.width + 'vw'
+    let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw'
     let clickouter = false
     let container = document.body
 
@@ -1529,7 +1572,7 @@
       (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
       (btnconfig.setting.container === 'tab' && btn.ContainerId)
     ) {
-      width = btnconfig.setting.width + '%'
+      width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%'
       container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
     }
 
@@ -1588,7 +1631,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