From 3fdf9771ced178f54e88087c465304ade2fbb5da Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Wed, 11 Dec 2019 13:10:36 +0800 Subject: [PATCH] update --- index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 63c1078..53c60bd 100644 --- a/index.ts +++ b/index.ts @@ -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) }