king
2021-11-17 c51f5e007a3e03c9d6731ab7f28f0080de009990
src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -13,7 +13,7 @@
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import { updateForm } from '@/utils/utils-update.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
// import './index.scss'
const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
const { confirm } = Modal
@@ -37,11 +37,13 @@
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    visible: false,
    formdata: null,
    tabledata: null,
    selines: null,
    btnconfig: null,
    loading: false,
    disabled: false,
    loadingNumber: ''
    hidden: false,
    loadingNumber: '',
    autoMatic: false
  }
  UNSAFE_componentWillMount () {
@@ -55,7 +57,7 @@
          disabled = true
        }
      })
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -64,7 +66,13 @@
  }
  componentDidMount () {
    const { btn } = this.props
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    if (btn.autoMatic) {
      MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -81,7 +89,7 @@
          }
        })
      }
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -90,6 +98,15 @@
      return
    }
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
    MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
  }
  triggerBtnPopSubmit = (id) => {
    const { btn } = this.props
    if (btn.uuid !== id) return
    this.handleOk()
  }
  
  /**
@@ -113,6 +130,8 @@
        return
      }
    }
    this.setState({autoMatic: type === 'autoMatic'})
    let _this = this
    let data = record || selectedData || []
@@ -150,6 +169,10 @@
      return
    }
    this.setState({
      selines: data
    })
    if (btn.execMode === 'pop') {
      let modal = this.state.btnconfig
      if (!modal && btn.modal) {
@@ -158,7 +181,6 @@
      this.setState({
        loading: true,
        tabledata: data,
        btnconfig: modal
      }, () => {
        this.improveAction()
@@ -1206,8 +1228,9 @@
   */
  execSuccess = (res) => {
    const { btn } = this.props
    const { autoMatic } = this.state
    if (res && res.ErrCode === 'S') { // 执行成功
    if ((res && res.ErrCode === 'S') || autoMatic) { // 执行成功
      notification.success({
        top: 92,
        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
@@ -1220,13 +1243,18 @@
    } else if (res && res.ErrCode === '-1') { // 完成后不提示
    }
    this.setState({
      loading: false
    })
    if (autoMatic) {
      MKEmitter.emit('autoExecOver', btn.uuid, 'success')
      return
    }
    if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
    }
  }
@@ -1238,13 +1266,13 @@
   */
  execError = (res) => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (res.ErrCode === 'E') {
    if (res.ErrCode === 'E' && !autoMatic) {
      Modal.error({
        title: res.message || res.ErrMesg,
      })
    } else if (res.ErrCode === 'N') {
    } else if (res.ErrCode === 'N' || autoMatic) {
      notification.error({
        top: 92,
        message: res.message || res.ErrMesg,
@@ -1265,12 +1293,17 @@
      loading: false
    })
    if (autoMatic) {
      MKEmitter.emit('autoExecOver', btn.uuid, 'error')
      return
    }
    if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) {
      MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus)
    }
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    }
  }
@@ -1313,10 +1346,10 @@
   */
  improveAction = () => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (btnconfig) {
      if (btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示
      if (!autoMatic && btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示
        this.modelconfirm()
      } else {
        this.setState({
@@ -1360,7 +1393,7 @@
          this.setState({
            btnconfig: _LongParam
          }, () => {
            if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
            if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
              this.modelconfirm()
            } else {
              this.setState({
@@ -1377,14 +1410,17 @@
   * @description 模态框(表单),确认
   */
  handleOk = () => {
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (!this.formRef) return
    this.formRef.handleConfirm().then(res => {
      if (btnconfig.setting.finish !== 'unclose') {
      if (btnconfig.setting.finish !== 'unclose' || autoMatic) {
        this.setState({
          visible: false
        })
      }
      this.triggerPrint(this.state.tabledata, res)
      this.triggerPrint(this.state.selines, res)
    })
  }
@@ -1400,7 +1436,7 @@
  modelconfirm = () => {
    const { BData } = this.props
    const { btnconfig, tabledata } = this.state
    const { btnconfig, selines } = this.state
    let _this = this
    let result = []
    
@@ -1415,8 +1451,8 @@
      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
        _initval = BData[item.field]
      } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) {
        _initval = tabledata[0][item.field]
      } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) {
        _initval = selines[0][item.field]
      } else if (item.type === 'date' && _initval) {
        _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD')
      } else if (item.type === 'datemonth' && _initval) {
@@ -1449,7 +1485,7 @@
    confirm({
      title: this.state.dict['main.action.confirm.tip'],
      onOk() {
        _this.triggerPrint(tabledata, result)
        _this.triggerPrint(selines, result)
      },
      onCancel() {
        _this.setState({ loading: false })
@@ -1501,7 +1537,7 @@
          menuType={this.props.menuType}
          action={btnconfig}
          inputSubmit={this.handleOk}
          data={this.state.tabledata[0]}
          data={this.state.selines[0]}
          BData={this.props.BData}
          wrappedComponentRef={(inst) => this.formRef = inst}
        />
@@ -1511,7 +1547,9 @@
  render() {
    const { btn, show } = this.props
    const { loadingNumber, loading, disabled } = this.state
    const { loadingNumber, loading, disabled, hidden } = this.state
    if (hidden) return null
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>