king
2020-08-11 04b5222fcf0c8f24b3a577cf3a05fb57462982a5
src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -378,54 +378,50 @@
   */
  exportExcel = (data) => {
    const { btn } = this.props
    if (data && data.length > 0) {
      try {
        let _header = []
        let _topRow = {}
        let colwidth = []
    try {
      let _header = []
      let _topRow = {}
      let colwidth = []
        btn.verify.columns.forEach(col => {
          if (!data[0].hasOwnProperty(col.Column)) return
          if (_topRow[col.Column]) return
      btn.verify.columns.forEach(col => {
        if (_topRow[col.Column]) return
          _header.push(col.Column)
          _topRow[col.Column] = col.Text
        _header.push(col.Column)
        _topRow[col.Column] = col.Text
          colwidth.push({width: col.Width})
        colwidth.push({width: col.Width || 20})
      })
      let table = []
      table.push(_topRow)
      data && data.forEach(item => {
        let _row = {}
        _header.forEach(field => {
          _row[field] = item[field]
        })
        let table = []
        table.push(_row)
      })
        table.push(_topRow)
      const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true})
        data.forEach(item => {
          let _row = {}
          _header.forEach(field => {
            _row[field] = item[field]
          })
      ws['!cols'] = colwidth
          table.push(_row)
        })
      const wb = XLSX.utils.book_new()
      XLSX.utils.book_append_sheet(wb, ws, 'Sheet1')
        const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true})
      XLSX.writeFile(wb, this.state.excelName)
        ws['!cols'] = colwidth
        const wb = XLSX.utils.book_new()
        XLSX.utils.book_append_sheet(wb, ws, 'Sheet1')
        XLSX.writeFile(wb, this.state.excelName)
        if (btn.verify && btn.verify.enable === 'true' && btn.verify.script) {
          this.execCustomScript()
        } else {
          this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'})
        }
      } catch {
        this.execError({ErrCode: 'N', message: 'Excel生成失败!'})
      if (btn.verify && btn.verify.enable === 'true' && btn.verify.script) {
        this.execCustomScript()
      } else {
        this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'})
      }
    } else {
      this.execError({ErrCode: 'N', message: '未查询到导出数据!'})
    } catch {
      this.execError({ErrCode: 'N', message: 'Excel生成失败!'})
    }
  }