king
2023-01-17 c39acd25c3e8747be16773a003f519e4ef801640
src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -3,7 +3,7 @@
import moment from 'moment'
import { is, fromJS } from 'immutable'
import { Button, Modal, notification, message } from 'antd'
import * as XLSX from 'xlsx'
import * as XLSX from 'sheetjs-style'
import Utils from '@/utils/utils.js'
import options from '@/store/options.js'
@@ -18,7 +18,6 @@
  static propTpyes = {
    BID: PropTypes.string,            // 主表ID
    BData: PropTypes.any,             // 主表数据
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    btn: PropTypes.object,            // 按钮
    setting: PropTypes.any,           // 页面通用设置
    updateStatus: PropTypes.func,     // 按钮状态更新
@@ -113,13 +112,13 @@
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record, type) => {
    const { setting, Tab, BID, btn } = this.props
    const { setting, BID, btn } = this.props
    const { loading, disabled } = this.state
    if (loading || disabled) return
    if (triggerId && btn.uuid !== triggerId) return
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
    if (setting.supModule && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
@@ -196,7 +195,7 @@
        })
        viewParam.arr_field = viewParam.arr_field.join(',')
        viewParam.orderBy = btn.verify.order || viewParam.orderBy
        viewParam.orderBy = btn.verify.order || ''
      }
    }
    if (btn.intertype === 'system' && btn.verify.enable === 'true') {
@@ -252,9 +251,17 @@
            }
          }
        } else {
          if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
            param.rduri = window.GLOB.mainSystemApi
          } else if (btn.sysInterface !== 'true') {
          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 (window.GLOB.systemType === 'production' && btn.proInterface) {
              param.rduri = btn.proInterface
            } else {
@@ -304,9 +311,17 @@
                }
              }
            } else {
              if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
                res.rduri = window.GLOB.mainSystemApi
              } else if (btn.sysInterface !== 'true') {
              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 (window.GLOB.systemType === 'production' && btn.proInterface) {
                  res.rduri = btn.proInterface
                } else {
@@ -379,9 +394,17 @@
            }
          }
        } else {
          if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
            res.rduri = window.GLOB.mainSystemApi
          } else if (btn.sysInterface !== 'true') {
          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 (window.GLOB.systemType === 'production' && btn.proInterface) {
              res.rduri = btn.proInterface
            } else {
@@ -457,9 +480,17 @@
          }
        }
      } else {
        if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
          param.rduri = window.GLOB.mainSystemApi
        } else if (btn.sysInterface !== 'true') {
        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 (window.GLOB.systemType === 'production' && btn.proInterface) {
            param.rduri = btn.proInterface
          } else {
@@ -571,11 +602,15 @@
        let _header = []
        let _topRow = {}
        let colwidth = []
        columns.forEach(col => {
        let requires = []
        columns.forEach((col, i) => {
          _header.push(col.Column)
          _topRow[col.Column] = col.Text
          colwidth.push({width: col.Width || 20})
          if (col.required === 'true') {
            requires.push(i)
          }
        })
  
        let table = []
@@ -607,8 +642,18 @@
        })
  
        const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true})
        ws['!cols'] = colwidth
        if (requires.length) {
          let cols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
          requires.forEach(col => {
            if (cols[col]) {
              ws[cols[col] + '1'].s = {font: { color: { rgb: 'F5222D' } }}
            }
          })
        }
        // ws["A1"].s = {fill: { bgColor: { rgb: "FFFFAA"  }}, font: { color: { rgb: "1890FF" } }}
  
        const wb = XLSX.utils.book_new()
        XLSX.utils.book_append_sheet(wb, ws, 'Sheet1')
@@ -765,13 +810,11 @@
    let customScript = setting.customScript || ''
    let _dataresource = setting.dataresource || ''
    let queryType = setting.queryType
    let transaction = setting.transaction
    if (btn.verify.dataType === 'custom') {
      defaultSql = btn.verify.defaultSql || 'true'
      _dataresource = btn.verify.dataresource || ''
      queryType = btn.verify.queryType
      transaction = btn.verify.transaction
      if (/\s/.test(_dataresource)) {
        _dataresource = '(' + _dataresource + ') tb'
@@ -920,10 +963,6 @@
    if (window.GLOB.mkHS) { // 云端数据验证
      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
    }
    if (transaction === 'true') {
      param.func = 'sPC_Get_TableData_try'
    }
    return param