king
2021-11-17 c51f5e007a3e03c9d6731ab7f28f0080de009990
src/tabviews/zshare/actionList/normalbutton/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,13 +37,15 @@
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    visible: false,
    formdata: null,
    tabledata: null,
    selines: null,
    confirmLoading: false,
    btnconfig: null,
    loading: false,
    loadingNumber: '',
    disabled: false,
    checkParam: null
    hidden: false,
    checkParam: null,
    autoMatic: false
  }
  moduleParams = null
@@ -59,7 +61,7 @@
          disabled = true
        }
      })
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -68,13 +70,17 @@
  }
  componentDidMount () {
    const { position } = this.props
    const { position, btn } = this.props
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    if (position === 'form') {
      MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
    }
    MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
    if (btn.autoMatic) {
      MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -91,7 +97,7 @@
          }
        })
      }
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -102,6 +108,15 @@
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
    MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit)
    MKEmitter.removeListener('returnModuleParam', this.resetModuleParam)
    MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
  }
  triggerBtnPopSubmit = (id) => {
    const { btn } = this.props
    if (btn.uuid !== id) return
    this.handleOk()
  }
  actionSubmit = (res) => {
@@ -111,7 +126,7 @@
    this.setState({ loading: true })
    this.execSubmit(this.state.tabledata, () => {}, res.form)
    this.execSubmit(this.state.selines, () => {}, res.form)
  }
  resetModuleParam = (menuId, btnId, param) => {
@@ -154,6 +169,8 @@
        return
      }
    }
    this.setState({autoMatic: type === 'autoMatic'})
    let _this = this
    let data = record || selectedData || []
@@ -228,10 +245,11 @@
      return
    }
    this.setState({
      selines: data
    })
    if (btn.OpenType === 'formSubmit') {
      this.setState({
        tabledata: data
      })
      MKEmitter.emit('mkFormSubmit', btn.uuid)
      return
    } else if (btn.OpenType === 'prompt') {
@@ -258,7 +276,6 @@
      this.setState({
        loading: true,
        tabledata: data,
        btnconfig: modal
      }, () => {
        this.improveAction()
@@ -664,7 +681,18 @@
  }
  execRealSubmit = (data, _resolve, formdata) => {
    const { setting, btn } = this.props
    const { setting, btn, Tab, BID } = this.props
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        duration: 5
      })
      _resolve()
      return
    }
    if (btn.intertype === 'system' || btn.intertype === 'inner') { // 系统接口
      let params = []
@@ -1344,9 +1372,9 @@
   */
  execSuccess = (res) => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, 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'],
@@ -1360,7 +1388,14 @@
    }
    
    if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
    if (autoMatic) {
      this.setState({
        loading: false,
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'success')
      return
    } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
      this.setState({
        loading: false,
        visible: false
@@ -1379,7 +1414,7 @@
    if (btn.execSuccess === 'closetab') {
      MKEmitter.emit('closeTabView', btn.$MenuID)
    } else if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
    }
    if (btn.refreshTab && btn.refreshTab.length > 0) {
@@ -1526,13 +1561,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,
@@ -1547,6 +1582,16 @@
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || res.ErrMesg)
    }
    if (autoMatic) {
      this.setState({
        loading: false,
        loadingNumber: '',
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'error')
      return
    }
    
    this.setState({
@@ -1583,7 +1628,7 @@
              visible: false
            })
            if (btn.execError !== 'never') {
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
            }
          }
        })
@@ -1601,7 +1646,7 @@
    }
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    }
  }
@@ -1644,10 +1689,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({
@@ -1691,7 +1736,7 @@
          this.setState({
            btnconfig: _LongParam
          }, () => {
            if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
            if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
              this.modelconfirm()
            } else {
              this.setState({
@@ -1708,10 +1753,11 @@
   * @description 模态框(表单),确认
   */
  handleOk = () => {
    if (!this.formRef) return
    this.formRef.handleConfirm().then(res => {
      this.setState({ confirmLoading: true })
      this.execSubmit(this.state.tabledata, () => { this.setState({ confirmLoading: false }) }, res)
      this.execSubmit(this.state.selines, () => { this.setState({ confirmLoading: false }) }, res)
    })
  }
@@ -1728,7 +1774,7 @@
  modelconfirm = () => {
    const { BData } = this.props
    const { btnconfig, tabledata } = this.state
    const { btnconfig, selines } = this.state
    let _this = this
    let result = []
@@ -1743,8 +1789,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) {
@@ -1785,7 +1831,7 @@
      title: this.state.dict['main.action.confirm.tip'],
      onOk() {
        return new Promise(resolve => {
          _this.execSubmit(tabledata, resolve, result)
          _this.execSubmit(selines, resolve, result)
        })
      },
      onCancel() {
@@ -1831,7 +1877,7 @@
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
@@ -1874,7 +1920,7 @@
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.tabledata[0]}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
@@ -1885,7 +1931,9 @@
  render() {
    const { btn, show, style } = 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()}>
@@ -1900,7 +1948,7 @@
        {this.getModels()}
      </div>
    } else if (show && show.indexOf('plus') > -1) {
      return <div className="mk-btn-wrap">
      return <div style={{display: 'inline-block'}}>
        <Button
          type="link"
          loading={loading}