king
2020-07-07 faf99ae37eea8905ef181eaddae48d9a1457d92a
src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -91,6 +91,13 @@
        duration: 5
      })
      return
    } else if (!btn.verify || !btn.verify.columns || btn.verify.columns.length === 0) {
      notification.warning({
        top: 92,
        message: '请设置导出列!',
        duration: 5
      })
      return
    }
    this.triggerExcelout()
@@ -373,74 +380,21 @@
   * @description Excel 生成
   */
  exportExcel = (data) => {
    const { columns, btn } = this.props
    const { btn } = this.props
    if (data && data.length > 0) {
      try {
        let _header = []
        let _topRow = {}
        let colwidth = []
        let hidecolumns = []
        btn.verify.columns.forEach(col => {
          if (!data[0].hasOwnProperty(col.Column)) return
          if (_topRow[col.Column]) return
        let verifyColumn = {} // 记录验证信息中的Excel列配置
        if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) {
          btn.verify.columns.forEach(col => {
            if (col.export === 'false') {
              hidecolumns.push(col.Column)
              return
            }
            verifyColumn[col.Column] = col
          })
        }
          _header.push(col.Column)
          _topRow[col.Column] = col.Text
        columns.forEach(col => {
          if (col.Hide === 'true' || hidecolumns.includes(col.field)) {
            hidecolumns.push(col.field)
            return
          }
          if (!data[0].hasOwnProperty(col.field)) return
          if (_topRow[col.field]) return
          if (verifyColumn[col.field]) { // 优先使用验证信息中的列设置
            _header.push(col.field)
            _topRow[col.field] = verifyColumn[col.field].Text
            colwidth.push({width: verifyColumn[col.field].Width})
          } else {
            _header.push(col.field)
            _topRow[col.field] = col.label
            let _colwidth = Math.floor(col.Width / 6)
            if (!_colwidth || _colwidth < 5) {
              _colwidth = 5
            }
            colwidth.push({width: _colwidth})
          }
        })
        if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) {
          btn.verify.columns.forEach(col => {
            if (hidecolumns.includes(col.Column)) return
            if (!data[0].hasOwnProperty(col.Column)) return
            if (_topRow[col.Column]) return
            _header.push(col.Column)
            _topRow[col.Column] = col.Text
            colwidth.push({width: col.Width})
          })
        }
        Object.keys(data[0]).forEach(key => {
          if (hidecolumns.includes(key)) return
          if (_topRow[key]) return
          _header.push(key)
          _topRow[key] = key
          colwidth.push({width: 12})
          colwidth.push({width: col.Width})
        })
        let table = []