king
2023-10-04 ae46c8e640ed64abd7605b289554377e0cdc0cb7
src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -168,7 +168,7 @@
        Api.genericInterface(param).then(result => {
          if (result.status) {
            this.exportExcel(result.data)
            this.exportExcel(result.data, result.ErrCode, result.message)
          } else {
            this.execError(result)
          }
@@ -180,9 +180,14 @@
        let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search)
        param.func = btn.innerFunc
        if (btn.recordUser === 'true') {
          param.username = sessionStorage.getItem('User_Name') || ''
          param.fullname = sessionStorage.getItem('Full_Name') || ''
        }
        Api.genericInterface(param).then(result => {
          if (result.status) {
            this.exportExcel(result.data)
            this.exportExcel(result.data, result.ErrCode, result.message)
          } else {
            this.execError(result)
          }
@@ -193,39 +198,25 @@
      } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 使用外部函数
        let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search)
        if (window.GLOB.mkHS) {
          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') {
            if (window.GLOB.systemType === 'production' && btn.proInterface) {
              param.rduri = btn.proInterface
            } else {
              param.rduri = btn.interface
            }
        if (btn.sysInterface === 'true') {
          if (window.GLOB.mainSystemApi) {
            param.rduri = window.GLOB.mainSystemApi
          }
        } else if (btn.sysInterface === 'external') {
          if (window.GLOB.systemType === 'production') {
            param.$token = btn.exProInterface || ''
          } else {
            param.$token = btn.exInterface || ''
          }
        } else {
          if (btn.sysInterface === 'true') {
            if (window.GLOB.mainSystemApi) {
              param.rduri = window.GLOB.mainSystemApi
            }
          } else if (btn.sysInterface === 'external') {
            if (window.GLOB.systemType === 'production') {
              param.$token = btn.exProInterface || ''
            } else {
              param.$token = btn.exInterface || ''
            }
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            param.rduri = btn.proInterface
          } else {
            if (window.GLOB.systemType === 'production' && btn.proInterface) {
              param.rduri = btn.proInterface
            } else {
              param.rduri = btn.interface
            }
            let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
            if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
              param.$login = true
            }
            param.rduri = btn.interface
          }
          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
            param.$login = true
          }
        }
  
