king
2023-08-17 c7aece35a62b6e91fd98a625bf0e53f64bfbd18d
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -6,10 +6,7 @@
import ExcelIn from './excelin'
import Utils, { getExcelInSql } from '@/utils/utils.js'
import options from '@/store/options.js'
import Api from '@/api'
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'
@@ -27,7 +24,6 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    loading: false,
    selines: null,
    disabled: false,
@@ -78,7 +74,7 @@
      if (data.length > 0) {
        data.forEach(item => {
          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
          if (btn.controlVals.includes(s)) {
          if (btn.controlVals.includes(s) || item.$lock) {
            disabled = true
          }
        })
@@ -134,7 +130,7 @@
      // 需要选择单行时,校验数据
      notification.warning({
        top: 92,
        message: this.state.dict['main.action.confirm.selectSingleLine'],
        message: '请选择单行数据!',
        duration: 5
      })
      return
@@ -172,20 +168,20 @@
   * 4、模态框执行成功后是否关闭
   * 5、通知主列表刷新
   */
  execSuccess = (res) => {
  execSuccess = (res = {}) => {
    const { btn } = this.props
    if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 执行成功
    if (res.ErrCode === 'S' || !res.ErrCode) { // 执行成功
      notification.success({
        top: 92,
        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
        message: res.message || '执行成功!',
        duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
      })
    } else if (res && res.ErrCode === 'Y') { // 执行成功
    } else if (res.ErrCode === 'Y') { // 执行成功
      Modal.success({
        title: res.ErrMesg || this.state.dict['main.action.confirm.success']
        title: res.message || '执行成功!'
      })
    } else if (res && res.ErrCode === '-1') { // 完成后不提示
    } else if (res.ErrCode === '-1') { // 完成后不提示
    }
@@ -199,12 +195,26 @@
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
    }
    
    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
    if (btn.syncComponentId) {
      if (btn.syncComponentId === 'multiComponent') {
        btn.syncComponentIds.forEach((id, i) => {
          setTimeout(() => {
            MKEmitter.emit('reloadData', id)
          }, 20 * i)
        })
      } else {
        MKEmitter.emit('reloadData', btn.syncComponentId)
      }
    }
    if (btn.switchTab && btn.switchTab.length > 0) {
      let id = btn.switchTab[btn.switchTab.length - 1]
      let node = document.getElementById('tab' + id)
      node && node.click()
    }
    if (btn.execSuccess === 'popclose' && btn.$tabId) { // 标签关闭刷新
      MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
@@ -214,28 +224,32 @@
   * 2、excel导出,失败后取消导出按钮加载中状态
   * 3、通知主列表刷新
   */
  execError = (res) => {
  execError = (res = {}) => {
    const { btn } = this.props
    if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) {
      res.ErrCode = 'E'
    }
    if (res.ErrCode === 'E') {
      Modal.error({
        title: res.message || res.ErrMesg,
        title: res.message || '执行失败!',
      })
    } else if (res.ErrCode === 'N') {
      notification.error({
        top: 92,
        message: res.message || res.ErrMesg,
        message: res.message || '执行失败!',
        duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
      })
    } else if (res.ErrCode === 'F') {
      notification.error({
        className: 'notification-custom-error',
        top: 92,
        message: res.message || res.ErrMesg,
        message: res.message || '执行失败!',
        duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || res.ErrMesg)
      message.error(res.message || '执行失败!')
    }
    
    this.setState({
@@ -246,6 +260,10 @@
      MKEmitter.emit('popclose')
    } else if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    }
    if (btn.execError === 'popclose' && btn.$tabId) { // 标签关闭刷新
      MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
@@ -319,17 +337,7 @@
    if (btn.intertype === 'system') { // 系统存储过程
      param.func = 'sPC_TableData_InUpDe'
      if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
        result.sql = result.sql.replace(/\$@/ig, '/*')
        result.sql = result.sql.replace(/@\$/ig, '*/')
        result.bottom = result.bottom.replace(/\$@/ig, '/*')
        result.bottom = result.bottom.replace(/@\$/ig, '*/')
      } else {
        result.sql = result.sql.replace(/@\$|\$@/ig, '')
        result.bottom = result.bottom.replace(/@\$|\$@/ig, '')
      }
      param.excel_in_type = 'true'
      param.LText1 = Utils.formatOptions(result.insert)
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -377,7 +385,7 @@
          } else if (res.ErrCode === 'C') {
            const _this = this
            confirm({
              title: '继续执行?',
              title: '请确认',
              content: res.message,
              onOk() {
                return new Promise(resolve => {
@@ -398,7 +406,8 @@
          } else {
            this.execError(res)
          }
        }, () => {
        }, (error) => {
          if (error && error.ErrCode === 'LoginError') return
          this.execError({})
        })
      } else {
@@ -408,7 +417,8 @@
          } else {
            this.execError(res)
          }
        }, () => {
        }, (error) => {
          if (error && error.ErrCode === 'LoginError') return
          this.execError({})
        })
      }
@@ -421,11 +431,13 @@
        } else {
          this.execError(res)
        }
      }, () => {
      }, (error) => {
        if (error && error.ErrCode === 'LoginError') return
        this.execError({})
      })
    } else if (btn.intertype === 'outer') { // 外部接口
      let _outParam = null
      let ver_token = false
      new Promise(resolve => {
        // 内部请求
@@ -449,7 +461,8 @@
              this.execError(res)
              resolve(false)
            }
          }, () => {
          }, (error) => {
            if (error && error.ErrCode === 'LoginError') return
            this.execError({})
          })
        } else {
@@ -461,8 +474,8 @@
        _outParam = fromJS(res).toJS()
        if (window.GLOB.mkHS) {
          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
            param.rduri = options.cloudServiceApi
          if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
            param.rduri = window.GLOB.cloudServiceApi
            param.userid = sessionStorage.getItem('CloudUserID') || ''
            param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
          } else if (btn.sysInterface !== 'true') {
@@ -483,6 +496,7 @@
            } else {
              param.$token = btn.exInterface || ''
            }
            ver_token = true
          } else {
            if (window.GLOB.systemType === 'production' && btn.proInterface) {
              param.rduri = btn.proInterface
@@ -509,9 +523,11 @@
        return Api.genericInterface(res)
      }).then(response => {
        if (!response) return
        if (!response || response.ErrCode === 'LoginError') return
        // 回调请求
        if (btn.callbackFunc) {
        if (ver_token && response.ErrMesg === 'token_error') {
          this.execError(response)
        } else if (btn.callbackFunc ) {
          // 存在回调函数时,调用
          delete response.message
          delete response.status
@@ -528,7 +544,7 @@
          }
        }
      }).then(res => {
        if (!res) return
        if (!res || res.ErrCode === 'LoginError') return
        if (res.status) {
          this.execSuccess(res)