king
2020-02-18 3d8cb6c1787dec23cbc85d4b262fd1f00654f891
src/tabviews/subtable/index.jsx
@@ -506,65 +506,22 @@
      this.props.handleMainTable()
    } else if (btn.popClose === 'subgrid' && type === 'pop') {
      this.reloadtable()
    } else if (type === 'excelOut') {
      this.handleDefaultExcelout(btn)
    }
  }
  /**
   * @description 使用默认存储过程 sPC_Get_TableData 导出excel表格
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  handleDefaultExcelout = (btn) => {
    const { MenuName } = this.props
    const { arr_field, orderBy, search, setting, config } = this.state
  getexceloutparam = () => {
    const { Tab } = this.props
    const { arr_field, orderBy, search, setting} = this.state
    let _arr_labels = []      // 列名称集
    let _arr_label_field = [] // 列名称字段集
    config.columns.forEach(col => {
      if (col.field) {
        _arr_labels.push(col.label)
        _arr_label_field.push(`${col.field} as ${col.label}`)
      }
    })
    _arr_labels = _arr_labels.join(',')
    _arr_label_field = _arr_label_field.join(',')
    let _search = Utils.joinMainSearchkey(search)
    _search = _search ? 'where (' + _search + ')' : ''
    // 获取列表数据
    let param = {
      func: 'sPC_Get_TableData',
      obj_name: 'data',
      arr_field: _arr_labels,
      BID: this.props.BID,
      appkey: window.GLOB.appkey || ''
    return {
      arr_field: arr_field,
      orderBy: orderBy || setting.order,
      search: search,
      menuName: Tab.label
    }
    let _orderBy = orderBy || setting.order
    let _dataresource = setting.dataresource
    if (/\s/.test(_dataresource)) {
      _dataresource = '(' + _dataresource + ') tb'
    }
    let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows`
    param.LText = Utils.formatOptions(LText)
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.DateCount = ''
    let name = `${MenuName}${moment().format('YYYYMMDDHHmmss')}.xlsx`
    Api.getExcelOut(param, name).then(res => {
      if (res && res.status === false) {
        this.refs.subButton.execError(res, btn)
      } else {
        this.refs.subButton.execSuccess(btn)
      }
    })
  }
  /**
@@ -656,6 +613,7 @@
            ContainerId={this.props.ContainerId}
            refreshdata={this.refreshbyaction}
            triggerPopview={this.triggerPopview}
            getexceloutparam={this.getexceloutparam}
            gettableselected={this.gettableselected}
          />
        }