@@ -235,7 +226,7 @@
        Api.genericInterface(param).then(result => {
          if (result.status) {
            this.exportExcel(result.data)
            this.exportExcel(result.data, result.ErrCode, result.message)
          } else {
            this.execError(result)
          }
@@ -254,39 +245,25 @@
            delete res.message
            delete res.status
            if (window.GLOB.mkHS) {
              if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
                res.rduri = window.GLOB.cloudServiceApi
                res.userid = sessionStorage.getItem('CloudUserID') || ''
                res.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
              } else if (btn.sysInterface !== 'true') {
                if (window.GLOB.systemType === 'production' && btn.proInterface) {
                  res.rduri = btn.proInterface
                } else {
                  res.rduri = btn.interface
                }
            if (btn.sysInterface === 'true') {
              if (window.GLOB.mainSystemApi) {
                res.rduri = window.GLOB.mainSystemApi
              }
            } else if (btn.sysInterface === 'external') {
              if (window.GLOB.systemType === 'production') {
                res.$token = btn.exProInterface || ''
              } else {
                res.$token = btn.exInterface || ''
              }
            } else {
              if (btn.sysInterface === 'true') {
                if (window.GLOB.mainSystemApi) {
                  res.rduri = window.GLOB.mainSystemApi
                }
              } else if (btn.sysInterface === 'external') {
                if (window.GLOB.systemType === 'production') {
                  res.$token = btn.exProInterface || ''
                } else {
                  res.$token = btn.exInterface || ''
                }
              if (window.GLOB.systemType === 'production' && btn.proInterface) {
                res.rduri = btn.proInterface
              } else {
                if (window.GLOB.systemType === 'production' && btn.proInterface) {
                  res.rduri = btn.proInterface
                } else {
                  res.rduri = btn.interface
                }
                let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
                if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
                  res.$login = true
                }
                res.rduri = btn.interface
              }
              let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
              if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
                res.$login = true
              }
            }
  
@@ -296,7 +273,7 @@
      
            Api.genericInterface(res).then(result => {
              if (result.status) {
                this.exportExcel(result.data)
                this.exportExcel(result.data, result.ErrCode, result.message)
              } else {
                this.execError(result)
              }
@@ -340,39 +317,25 @@
        delete res.message
        delete res.status
        if (window.GLOB.mkHS) {
          if (btn.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
            res.rduri = window.GLOB.cloudServiceApi
            res.userid = sessionStorage.getItem('CloudUserID') || ''
            res.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
          } else if (btn.sysInterface !== 'true') {
            if (window.GLOB.systemType === 'production' && btn.proInterface) {
              res.rduri = btn.proInterface
            } else {
              res.rduri = btn.interface
            }
        if (btn.sysInterface === 'true') {
          if (window.GLOB.mainSystemApi) {
            res.rduri = window.GLOB.mainSystemApi
          }
        } else if (btn.sysInterface === 'external') {
          if (window.GLOB.systemType === 'production') {
            res.$token = btn.exProInterface || ''
          } else {
            res.$token = btn.exInterface || ''
          }
        } else {
          if (btn.sysInterface === 'true') {
            if (window.GLOB.mainSystemApi) {
              res.rduri = window.GLOB.mainSystemApi
            }
          } else if (btn.sysInterface === 'external') {
            if (window.GLOB.systemType === 'production') {
              res.$token = btn.exProInterface || ''
            } else {
              res.$token = btn.exInterface || ''
            }
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            res.rduri = btn.proInterface
          } else {
            if (window.GLOB.systemType === 'production' && btn.proInterface) {
              res.rduri = btn.proInterface
            } else {
              res.rduri = btn.interface
            }
            let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
            if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
              res.$login = true
            }
            res.rduri = btn.interface
          }
          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
          if (res.rduri.indexOf(host) === -1 && /\/dostars/.test(res.rduri)) {
            res.$login = true
          }
        }
@@ -390,7 +353,7 @@
              this.getExcelOutDoubleData(viewParam, pageIndex, pageSize, data)
            } else {
              data = data.concat(result.data)
              this.exportExcel(data)
              this.exportExcel(data, result.ErrCode, result.message)
            }
          } else {
            this.execError(result)
@@ -420,43 +383,34 @@
      param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
      param.func = btn.innerFunc
      if (btn.recordUser === 'true') {
        param.username = sessionStorage.getItem('User_Name') || ''
        param.fullname = sessionStorage.getItem('Full_Name') || ''
      }
    } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 使用外部函数
      param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
      if (window.GLOB.mkHS) {
        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') {
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            param.rduri = btn.proInterface
          } else {
            param.rduri = btn.interface
          }
      if (btn.sysInterface === 'true') {
        if (window.GLOB.mainSystemApi) {
          param.rduri = window.GLOB.mainSystemApi
        }
      } else if (btn.sysInterface === 'external') {
        if (window.GLOB.systemType === 'production') {
          param.$token = btn.exProInterface || ''
        } else {
          param.$token = btn.exInterface || ''
        }
      } else {
        if (btn.sysInterface === 'true') {
          if (window.GLOB.mainSystemApi) {
            param.rduri = window.GLOB.mainSystemApi
          }
        } else if (btn.sysInterface === 'external') {
          if (window.GLOB.systemType === 'production') {
            param.$token = btn.exProInterface || ''
          } else {
            param.$token = btn.exInterface || ''
          }
        if (window.GLOB.systemType === 'production' && btn.proInterface) {
          param.rduri = btn.proInterface
        } else {
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            param.rduri = btn.proInterface
          } else {
            param.rduri = btn.interface
          }
          param.rduri = btn.interface
        }
          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
            param.$login = true
          }
        let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
        if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
          param.$login = true
        }
      }
      
@@ -475,7 +429,7 @@
          this.getExcelOutData(viewParam, pageIndex, pageSize, data)
        } else {
          data = data.concat(result.data)
          this.exportExcel(data)
          this.exportExcel(data, result.ErrCode, result.message)
        }
      } else {
        this.execError(result)
@@ -489,13 +443,11 @@
  /**
   * @description Excel 生成
   */
  exportExcel = (data) => {
  exportExcel = (data, ErrCode, msg) => {
    const { btn } = this.props
    
    let imgCol = false
    let columns = btn.verify.columns.filter(col => {
      if (col.output === 'false') return false
    let columns = btn.verify.columns.map(col => {
      if (col.type === 'image') {
        imgCol = true
      }
@@ -510,6 +462,7 @@
    if (data && data[0]) {
      let errors = []
      columns.forEach(col => {
        if (col.output === 'false') return
        if (col.Column && data[0][col.Column] === undefined) {
          errors.push(col.Text)
        }
@@ -555,7 +508,13 @@
  
          columns.forEach((col, i) => {
            let val = item[col.Column]
            if (col.type === 'number' && typeof(val) === 'number') {
            if (col.output === 'false') {
              if (col.type === 'number') {
                val = 0
              } else {
                val = ''
              }
            } else if (col.type === 'number' && typeof(val) === 'number') {
              if (col.abs === 'true') {
                val = Math.abs(val)
              }
@@ -573,7 +532,7 @@
        this.table2excel(column, table)
        this.execSuccess({ErrCode: 'S', message: '导出成功!'})
        this.execSuccess({ErrCode: ErrCode || 'S', message: msg || '导出成功!'})
      } else {
        let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        let cols = []
@@ -640,7 +599,13 @@
          columns.forEach((col, i) => {
            let val = item[col.Column]
            if (col.type === 'number' && typeof(val) === 'number') {
            if (col.output === 'false') {
              if (col.type === 'number') {
                val = 0
              } else {
                val = ''
              }
            } else if (col.type === 'number' && typeof(val) === 'number') {
              if (col.abs === 'true') {
                val = Math.abs(val)
              }
@@ -710,7 +675,7 @@
  
        XLSX.writeFile(wb, `${btn.$menuName || ''}${moment().format('YYYYMMDDHHmmss')}.xlsx`)
  
        this.execSuccess({ErrCode: 'S', message: '导出成功!'})
        this.execSuccess({ErrCode: ErrCode || 'S', message: msg || '导出成功!'})
      }
    } catch (e) {
      this.execError({ErrCode: 'N', message: 'Excel生成失败!'})
@@ -812,7 +777,7 @@
      _setting.arr_field = _setting.arr_field.join(',')
      _setting.execute = btn.verify.defaultSql !== 'false'
      _setting.dataresource = btn.verify.dataresource || ''
      _setting.primaryKey = _setting.primaryKey || setting.primaryKey || 'ID'
      _setting.primaryKey = btn.verify.primaryKey || setting.primaryKey || 'ID'
      if (!_setting.execute) {
        _setting.dataresource = ''
@@ -859,8 +824,11 @@
      _orderBy = btn.verify.order || ''
    } else {
      _setting = {...setting}
      _setting.$name = btn.logLabel
      _setting.laypage = pagination
      _setting.arr_field = _setting.all_field || _setting.arr_field
      delete _setting.sub_field
    }
    let primaryId = ''
@@ -892,18 +860,18 @@
   * 4、模态框执行成功后是否关闭
   * 5、通知主列表刷新
   */
  execSuccess = (res = {}) => {
  execSuccess = (res) => {
    const { btn } = this.props
    if (res.ErrCode === 'S' || !res.ErrCode) { // 执行成功
    if (res.ErrCode === 'S') { // 执行成功
      notification.success({
        top: 92,
        message: res.message || '执行成功!',
        message: res.message,
        duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2
      })
    } else if (res.ErrCode === 'Y') { // 执行成功
      Modal.success({
        title: res.message || '执行成功!'
        title: res.message
      })
    } else if (res.ErrCode === '-1') { // 完成后不提示