vxe-table 3.4.4 → 3.4.7-beta.1

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.
Files changed (51) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/README.zh-TW.md +1 -1
  4. package/lib/button/src/button.js +15 -14
  5. package/lib/button/src/button.min.js +1 -1
  6. package/lib/edit/src/mixin.js +19 -25
  7. package/lib/edit/src/mixin.min.js +1 -1
  8. package/lib/export/src/mixin.js +25 -10
  9. package/lib/export/src/mixin.min.js +1 -1
  10. package/lib/filter/src/mixin.js +25 -1
  11. package/lib/filter/src/mixin.min.js +1 -1
  12. package/lib/grid/src/grid.js +6 -3
  13. package/lib/grid/src/grid.min.js +1 -1
  14. package/lib/index.umd.js +1472 -426
  15. package/lib/index.umd.min.js +2 -1
  16. package/lib/select/src/select.js +1 -1
  17. package/lib/select/src/select.min.js +1 -1
  18. package/lib/table/src/body.js +9 -17
  19. package/lib/table/src/body.min.js +1 -1
  20. package/lib/table/src/cell.js +16 -17
  21. package/lib/table/src/cell.min.js +1 -1
  22. package/lib/table/src/methods.js +490 -324
  23. package/lib/table/src/methods.min.js +1 -1
  24. package/lib/table/src/table.js +6 -6
  25. package/lib/table/src/util.js +7 -0
  26. package/lib/table/src/util.min.js +1 -1
  27. package/lib/tools/src/dom.js +2 -9
  28. package/lib/tools/src/dom.min.js +1 -1
  29. package/lib/tools/src/utils.js +1 -1
  30. package/lib/tools/src/utils.min.js +1 -1
  31. package/lib/v-x-e-table/src/conf.js +6 -2
  32. package/lib/v-x-e-table/src/conf.min.js +1 -1
  33. package/lib/validator/src/mixin.js +3 -3
  34. package/lib/validator/src/mixin.min.js +1 -1
  35. package/package.json +3 -24
  36. package/packages/button/src/button.js +14 -14
  37. package/packages/edit/src/mixin.js +18 -21
  38. package/packages/export/src/mixin.js +17 -6
  39. package/packages/filter/src/mixin.js +20 -1
  40. package/packages/grid/src/grid.js +6 -2
  41. package/packages/select/src/select.js +1 -1
  42. package/packages/table/src/body.js +12 -16
  43. package/packages/table/src/cell.js +15 -15
  44. package/packages/table/src/methods.js +147 -52
  45. package/packages/table/src/table.js +6 -6
  46. package/packages/table/src/util.js +4 -0
  47. package/packages/tools/src/dom.js +2 -7
  48. package/packages/tools/src/utils.js +1 -1
  49. package/packages/v-x-e-table/src/conf.js +6 -2
  50. package/packages/validator/src/mixin.js +3 -3
  51. package/types/v-x-e-table/renderer.d.ts +3 -1
