king
2022-01-02 bde2916433c7830e2879e6524e32b9f6c8bd0bab
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,          // 按钮位置,工具栏为toolbar
    BID: PropTypes.string,            // 主表ID
    BData: PropTypes.any,             // 主表数据
    selectedData: PropTypes.any,      // 子表中选择数据
@@ -31,6 +31,7 @@
    btn: PropTypes.object,            // 按钮
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    disabled: PropTypes.any,          // 行按钮禁用
  }
  state = {
@@ -47,7 +48,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 +58,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 +92,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 +105,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})
    }
  }
@@ -1349,7 +1381,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 +1425,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 +1532,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 })
        }
      })
    }
  }
  /**
@@ -1588,7 +1624,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 || ''