diff --git a/index.ts b/index.ts index 97b5f3a..8363be1 100644 --- a/index.ts +++ b/index.ts @@ -47,8 +47,9 @@ function exportPDF (params: VxeGlobalInterceptorHandles.InterceptorExportParams) const { $table, options, columns, datas } = params const { props } = $table const { treeConfig } = props - const { computeTreeOpts } = $table.getComputeMaps() + const { computeColumnOpts, computeTreeOpts } = $table.getComputeMaps() const treeOpts = computeTreeOpts.value + const columnOpts = computeColumnOpts.value const dX = 7 const dY = 15.8 const ratio = 3.78 @@ -59,8 +60,9 @@ function exportPDF (params: VxeGlobalInterceptorHandles.InterceptorExportParams) const { type, filename, isHeader, isFooter, original } = options const footList: { [key: string]: any }[] = [] const headers: any[] = columns.map((column) => { - const { id, field, renderWidth, headerExportMethod } = column as any - const title = headerExportMethod ? headerExportMethod({ column, $table }) : (XEUtils.toValueString(original ? field : column.getTitle())) + const { id, field, renderWidth } = column + const headExportMethod = (column as any).headerExportMethod || (columnOpts as any).headerExportMethod + const title = headExportMethod ? headExportMethod({ column, options, $table }) : (XEUtils.toValueString(original ? field : column.getTitle())) const width = renderWidth / ratio colWidth += width return { diff --git a/package.json b/package.json index 2632f48..7e4ada4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table-plugin-export-pdf", - "version": "3.0.5", + "version": "3.0.6", "description": "基于 vxe-table 的表格插件,支持导出 pdf 格式", "scripts": { "lib": "gulp build"