@@ -40,7 +40,7 @@ function renderLine (h, _vm, $xetable, rowLevel, items, params) {
40
40
  /**
41
41
  * 渲染列
42
42
  */
43
- function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
43
+ function renderColumn (h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
44
44
  const {
45
45
  $listeners: tableListeners,
46
46
  afterFullData,
@@ -98,7 +98,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
98
98
  const bindMouseenter = tableListeners['cell-mouseenter']
99
99
  const bindMouseleave = tableListeners['cell-mouseleave']
100
100
  const triggerDblclick = (editRender && editConfig && editOpts.trigger === 'dblclick')
101
- const params = { $table: $xetable, $seq, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
101
+ const params = { $table: $xetable, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
102
102
  // 虚拟滚动不支持动态高度
103
103
  if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
104
104
  showEllipsis = hasEllipsis = true
@@ -266,7 +266,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
266
266
  }, tdVNs)
267
267
  }
268
268
 
269
- function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn) {
269
+ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
270
270
  const {
271
271
  stripe,
272
272
  rowKey,
@@ -280,24 +280,19 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
280
280
  editOpts,
281
281
  treeExpandeds,
282
282
  scrollYLoad,
283
- scrollYStore,
284
283
  editStore,
285
284
  rowExpandeds,
286
285
  radioOpts,
287
286
  checkboxOpts,
288
287
  expandColumn,
289
288
  hasFixedColumn,
290
- fullAllDataRowIdData,
289
+ fullDataRowIdData,
291
290
  rowOpts
292
291
  } = $xetable
293
292
  const rows = []
294
293
  tableData.forEach((row, $rowIndex) => {
295
294
  const trOn = {}
296
295
  let rowIndex = $rowIndex
297
- let seq = rowIndex + 1
298
- if (scrollYLoad) {
299
- seq += scrollYStore.startIndex
300
- }
301
296
  const _rowIndex = $xetable.getVTRowIndex(row)
302
297
  // 确保任何情况下 rowIndex 都精准指向真实 data 索引
303
298
  rowIndex = $xetable.getRowIndex(row)
@@ -317,9 +312,10 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
317
312
  }
318
313
  }
319
314
  const rowid = UtilTools.getRowid($xetable, row)
320
- const rest = fullAllDataRowIdData[rowid]
315
+ const rest = fullDataRowIdData[rowid]
321
316
  const rowLevel = rest ? rest.level : 0
322
- const params = { $table: $xetable, $seq, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
317
+ const seq = rest ? rest.seq : -1
318
+ const params = { $table: $xetable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
323
319
  let isNewRow = false
324
320
  if (editConfig) {
325
321
  isNewRow = editStore.insertList.indexOf(row) > -1
@@ -340,7 +336,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
340
336
  key: rowKey || treeConfig ? rowid : $rowIndex,
341
337
  on: trOn
342
338
  }, tableColumn.map((column, $columnIndex) => {
343
- return renderColumn(h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
339
+ return renderColumn(h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
344
340
  }))
345
341
  )
346
342
  // 如果行被展开了
@@ -353,7 +349,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
353
349
  }
354
350
  const { showOverflow } = expandColumn
355
351
  const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? allColumnOverflow : showOverflow
356
- const expandParams = { $table: $xetable, $seq, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
352
+ const expandParams = { $table: $xetable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
357
353
  rows.push(
358
354
  h('tr', {
359
355
  class: 'vxe-body--expanded-row',
@@ -381,10 +377,10 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
381
377
  )
382
378
  }
383
379
  // 如果是树形表格
384
- if (treeConfig && !scrollYLoad && treeExpandeds.length) {
380
+ if (treeConfig && !scrollYLoad && !treeOpts.transform && treeExpandeds.length) {
385
381
  const rowChildren = row[treeOpts.children]
386
382
  if (rowChildren && rowChildren.length && treeExpandeds.indexOf(row) > -1) {
387
- rows.push(...renderRows(h, _vm, $xetable, $seq ? `${$seq}.${seq}` : `${seq}`, fixedType, rowChildren, tableColumn))
383
+ rows.push(...renderRows(h, _vm, $xetable, fixedType, rowChildren, tableColumn))
388
384
  }
389
385
  }
390
386
  })
@@ -529,7 +525,7 @@ export default {
529
525
  */
530
526
  h('tbody', {
531
527
  ref: 'tbody'
532
- }, renderRows(h, this, $xetable, '', fixedType, tableData, tableColumn))
528
+ }, renderRows(h, this, $xetable, fixedType, tableData, tableColumn))
533
529
  ]),
534
530
  h('div', {
535
531
  class: 'vxe-table--checkbox-range'
@@ -99,16 +99,16 @@ export const Cell = {
99
99
  }
100
100
  switch (type) {
101
101
  case 'seq':
102
- renMaps.renderHeader = this.renderIndexHeader
103
- renMaps.renderCell = treeNode ? this.renderTreeIndexCell : this.renderIndexCell
102
+ renMaps.renderHeader = this.renderSeqHeader
103
+ renMaps.renderCell = treeNode ? this.renderTreeIndexCell : this.renderSeqCell
104
104
  break
105
105
  case 'radio':
106
106
  renMaps.renderHeader = this.renderRadioHeader
107
107
  renMaps.renderCell = treeNode ? this.renderTreeRadioCell : this.renderRadioCell
108
108
  break
109
109
  case 'checkbox':
110
- renMaps.renderHeader = this.renderSelectionHeader
111
- renMaps.renderCell = checkboxOpts.checkField ? (treeNode ? this.renderTreeSelectionCellByProp : this.renderSelectionCellByProp) : (treeNode ? this.renderTreeSelectionCell : this.renderSelectionCell)
110
+ renMaps.renderHeader = this.renderCheckboxHeader
111
+ renMaps.renderCell = checkboxOpts.checkField ? (treeNode ? this.renderTreeSelectionCellByProp : this.renderCheckboxCellByProp) : (treeNode ? this.renderTreeSelectionCell : this.renderCheckboxCell)
112
112
  break
113
113
  case 'expand':
114
114
  renMaps.renderCell = this.renderExpandCell
@@ -253,24 +253,24 @@ export const Cell = {
253
253
  /**
254
254
  * 索引
255
255
  */
256
- renderIndexHeader (h, params) {
256
+ renderSeqHeader (h, params) {
257
257
  const { $table, column } = params
258
258
  const { slots } = column
259
259
  return renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : UtilTools.formatText(column.getTitle(), 1))
260
260
  },
261
- renderIndexCell (h, params) {
261
+ renderSeqCell (h, params) {
262
262
  const { $table, column } = params
263
- const { seqOpts } = $table
263
+ const { treeConfig, seqOpts } = $table
264
264
  const { slots } = column
265
265
  if (slots && slots.default) {
266
266
  return $table.callSlot(slots.default, params, h)
267
267
  }
268
- const { $seq, seq, level } = params
268
+ const { seq } = params
269
269
  const seqMethod = seqOpts.seqMethod
270
- return [UtilTools.formatText(seqMethod ? seqMethod(params) : level ? `${$seq}.${seq}` : (seqOpts.startIndex) + seq, 1)]
270
+ return [UtilTools.formatText(seqMethod ? seqMethod(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + seq, 1)]
271
271
  },
272
272
  renderTreeIndexCell (h, params) {
273
- return Cell.renderTreeIcon(h, params, Cell.renderIndexCell(h, params))
273
+ return Cell.renderTreeIcon(h, params, Cell.renderSeqCell(h, params))
274
274
  },
275
275
 
276
276
  /**
@@ -350,7 +350,7 @@ export const Cell = {
350
350
  /**
351
351
  * 多选
352
352
  */
353
- renderSelectionHeader (h, params) {
353
+ renderCheckboxHeader (h, params) {
354
354
  const { $table, column, isHidden } = params
355
355
  const { isIndeterminate: isAllCheckboxIndeterminate, isAllCheckboxDisabled } = $table
356
356
  const { slots } = column
@@ -409,7 +409,7 @@ export const Cell = {
409
409
  ] : []))
410
410
  ])
411
411
  },
412
- renderSelectionCell (h, params) {
412
+ renderCheckboxCell (h, params) {
413
413
  const { $table, row, column, isHidden } = params
414
414
  const { treeConfig, treeIndeterminates } = $table
415
415
  const { labelField, checkMethod, visibleMethod } = $table.checkboxOpts
@@ -474,9 +474,9 @@ export const Cell = {
474
474
  ]
475
475
  },
476
476
  renderTreeSelectionCell (h, params) {
477
- return Cell.renderTreeIcon(h, params, Cell.renderSelectionCell(h, params))
477
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCell(h, params))
478
478
  },
479
- renderSelectionCellByProp (h, params) {
479
+ renderCheckboxCellByProp (h, params) {
480
480
  const { $table, row, column, isHidden } = params
481
481
  const { treeConfig, treeIndeterminates } = $table
482
482
  const { labelField, checkField: property, halfField, checkMethod, visibleMethod } = $table.checkboxOpts
@@ -541,7 +541,7 @@ export const Cell = {
541
541
  ]
542
542
  },
543
543
  renderTreeSelectionCellByProp (h, params) {
544
- return Cell.renderTreeIcon(h, params, Cell.renderSelectionCellByProp(h, params))
544
+ return Cell.renderTreeIcon(h, params, Cell.renderCheckboxCellByProp(h, params))
545
545
  },
546
546
 
547
547
  /**
@@ -3,7 +3,7 @@ import GlobalConfig from '../../v-x-e-table/src/conf'
3
3
  import Cell from './cell'
4
4
  import VXETable from '../../v-x-e-table'
5
5
  import { UtilTools, DomTools } from '../../tools'
6
- import { clearTableAllStatus, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener } from './util'
6
+ import { clearTableAllStatus, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener, toTreePathSeq } from './util'
7
7
  import { eqEmptyValue, isEnableConf } from '../../tools/src/utils'
8
8
  import { browse, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '../../tools/src/dom'
9
9
  import { formats } from '../../v-x-e-table/src/formats'
@@ -301,9 +301,33 @@ const Methods = {
301
301
  return this.handleTableData(true).then(this.updateFooter).then(this.recalculate)
302
302
  },
303
303
  handleTableData (force) {
304
- const { scrollYLoad, scrollYStore } = this
305
- const fullData = force ? this.updateAfterFullData() : this.afterFullData
306
- this.tableData = scrollYLoad ? fullData.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullData.slice(0)
304
+ const { treeConfig, scrollYLoad, scrollYStore, fullDataRowIdData, treeExpandeds, treeOpts } = this
305
+ let fullList = []
306
+ // 是否进行数据处理
307
+ if (force) {
308
+ this.updateAfterFullData()
309
+ }
310
+ // 如果为虚拟树,将树结构拍平
311
+ if (treeConfig && treeOpts.transform) {
312
+ const expandMaps = new Map()
313
+ XEUtils.eachTree(this.afterTreeFullData, (row, index, items, path, parent) => {
314
+ if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
315
+ expandMaps.set(row, 1)
316
+ fullList.push(row)
317
+ }
318
+ }, { children: treeOpts.mapChildren })
319
+ } else {
320
+ fullList = this.afterFullData
321
+ }
322
+ const tableData = scrollYLoad ? fullList.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullList.slice(0)
323
+ tableData.forEach((row, $index) => {
324
+ const rowid = getRowid(this, row)
325
+ const rest = fullDataRowIdData[rowid]
326
+ if (rest) {
327
+ rest.$index = $index
328
+ }
329
+ })
330
+ this.tableData = tableData
307
331
  return this.$nextTick()
308
332
  },
309
333
  updateScrollYStatus (fullData) {
@@ -334,13 +358,24 @@ const Methods = {
334
358
  if (!treeOpts.children) {
335
359
  UtilTools.error('vxe.error.reqProp', ['tree-config.children'])
336
360
  }
361
+ if (!treeOpts.mapChildren) {
362
+ UtilTools.error('vxe.error.reqProp', ['tree-config.mapChildren'])
363
+ }
364
+ if (treeOpts.children === treeOpts.mapChildren) {
365
+ UtilTools.error('vxe.error.errConflicts', ['tree-config.children', 'tree-config.mapChildren'])
366
+ }
337
367
  fullData.forEach(row => {
338
368
  if (row[treeOpts.children] && row[treeOpts.children].length) {
339
369
  UtilTools.warn('vxe.error.errConflicts', ['tree-config.transform', `row.${treeOpts.children}`])
340
370
  }
341
371
  })
342
372
  }
343
- treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowField, parentKey: treeOpts.parentField, children: treeOpts.children })
373
+ treeData = XEUtils.toArrayTree(fullData, {
374
+ key: treeOpts.rowField,
375
+ parentKey: treeOpts.parentField,
376
+ children: treeOpts.children,
377
+ mapChildren: treeOpts.mapChildren
378
+ })
344
379
  fullData = treeData.slice(0)
345
380
  } else {
346
381
  treeData = fullData.slice(0)
@@ -356,7 +391,7 @@ const Methods = {
356
391
  this.scrollYLoad = sYLoad
357
392
  // 全量数据
358
393
  this.tableFullData = fullData
359
- this.treeFullData = treeData
394
+ this.tableFullTreeData = treeData
360
395
  // 缓存数据
361
396
  this.cacheRowMap(true)
362
397
  // 原始数据
@@ -530,12 +565,14 @@ const Methods = {
530
565
  * 牺牲数据组装的耗时,用来换取使用过程中的流畅
531
566
  */
532
567
  cacheRowMap (source) {
533
- const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap } = this
568
+ const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData } = this
534
569
  let { fullDataRowIdData, fullAllDataRowIdData } = this
535
570
  const rowkey = getRowkey(this)
536
571
  const isLazy = treeConfig && treeOpts.lazy
537
572
  const handleCache = (row, index, items, path, parent, nodes) => {
538
573
  let rowid = getRowid(this, row)
574
+ const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
575
+ const level = nodes ? nodes.length - 1 : 0
539
576
  if (eqEmptyValue(rowid)) {
540
577
  rowid = getRowUniqueId()
541
578
  XEUtils.set(row, rowkey, rowid)
@@ -543,7 +580,7 @@ const Methods = {
543
580
  if (isLazy && row[treeOpts.hasChild] && XEUtils.isUndefined(row[treeOpts.children])) {
544
581
  row[treeOpts.children] = null
545
582
  }
546
- const rest = { row, rowid, index: treeConfig && parent ? -1 : index, items, parent, level: nodes ? nodes.length - 1 : 0 }
583
+ const rest = { row, rowid, seq, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items, parent, level }
547
584
  if (source) {
548
585
  fullDataRowIdData[rowid] = rest
549
586
  fullDataRowMap.set(row, rest)
@@ -558,7 +595,7 @@ const Methods = {
558
595
  fullAllDataRowIdData = this.fullAllDataRowIdData = {}
559
596
  fullAllDataRowMap.clear()
560
597
  if (treeConfig) {
561
- XEUtils.eachTree(tableFullData, handleCache, treeOpts)
598
+ XEUtils.eachTree(tableFullTreeData, handleCache, treeOpts)
562
599
  } else {
563
600
  tableFullData.forEach(handleCache)
564
601
  }
@@ -578,7 +615,7 @@ const Methods = {
578
615
  }
579
616
  XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
580
617
  const rowid = getRowid(this, childRow)
581
- const rest = { row: childRow, rowid, index: -1, items, parent, level: parentLevel + nodes.length }
618
+ const rest = { row: childRow, rowid, seq: -1, index: -1, _index: -1, $index: -1, items, parent, level: parentLevel + nodes.length }
582
619
  fullDataRowIdData[rowid] = rest
583
620
  fullDataRowMap.set(childRow, rest)
584
621
  fullAllDataRowIdData[rowid] = rest
@@ -724,6 +761,21 @@ const Methods = {
724
761
  }
725
762
  return null
726
763
  },
764
+ /**
765
+ * 根据 row 获取序号
766
+ * @param {Row} row 行对象
767
+ */
768
+ getRowSeq (row) {
769
+ const { fullDataRowIdData } = this
770
+ if (row) {
771
+ const rowid = getRowid(this, row)
772
+ const rest = fullDataRowIdData[rowid]
773
+ if (rest) {
774
+ return rest.seq
775
+ }
776
+ }
777
+ return -1
778
+ },
727
779
  /**
728
780
  * 根据 row 获取相对于 data 中的索引
729
781
  * @param {Row} row 行对象
@@ -1061,10 +1113,12 @@ const Methods = {
1061
1113
  * 如果存在筛选条件,继续处理
1062
1114
  */
1063
1115
  updateAfterFullData () {
1064
- const { tableFullColumn, tableFullData, filterOpts, sortOpts } = this
1116
+ const { tableFullColumn, tableFullData, filterOpts, sortOpts, treeConfig, treeOpts, tableFullTreeData } = this
1065
1117
  const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
1066
1118
  const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple } = sortOpts
1067
- let tableData = tableFullData.slice(0)
1119
+ const { transform } = treeOpts
1120
+ let tableData = []
1121
+ let tableTree = []
1068
1122
  const filterColumns = []
1069
1123
  const orderColumns = []
1070
1124
  tableFullColumn.forEach(column => {
@@ -1087,7 +1141,7 @@ const Methods = {
1087
1141
  }
1088
1142
  })
1089
1143
  if (filterColumns.length) {
1090
- tableData = tableData.filter(row => {
1144
+ const handleFilter = (row) => {
1091
1145
  return filterColumns.every(({ column, valueList, itemList }) => {
1092
1146
  if (valueList.length && !allRemoteFilter) {
1093
1147
  const { filterMethod, filterRender } = column
@@ -1108,7 +1162,16 @@ const Methods = {
1108
1162
  }
1109
1163
  return true
1110
1164
  })
1111
- })
1165
+ }
1166
+ if (treeConfig && transform) {
1167
+ tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, { ...treeOpts, original: true })
1168
+ } else {
1169
+ tableData = treeConfig ? tableFullTreeData.filter(handleFilter) : tableFullData.filter(handleFilter)
1170
+ tableTree = tableData
1171
+ }
1172
+ } else {
1173
+ tableData = treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0)
1174
+ tableTree = tableData
1112
1175
  }
1113
1176
  const firstOrderColumn = orderColumns[0]
1114
1177
  if (!allRemoteSort && firstOrderColumn) {
@@ -1128,9 +1191,52 @@ const Methods = {
1128
1191
  tableData = XEUtils.orderBy(tableData, sortByConfs || [firstOrderColumn].map(({ column, order }) => [getOrderField(this, column), order]))
1129
1192
  }
1130
1193
  }
1194
+ tableTree = tableData
1131
1195
  }
1132
1196
  this.afterFullData = tableData
1133
- return tableData
1197
+ this.afterTreeFullData = tableTree
1198
+ this.updateAfterDataIndex()
1199
+ },
1200
+ /**
1201
+ * 预编译
1202
+ * 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
1203
+ */
1204
+ updateAfterDataIndex () {
1205
+ const { treeConfig, afterFullData, fullDataRowIdData, fullAllDataRowIdData, afterTreeFullData, treeOpts } = this
1206
+ if (treeConfig) {
1207
+ XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
1208
+ const rowid = getRowid(this, row)
1209
+ const allrest = fullAllDataRowIdData[rowid]
1210
+ const fullrest = fullDataRowIdData[rowid]
1211
+ const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
1212
+ if (allrest) {
1213
+ allrest.seq = seq
1214
+ }
1215
+ if (fullrest) {
1216
+ fullrest.seq = seq
1217
+ } else {
1218
+ fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1219
+ fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1220
+ }
1221
+ }, treeOpts)
1222
+ } else {
1223
+ afterFullData.forEach((row, index) => {
1224
+ const rowid = getRowid(this, row)
1225
+ const allrest = fullAllDataRowIdData[rowid]
1226
+ const fullrest = fullDataRowIdData[rowid]
1227
+ const seq = index + 1
1228
+ if (allrest) {
1229
+ allrest.seq = seq
1230
+ }
1231
+ if (fullrest) {
1232
+ fullrest.seq = seq
1233
+ fullrest._index = index
1234
+ } else {
1235
+ fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1236
+ fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
1237
+ }
1238
+ })
1239
+ }
1134
1240
  },
1135
1241
  /**
1136
1242
  * 根据行的唯一主键获取行
@@ -2097,7 +2203,7 @@ const Methods = {
2097
2203
  * 表格键盘事件
2098
2204
  */
2099
2205
  keydownEvent (evnt) {
2100
- const { filterStore, ctxMenuStore, editStore, keyboardConfig, mouseConfig, mouseOpts } = this
2206
+ const { filterStore, ctxMenuStore, editStore, keyboardConfig, mouseConfig, mouseOpts, keyboardOpts } = this
2101
2207
  const { actived } = editStore
2102
2208
  const { keyCode } = evnt
2103
2209
  const isEsc = keyCode === 27
@@ -2110,13 +2216,15 @@ const Methods = {
2110
2216
  // 如果按下了 Esc 键,关闭快捷菜单、筛选
2111
2217
  this.closeFilter()
2112
2218
  this.closeMenu()
2113
- // 如果是激活编辑状态,则取消编辑
2114
- if (actived.row) {
2115
- const params = actived.args
2116
- this.clearActived(evnt)
2117
- // 如果配置了选中功能,则为选中状态
2118
- if (mouseConfig && mouseOpts.selected) {
2119
- this.$nextTick(() => this.handleSelected(params, evnt))
2219
+ if (keyboardConfig && keyboardOpts.isEsc) {
2220
+ // 如果是激活编辑状态,则取消编辑
2221
+ if (actived.row) {
2222
+ const params = actived.args
2223
+ this.clearActived(evnt)
2224
+ // 如果配置了选中功能,则为选中状态
2225
+ if (mouseConfig && mouseOpts.selected) {
2226
+ this.$nextTick(() => this.handleSelected(params, evnt))
2227
+ }
2120
2228
  }
2121
2229
  }
2122
2230
  }
@@ -2923,6 +3031,16 @@ const Methods = {
2923
3031
  const { fullDataRowIdData, afterFullData, checkboxReserveRowMap, checkboxOpts, treeConfig, treeOpts } = this
2924
3032
  const reserveSelection = []
2925
3033
  if (checkboxOpts.reserve) {
3034
+ const afterFullIdMaps = {}
3035
+ if (treeConfig) {
3036
+ XEUtils.eachTree(afterFullData, row => {
3037
+ afterFullIdMaps[getRowid(this, row)] = 1
3038
+ }, treeOpts)
3039
+ } else {
3040
+ afterFullData.forEach(row => {
3041
+ afterFullIdMaps[getRowid(this, row)] = 1
3042
+ })
3043
+ }
2926
3044
  XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
2927
3045
  if (oldRow) {
2928
3046
  if (isFull) {
@@ -2930,14 +3048,8 @@ const Methods = {
2930
3048
  reserveSelection.push(oldRow)
2931
3049
  }
2932
3050
  } else {
2933
- if (treeConfig) {
2934
- if (!XEUtils.findTree(afterFullData, row => getRowid(this, row) === oldRowid, treeOpts)) {
2935
- reserveSelection.push(oldRow)
2936
- }
2937
- } else {
2938
- if (!afterFullData.some(row => getRowid(this, row) === oldRowid)) {
2939
- reserveSelection.push(oldRow)
2940
- }
3051
+ if (!afterFullIdMaps[oldRowid]) {
3052
+ reserveSelection.push(oldRow)
2941
3053
  }
2942
3054
  }
2943
3055
  }
@@ -3690,7 +3802,7 @@ const Methods = {
3690
3802
  return this.handleAsyncTreeExpandChilds(row)
3691
3803
  }).then(() => {
3692
3804
  if (transform) {
3693
- return this.updateVirtualTreeData()
3805
+ return this.handleTableData()
3694
3806
  }
3695
3807
  }).then(() => {
3696
3808
  return this.recalculate()
@@ -3836,23 +3948,6 @@ const Methods = {
3836
3948
  }
3837
3949
  return Promise.all(result).then(this.recalculate)
3838
3950
  },
3839
- updateVirtualTreeData () {
3840
- const { scrollYLoad: oldScrollYLoad, treeExpandeds, treeOpts, treeFullData } = this
3841
- const fullData = []
3842
- const expandMaps = new Map()
3843
- XEUtils.eachTree(treeFullData, (row, index, items, path, parent) => {
3844
- if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
3845
- expandMaps.set(row, 1)
3846
- fullData.push(row)
3847
- }
3848
- }, treeOpts)
3849
- const scrollYLoad = this.updateScrollYStatus(fullData)
3850
- this.tableFullData = scrollYLoad ? fullData : treeFullData
3851
- if (scrollYLoad || oldScrollYLoad !== scrollYLoad) {
3852
- return this.handleTableData(true).then(() => this.recalculate())
3853
- }
3854
- return this.$nextTick()
3855
- },
3856
3951
  /**
3857
3952
  * 虚拟树的展开与收起
3858
3953
  * @param rows
@@ -3861,7 +3956,7 @@ const Methods = {
3861
3956
  */
3862
3957
  handleVirtualTreeExpand (rows, expanded) {
3863
3958
  return this.handleBaseTreeExpand(rows, expanded).then(() => {
3864
- return this.updateVirtualTreeData()
3959
+ return this.handleTableData()
3865
3960
  }).then(() => {
3866
3961
  return this.recalculate()
3867
3962
  })
@@ -3909,7 +4004,7 @@ const Methods = {
3909
4004
  if (reserve) {
3910
4005
  XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), treeOpts)
3911
4006
  }
3912
- return this.updateVirtualTreeData().then(() => {
4007
+ return this.handleTableData().then(() => {
3913
4008
  if (isExists) {
3914
4009
  this.recalculate()
3915
4010
  }
@@ -4418,7 +4513,7 @@ const Methods = {
4418
4513
  }
4419
4514
 
4420
4515
  // Module methods
4421
- const funcs = 'setFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,clearCopyCellArea,setCellAreas,openFind,openReplace,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearActived,getActiveRecord,isActiveByRow,setActiveRow,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
4516
+ const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,clearCopyCellArea,setCellAreas,openFind,openReplace,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearActived,getActiveRecord,isActiveByRow,setActiveRow,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
4422
4517
 
4423
4518
  funcs.forEach(name => {
4424
4519
  Methods[name] = function (...args) {
@@ -114,15 +114,15 @@ export default {
114
114
  footerAlign: { type: String, default: () => GlobalConfig.table.footerAlign },
115
115
  // 是否显示表头
116
116
  showHeader: { type: Boolean, default: () => GlobalConfig.table.showHeader },
117
- // 是否要高亮当前选中行
117
+ // (即将废弃)是否要高亮当前选中行
118
118
  highlightCurrentRow: { type: Boolean, default: () => GlobalConfig.table.highlightCurrentRow },
119
- // 鼠标移到行是否要高亮显示
119
+ // (即将废弃)鼠标移到行是否要高亮显示
120
120
  highlightHoverRow: { type: Boolean, default: () => GlobalConfig.table.highlightHoverRow },
121
- // 是否要高亮当前选中列
121
+ // (即将废弃)是否要高亮当前选中列
122
122
  highlightCurrentColumn: { type: Boolean, default: () => GlobalConfig.table.highlightCurrentColumn },
123
- // 鼠标移到列是否要高亮显示
123
+ // (即将废弃)鼠标移到列是否要高亮显示
124
124
  highlightHoverColumn: { type: Boolean, default: () => GlobalConfig.table.highlightHoverColumn },
125
- // 激活单元格编辑时是否高亮显示
125
+ // (即将废弃)激活单元格编辑时是否高亮显示
126
126
  highlightCell: Boolean,
127
127
  // 是否显示表尾合计
128
128
  showFooter: Boolean,
@@ -235,7 +235,7 @@ export default {
235
235
  scrollX: Object,
236
236
  // 纵向虚拟滚动配置项
237
237
  scrollY: Object,
238
- // 优化相关
238
+ // (即将废弃)优化相关
239
239
  animat: { type: Boolean, default: () => GlobalConfig.table.animat },
240
240
  delayHover: { type: Number, default: () => GlobalConfig.table.delayHover },
241
241
  // 额外的参数
@@ -20,6 +20,10 @@ export function restoreScrollLocation (_vm, scrollLeft, scrollTop) {
20
20
  })
21
21
  }
22
22
 
23
+ export function toTreePathSeq (path) {
24
+ return path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
25
+ }
26
+
23
27
  export function removeScrollListener (scrollElem) {
24
28
  if (scrollElem && scrollElem._onscroll) {
25
29
  scrollElem.onscroll = null
@@ -204,14 +204,9 @@ export const DomTools = {
204
204
  }
205
205
  },
206
206
  triggerEvent (targetElem, type) {
207
- let evnt
208
- if (typeof Event === 'function') {
209
- evnt = new Event(type)
210
- } else {
211
- evnt = document.createEvent('Event')
212
- evnt.initEvent(type, true, true)
207
+ if (targetElem) {
208
+ targetElem.dispatchEvent(new Event(type))
213
209
  }
214
- targetElem.dispatchEvent(evnt)
215
210
  },
216
211
  calcHeight ($xetable, key) {
217
212
  const val = $xetable[key]
@@ -183,7 +183,7 @@ export const UtilTools = {
183
183
  },
184
184
  // 行主键 key
185
185
  getRowkey ($xetable) {
186
- return $xetable.rowId || '_XID'
186
+ return $xetable.rowId || '_X_ID'
187
187
  },
188
188
  // 行主键 value
189
189
  getRowid ($xetable, row) {
@@ -11,6 +11,7 @@ export default {
11
11
  showHeader: true,
12
12
  animat: true,
13
13
  delayHover: 250,
14
+ autoResize: true,
14
15
  // keepSource: false,
15
16
  // showOverflow: null,
16
17
  // showHeaderOverflow: null,
@@ -18,7 +19,6 @@ export default {
18
19
  // resizeInterval: 500,
19
20
  // size: null,
20
21
  // zIndex: null,
21
- // autoResize: false,
22
22
  // stripe: false,
23
23
  // border: false,
24
24
  // round: false,
@@ -49,7 +49,7 @@ export default {
49
49
  // storage: false,
50
50
  // checkMethod () {}
51
51
  // },
52
- // rowId: '_XID', // 行数据的唯一主键字段名
52
+ // rowId: '_X_ID', // 行数据的唯一主键字段名
53
53
  sortConfig: {
54
54
  // remote: false,
55
55
  // trigger: 'default',
@@ -67,6 +67,7 @@ export default {
67
67
  parentField: 'parentId',
68
68
  children: 'children',
69
69
  hasChild: 'hasChild',
70
+ mapChildren: '_X_CHILD',
70
71
  indent: 20,
71
72
  showIcon: true
72
73
  },
@@ -91,6 +92,9 @@ export default {
91
92
  mouseConfig: {
92
93
  extension: true
93
94
  },
95
+ keyboardConfig: {
96
+ isEsc: true
97
+ },
94
98
  areaConfig: {
95
99
  selectCellByHeader: true
96
100
  },