vxe-table 3.7.0-beta.0 → 3.7.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,7 +77,7 @@ function toBooleanValue (cellValue) {
77
77
 
78
78
  function getLabelData ($xetable, opts, columns, datas) {
79
79
  const { isAllExpand, mode } = opts
80
- const { treeConfig, treeOpts, radioOpts, checkboxOpts } = $xetable
80
+ const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xetable
81
81
  if (!htmlCellElem) {
82
82
  htmlCellElem = document.createElement('div')
83
83
  }
@@ -99,15 +99,18 @@ function getLabelData ($xetable, opts, columns, datas) {
99
99
  columns.forEach((column, $columnIndex) => {
100
100
  let cellValue = ''
101
101
  const renderOpts = column.editRender || column.cellRender
102
- let exportLabelMethod = column.exportMethod
103
- if (!exportLabelMethod && renderOpts && renderOpts.name) {
102
+ let bodyExportMethod = column.exportMethod
103
+ if (!bodyExportMethod && renderOpts && renderOpts.name) {
104
104
  const compConf = VXETable.renderer.get(renderOpts.name)
105
105
  if (compConf) {
106
- exportLabelMethod = compConf.exportMethod || compConf.cellExportMethod
106
+ bodyExportMethod = compConf.exportMethod || compConf.cellExportMethod
107
107
  }
108
108
  }
109
- if (exportLabelMethod) {
110
- cellValue = exportLabelMethod({ $table: $xetable, row, column, options: opts })
109
+ if (!bodyExportMethod) {
110
+ bodyExportMethod = columnOpts.exportMethod
111
+ }
112
+ if (bodyExportMethod) {
113
+ cellValue = bodyExportMethod({ $table: $xetable, row, column, options: opts })
111
114
  } else {
112
115
  switch (column.type) {
113
116
  case 'seq':
@@ -216,21 +219,26 @@ function getBooleanValue (cellValue) {
216
219
  }
217
220
 
218
221
  function getHeaderTitle ($xetable, opts, column) {
219
- const { headerExportMethod } = column
220
- return headerExportMethod ? headerExportMethod({ column, $table: $xetable }) : ((opts.original ? column.property : column.getTitle()) || '')
222
+ const { columnOpts } = $xetable
223
+ const headExportMethod = column.headerExportMethod || columnOpts.headerExportMethod
224
+ return headExportMethod ? headExportMethod({ column, options: opts, $table: $xetable }) : ((opts.original ? column.property : column.getTitle()) || '')
221
225
  }
222
226
 
223
227
  function getFooterCellValue ($xetable, opts, items, column) {
228
+ const { columnOpts } = $xetable
224
229
  const renderOpts = column.editRender || column.cellRender
225
- let exportLabelMethod = column.footerExportMethod
226
- if (!exportLabelMethod && renderOpts && renderOpts.name) {
230
+ let footLabelMethod = column.footerExportMethod
231
+ if (!footLabelMethod && renderOpts && renderOpts.name) {
227
232
  const compConf = VXETable.renderer.get(renderOpts.name)
228
233
  if (compConf) {
229
- exportLabelMethod = compConf.footerExportMethod || compConf.footerCellExportMethod
234
+ footLabelMethod = compConf.footerExportMethod || compConf.footerCellExportMethod
230
235
  }
231
236
  }
237
+ if (!footLabelMethod) {
238
+ footLabelMethod = columnOpts.footerExportMethod
239
+ }
232
240
  const _columnIndex = $xetable.getVTColumnIndex(column)
233
- const cellValue = exportLabelMethod ? exportLabelMethod({ $table: $xetable, items, itemIndex: _columnIndex, _columnIndex, column, options: opts }) : XEUtils.toValueString(items[_columnIndex])
241
+ const cellValue = footLabelMethod ? footLabelMethod({ $table: $xetable, items, itemIndex: _columnIndex, _columnIndex, column, options: opts }) : XEUtils.toValueString(items[_columnIndex])
234
242
  return cellValue
235
243
  }
236
244
 
@@ -590,8 +590,8 @@ const Methods = {
590
590
  * 牺牲数据组装的耗时,用来换取使用过程中的流畅
591
591
  */
592
592
  cacheRowMap (source) {
593
- const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData } = this
594
- let { fullDataRowIdData, fullAllDataRowIdData } = this
593
+ const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData, tableSourceData } = this
594
+ let { fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = this
595
595
  const rowkey = getRowkey(this)
596
596
  const isLazy = treeConfig && treeOpts.lazy
597
597
  const handleCache = (row, index, items, path, parent, nodes) => {
@@ -618,12 +618,31 @@ const Methods = {
618
618
  fullDataRowMap.clear()
619
619
  }
620
620
  fullAllDataRowIdData = this.fullAllDataRowIdData = {}
621
+ sourceDataRowIdData = this.sourceDataRowIdData = {}
621
622
  fullAllDataRowMap.clear()
622
623
  if (treeConfig) {
623
624
  XEUtils.eachTree(tableFullTreeData, handleCache, treeOpts)
624
625
  } else {
625
626
  tableFullData.forEach(handleCache)
626
627
  }
628
+
629
+ const handleSourceRow = (row) => {
630
+ let rowid = getRowid(this, row)
631
+ if (eqEmptyValue(rowid)) {
632
+ rowid = getRowUniqueId()
633
+ XEUtils.set(row, rowkey, rowid)
634
+ }
635
+ sourceDataRowIdData[rowid] = {
636
+ row,
637
+ rowid
638
+ }
639
+ }
640
+ // 源数据缓存
641
+ if (treeConfig && !treeOpts.transform) {
642
+ XEUtils.eachTree(tableSourceData, handleSourceRow, treeOpts)
643
+ } else {
644
+ tableSourceData.forEach(handleSourceRow)
645
+ }
627
646
  },
628
647
  loadTreeChildren (row, childRecords) {
629
648
  const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData } = this
@@ -1460,7 +1479,7 @@ const Methods = {
1460
1479
  */
1461
1480
  showColumn (fieldOrColumn) {
1462
1481
  const column = handleFieldOrColumn(this, fieldOrColumn)
1463
- if (column & !column.visible) {
1482
+ if (column && column.visible) {
1464
1483
  column.visible = true
1465
1484
  return this.handleCustom()
1466
1485
  }
package/types/export.d.ts CHANGED
@@ -231,6 +231,7 @@ export interface ColumnExportCellRenderParams extends GridRenderParams {
231
231
 
232
232
  export interface ColumnExportHeaderRenderParams extends GridRenderParams {
233
233
  column: ColumnInfo;
234
+ options: ExportParams;
234
235
  }
235
236
 
236
237
  export interface ColumnExportFooterRenderParams extends GridRenderParams {
package/types/table.d.ts CHANGED
@@ -1250,6 +1250,7 @@ export interface TableColumnConfig {
1250
1250
  width?: number
1251
1251
  minWidth?: number
1252
1252
  maxWidth?: number
1253
+ headerExportMethod?(params: any): string | number
1253
1254
  }
1254
1255
  export type ColumnDefaultConfig = TableColumnConfig
1255
1256