This commit is contained in:
xuliangzhan
2019-12-11 13:10:36 +08:00
parent 0c2b1bd9d0
commit 3fdf9771ce

View File

@@ -2,6 +2,13 @@ import XEUtils from 'xe-utils/methods/xe-utils'
import VXETable from 'vxe-table/lib/vxe-table'
import XLSX from 'xlsx'
function getSeq($table: any, row: any, rowIndex: number, column: any, columnIndex: number) {
// 在 v3.0 中废弃 startIndex、indexMethod
let seqOpts = $table.seqOpts
let seqMethod = seqOpts.seqMethod || column.indexMethod
return seqMethod ? seqMethod({ row, rowIndex, column, columnIndex }) : ((seqOpts.startIndex || $table.startIndex) + rowIndex + 1)
}
function toBuffer(wbout: any) {
let buf = new ArrayBuffer(wbout.length)
let view = new Uint8Array(buf)
@@ -24,9 +31,9 @@ function exportXLSX(params: any) {
columns.forEach((column: any, columnIndex: number) => {
let cellValue
const property = column.property
const isIndex = column.type === 'index'
const isIndex = column.type === 'seq' || column.type === 'index'
if (!original || isIndex) {
cellValue = isIndex ? (column.indexMethod ? column.indexMethod({ row, rowIndex, column, columnIndex }) : rowIndex + 1) : row[column.id]
cellValue = isIndex ? getSeq($table, row, rowIndex, column, columnIndex) : row[column.id]
} else {
cellValue = XEUtils.get(row, property)
}