vxe-table 3.4.0-beta.0 → 3.4.3-beta.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vxe-table",
3
- "version": "3.4.0-beta.0",
4
- "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
3
+ "version": "3.4.3-beta.0",
4
+ "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
7
7
  "lint": "vue-cli-service lint",
@@ -3,6 +3,8 @@ import VXETable from '../../v-x-e-table'
3
3
  import { UtilTools, DomTools, isEnableConf } from '../../tools'
4
4
  import { browse } from '../../tools/src/dom'
5
5
 
6
+ const { getRowid } = UtilTools
7
+
6
8
  export default {
7
9
  methods: {
8
10
  /**
@@ -22,21 +24,51 @@ export default {
22
24
  * @param {Row} row 指定行
23
25
  */
24
26
  _insertAt (records, row) {
25
- const { mergeList, afterFullData, editStore, sYOpts, scrollYLoad, tableFullData, treeConfig } = this
27
+ const { treeFullData, mergeList, afterFullData, editStore, sYOpts, scrollYLoad, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = this
26
28
  if (!XEUtils.isArray(records)) {
27
29
  records = [records]
28
30
  }
29
31
  const newRecords = records.map(record => this.defineField(Object.assign({}, record)))
30
32
  if (!row) {
31
- afterFullData.unshift(...newRecords)
32
- tableFullData.unshift(...newRecords)
33
- // 刷新单元格合并
34
- mergeList.forEach(mergeItem => {
35
- const { row: mergeRowIndex } = mergeItem
36
- if (mergeRowIndex > 0) {
37
- mergeItem.row = mergeRowIndex + newRecords.length
38
- }
39
- })
33
+ // 如果为虚拟树
34
+ if (treeConfig && treeOpts.transform) {
35
+ newRecords.forEach(item => {
36
+ const parentRowId = item[treeOpts.parentField]
37
+ const rowid = getRowid(this, item)
38
+ if (parentRowId) {
39
+ const matchObj = XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts)
40
+ if (matchObj) {
41
+ const { item: parentRow } = matchObj
42
+ const parentRest = fullAllDataRowIdData[getRowid(this, parentRow)]
43
+ const parentLevel = parentRest ? parentRest.level : 0
44
+ let parentChilds = parentRow[treeOpts.children]
45
+ if (!XEUtils.isArray(parentChilds)) {
46
+ parentChilds = parentRow[treeOpts.children] = []
47
+ }
48
+ parentChilds.push(item)
49
+ const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
50
+ fullDataRowIdData[rowid] = rest
51
+ fullAllDataRowIdData[rowid] = rest
52
+ } else {
53
+ // 父节点不存在
54
+ }
55
+ } else {
56
+ afterFullData.unshift(item)
57
+ treeFullData.unshift(item)
58
+ }
59
+ })
60
+ this.updateVirtualTreeData()
61
+ } else {
62
+ afterFullData.unshift(...newRecords)
63
+ tableFullData.unshift(...newRecords)
64
+ // 刷新单元格合并
65
+ mergeList.forEach(mergeItem => {
66
+ const { row: mergeRowIndex } = mergeItem
67
+ if (mergeRowIndex > 0) {
68
+ mergeItem.row = mergeRowIndex + newRecords.length
69
+ }
70
+ })
71
+ }
40
72
  } else {
41
73
  if (row === -1) {
42
74
  afterFullData.push(...newRecords)
@@ -95,7 +127,7 @@ export default {
95
127
  * 如果为空则删除所有
96
128
  */
97
129
  _remove (rows) {
98
- const { afterFullData, tableFullData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, sYOpts, scrollYLoad } = this
130
+ const { afterFullData, tableFullData, treeFullData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, sYOpts, scrollYLoad, treeOpts } = this
99
131
  const { actived, removeList, insertList } = editStore
100
132
  const { checkField: property } = checkboxOpts
101
133
  let rest = []
@@ -126,26 +158,43 @@ export default {
126
158
  this.afterFullData = []
127
159
  this.clearMergeCells()
128
160
  } else {
129
- rows.forEach(row => {
130
- const tfIndex = tableFullData.indexOf(row)
131
- if (tfIndex > -1) {
132
- const rItems = tableFullData.splice(tfIndex, 1)
133
- rest.push(rItems[0])
134
- }
135
- const afIndex = afterFullData.indexOf(row)
136
- if (afIndex > -1) {
137
- // 刷新单元格合并
138
- mergeList.forEach(mergeItem => {
139
- const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
140
- if (mergeRowIndex > afIndex) {
141
- mergeItem.row = mergeRowIndex - 1
142
- } else if (mergeRowIndex + mergeRowspan > afIndex) {
143
- mergeItem.rowspan = mergeRowspan - 1
144
- }
145
- })
146
- afterFullData.splice(afIndex, 1)
147
- }
148
- })
161
+ // 如果为虚拟树
162
+ if (treeConfig && treeOpts.transform) {
163
+ rows.forEach((row) => {
164
+ const rowid = getRowid(this, row)
165
+ const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
166
+ if (matchObj) {
167
+ const rItems = matchObj.items.splice(matchObj.index, 1)
168
+ rest.push(rItems[0])
169
+ }
170
+ const afIndex = afterFullData.indexOf(row)
171
+ if (afIndex > -1) {
172
+ afterFullData.splice(afIndex, 1)
173
+ }
174
+ this.updateVirtualTreeData()
175
+ })
176
+ } else {
177
+ rows.forEach(row => {
178
+ const tfIndex = tableFullData.indexOf(row)
179
+ if (tfIndex > -1) {
180
+ const rItems = tableFullData.splice(tfIndex, 1)
181
+ rest.push(rItems[0])
182
+ }
183
+ const afIndex = afterFullData.indexOf(row)
184
+ if (afIndex > -1) {
185
+ // 刷新单元格合并
186
+ mergeList.forEach(mergeItem => {
187
+ const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
188
+ if (mergeRowIndex > afIndex) {
189
+ mergeItem.row = mergeRowIndex - 1
190
+ } else if (mergeRowIndex + mergeRowspan > afIndex) {
191
+ mergeItem.rowspan = mergeRowspan - 1
192
+ }
193
+ })
194
+ afterFullData.splice(afIndex, 1)
195
+ }
196
+ })
197
+ }
149
198
  }
150
199
  // 如果当前行被激活编辑,则清除激活状态
151
200
  if (actived.row && rows.indexOf(actived.row) > -1) {
@@ -216,14 +265,26 @@ export default {
216
265
  * 获取新增的临时数据
217
266
  */
218
267
  _getInsertRecords () {
268
+ const { treeConfig, treeFullData, tableFullData, treeOpts } = this
219
269
  const insertList = this.editStore.insertList
220
270
  const insertRecords = []
221
271
  if (insertList.length) {
222
- this.tableFullData.forEach(row => {
223
- if (insertList.indexOf(row) > -1) {
224
- insertRecords.push(row)
225
- }
226
- })
272
+ // 如果为虚拟树
273
+ if (treeConfig && treeOpts.transform) {
274
+ insertList.forEach(row => {
275
+ const rowid = getRowid(this, row)
276
+ const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid(this, item), treeOpts)
277
+ if (matchObj) {
278
+ insertRecords.push(row)
279
+ }
280
+ })
281
+ } else {
282
+ insertList.forEach(row => {
283
+ if (tableFullData.indexOf(row) > -1) {
284
+ insertRecords.push(row)
285
+ }
286
+ })
287
+ }
227
288
  }
228
289
  return insertRecords
229
290
  },
@@ -121,7 +121,7 @@ export default {
121
121
  if (scrollXLoad && !hasEllipsis) {
122
122
  showEllipsis = hasEllipsis = true
123
123
  }
124
- if (highlightCurrentColumn || tableListeners['header-cell-click'] || sortOpts.trigger === 'cell') {
124
+ if (columnOpts.isCurrent || highlightCurrentColumn || tableListeners['header-cell-click'] || sortOpts.trigger === 'cell') {
125
125
  thOns.click = evnt => $xetable.triggerHeaderCellClickEvent(evnt, params)
126
126
  }
127
127
  if (tableListeners['header-cell-dblclick']) {
@@ -141,7 +141,7 @@ function renderColumn (h, _vm, $xetable, $seq, seq, rowid, fixedType, rowLevel,
141
141
  }
142
142
  }
143
143
  // 点击事件处理
144
- if (highlightCurrentRow ||
144
+ if ((rowOpts.isCurrent || highlightCurrentRow) ||
145
145
  tableListeners['cell-click'] ||
146
146
  (editRender && editConfig) ||
147
147
  (expandOpts.trigger === 'row' || (expandOpts.trigger === 'cell')) ||
@@ -287,7 +287,8 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
287
287
  checkboxOpts,
288
288
  expandColumn,
289
289
  hasFixedColumn,
290
- fullAllDataRowIdData
290
+ fullAllDataRowIdData,
291
+ rowOpts
291
292
  } = $xetable
292
293
  const rows = []
293
294
  tableData.forEach((row, $rowIndex) => {
@@ -301,7 +302,7 @@ function renderRows (h, _vm, $xetable, $seq, fixedType, tableData, tableColumn)
301
302
  // 确保任何情况下 rowIndex 都精准指向真实 data 索引
302
303
  rowIndex = $xetable.getRowIndex(row)
303
304
  // 事件绑定
304
- if (highlightHoverRow) {
305
+ if (rowOpts.isHover || highlightHoverRow) {
305
306
  trOn.mouseenter = evnt => {
306
307
  if (isOperateMouse($xetable)) {
307
308
  return
@@ -579,7 +580,7 @@ export default {
579
580
  */
580
581
  scrollEvent (evnt) {
581
582
  const { $el: scrollBodyElem, $parent: $xetable, fixedType } = this
582
- const { $refs, elemStore, highlightHoverRow, scrollXLoad, scrollYLoad, lastScrollTop, lastScrollLeft } = $xetable
583
+ const { $refs, elemStore, highlightHoverRow, scrollXLoad, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable
583
584
  const { tableHeader, tableBody, leftBody, rightBody, tableFooter, validTip } = $refs
584
585
  const headerElem = tableHeader ? tableHeader.$el : null
585
586
  const footerElem = tableFooter ? tableFooter.$el : null
@@ -597,7 +598,7 @@ export default {
597
598
  $xetable.lastScrollTop = scrollTop
598
599
  $xetable.lastScrollLeft = scrollLeft
599
600
  $xetable.lastScrollTime = Date.now()
600
- if (highlightHoverRow) {
601
+ if (rowOpts.isHover || highlightHoverRow) {
601
602
  $xetable.clearHoverRow()
602
603
  }
603
604
  if (leftElem && fixedType === 'left') {
@@ -683,7 +684,7 @@ export default {
683
684
  wheelEvent (evnt) {
684
685
  const { deltaY, deltaX } = evnt
685
686
  const { $el: scrollBodyElem, $parent: $xetable } = this
686
- const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft } = $xetable
687
+ const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable
687
688
  const { tableBody } = $refs
688
689
  const bodyElem = tableBody.$el
689
690
 
@@ -706,7 +707,7 @@ export default {
706
707
  $xetable.lastScrollTop = scrollTop
707
708
  $xetable.lastScrollLeft = scrollLeft
708
709
  $xetable.lastScrollTime = Date.now()
709
- if (highlightHoverRow) {
710
+ if (rowOpts.isHover || highlightHoverRow) {
710
711
  $xetable.clearHoverRow()
711
712
  }
712
713
  this.handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY)
@@ -291,17 +291,18 @@ export const Cell = {
291
291
  const { $table, column, isHidden } = params
292
292
  const { radioOpts, selectRow } = $table
293
293
  const { slots } = column
294
- const { labelField, checkMethod } = radioOpts
294
+ const { labelField, checkMethod, visibleMethod } = radioOpts
295
295
  const { row } = params
296
296
  const defaultSlot = slots ? slots.default : null
297
297
  const radioSlot = slots ? slots.radio : null
298
298
  const isChecked = row === selectRow
299
+ const isVisible = !visibleMethod || visibleMethod({ row })
299
300
  let isDisabled = !!checkMethod
300
301
  let on
301
302
  if (!isHidden) {
302
303
  on = {
303
304
  click (evnt) {
304
- if (!isDisabled) {
305
+ if (!isDisabled && isVisible) {
305
306
  $table.triggerRadioRowEvent(evnt, params)
306
307
  }
307
308
  }
@@ -310,26 +311,36 @@ export const Cell = {
310
311
  isDisabled = !checkMethod({ row })
311
312
  }
312
313
  }
313
- const radioParams = { ...params, checked: isChecked, disabled: isDisabled }
314
- return radioSlot ? $table.callSlot(radioSlot, radioParams, h) : [
315
- h('span', {
316
- class: ['vxe-cell--radio', {
317
- 'is--checked': isChecked,
318
- 'is--disabled': isDisabled
319
- }],
320
- on
321
- }, [
314
+ const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
315
+ if (radioSlot) {
316
+ return $table.callSlot(radioSlot, radioParams, h)
317
+ }
318
+ const radioVNs = []
319
+ if (isVisible) {
320
+ radioVNs.push(
322
321
  h('span', {
323
322
  class: 'vxe-radio--icon vxe-radio--checked-icon'
324
323
  }),
325
324
  h('span', {
326
325
  class: 'vxe-radio--icon vxe-radio--unchecked-icon'
327
326
  })
328
- ].concat(defaultSlot || labelField ? [
327
+ )
328
+ }
329
+ if (defaultSlot || labelField) {
330
+ radioVNs.push(
329
331
  h('span', {
330
332
  class: 'vxe-radio--label'
331
333
  }, defaultSlot ? $table.callSlot(defaultSlot, radioParams, h) : XEUtils.get(row, labelField))
332
- ] : []))
334
+ )
335
+ }
336
+ return [
337
+ h('span', {
338
+ class: ['vxe-cell--radio', {
339
+ 'is--checked': isChecked,
340
+ 'is--disabled': isDisabled
341
+ }],
342
+ on
343
+ }, radioVNs)
333
344
  ]
334
345
  },
335
346
  renderTreeRadioCell (h, params) {
@@ -401,19 +412,20 @@ export const Cell = {
401
412
  renderSelectionCell (h, params) {
402
413
  const { $table, row, column, isHidden } = params
403
414
  const { treeConfig, treeIndeterminates } = $table
404
- const { labelField, checkMethod } = $table.checkboxOpts
415
+ const { labelField, checkMethod, visibleMethod } = $table.checkboxOpts
405
416
  const { slots } = column
406
417
  const defaultSlot = slots ? slots.default : null
407
418
  const checkboxSlot = slots ? slots.checkbox : null
408
419
  let indeterminate = false
409
420
  let isChecked = false
421
+ const isVisible = !visibleMethod || visibleMethod({ row })
410
422
  let isDisabled = !!checkMethod
411
423
  let on
412
424
  if (!isHidden) {
413
425
  isChecked = $table.selection.indexOf(row) > -1
414
426
  on = {
415
427
  click (evnt) {
416
- if (!isDisabled) {
428
+ if (!isDisabled && isVisible) {
417
429
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
418
430
  }
419
431
  }
@@ -425,16 +437,13 @@ export const Cell = {
425
437
  indeterminate = treeIndeterminates.indexOf(row) > -1
426
438
  }
427
439
  }
428
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
429
- return checkboxSlot ? $table.callSlot(checkboxSlot, checkboxParams, h) : [
430
- h('span', {
431
- class: ['vxe-cell--checkbox', {
432
- 'is--checked': isChecked,
433
- 'is--disabled': isDisabled,
434
- 'is--indeterminate': indeterminate
435
- }],
436
- on
437
- }, [
440
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
441
+ if (checkboxSlot) {
442
+ return $table.callSlot(checkboxSlot, checkboxParams, h)
443
+ }
444
+ const checkVNs = []
445
+ if (isVisible) {
446
+ checkVNs.push(
438
447
  h('span', {
439
448
  class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
440
449
  }),
@@ -444,11 +453,24 @@ export const Cell = {
444
453
  h('span', {
445
454
  class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
446
455
  })
447
- ].concat(defaultSlot || labelField ? [
456
+ )
457
+ }
458
+ if (defaultSlot || labelField) {
459
+ checkVNs.push(
448
460
  h('span', {
449
461
  class: 'vxe-checkbox--label'
450
462
  }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
451
- ] : []))
463
+ )
464
+ }
465
+ return [
466
+ h('span', {
467
+ class: ['vxe-cell--checkbox', {
468
+ 'is--checked': isChecked,
469
+ 'is--disabled': isDisabled,
470
+ 'is--indeterminate': indeterminate
471
+ }],
472
+ on
473
+ }, checkVNs)
452
474
  ]
453
475
  },
454
476
  renderTreeSelectionCell (h, params) {
@@ -457,19 +479,20 @@ export const Cell = {
457
479
  renderSelectionCellByProp (h, params) {
458
480
  const { $table, row, column, isHidden } = params
459
481
  const { treeConfig, treeIndeterminates } = $table
460
- const { labelField, checkField: property, halfField, checkMethod } = $table.checkboxOpts
482
+ const { labelField, checkField: property, halfField, checkMethod, visibleMethod } = $table.checkboxOpts
461
483
  const { slots } = column
462
484
  const defaultSlot = slots ? slots.default : null
463
485
  const checkboxSlot = slots ? slots.checkbox : null
464
486
  let indeterminate = false
465
487
  let isChecked = false
488
+ const isVisible = !visibleMethod || visibleMethod({ row })
466
489
  let isDisabled = !!checkMethod
467
490
  let on
468
491
  if (!isHidden) {
469
492
  isChecked = XEUtils.get(row, property)
470
493
  on = {
471
494
  click (evnt) {
472
- if (!isDisabled) {
495
+ if (!isDisabled && isVisible) {
473
496
  $table.triggerCheckRowEvent(evnt, params, !isChecked)
474
497
  }
475
498
  }
@@ -481,16 +504,13 @@ export const Cell = {
481
504
  indeterminate = treeIndeterminates.indexOf(row) > -1
482
505
  }
483
506
  }
484
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
485
- return checkboxSlot ? $table.callSlot(checkboxSlot, checkboxParams, h) : [
486
- h('span', {
487
- class: ['vxe-cell--checkbox', {
488
- 'is--checked': isChecked,
489
- 'is--disabled': isDisabled,
490
- 'is--indeterminate': halfField && !isChecked ? row[halfField] : indeterminate
491
- }],
492
- on
493
- }, [
507
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
508
+ if (checkboxSlot) {
509
+ return $table.callSlot(checkboxSlot, checkboxParams, h)
510
+ }
511
+ const checkVNs = []
512
+ if (isVisible) {
513
+ checkVNs.push(
494
514
  h('span', {
495
515
  class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
496
516
  }),
@@ -500,11 +520,24 @@ export const Cell = {
500
520
  h('span', {
501
521
  class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
502
522
  })
503
- ].concat(defaultSlot || labelField ? [
523
+ )
524
+ }
525
+ if (defaultSlot || labelField) {
526
+ checkVNs.push(
504
527
  h('span', {
505
528
  class: 'vxe-checkbox--label'
506
529
  }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
507
- ] : []))
530
+ )
531
+ }
532
+ return [
533
+ h('span', {
534
+ class: ['vxe-cell--checkbox', {
535
+ 'is--checked': isChecked,
536
+ 'is--disabled': isDisabled,
537
+ 'is--indeterminate': halfField && !isChecked ? row[halfField] : indeterminate
538
+ }],
539
+ on
540
+ }, checkVNs)
508
541
  ]
509
542
  },
510
543
  renderTreeSelectionCellByProp (h, params) {
@@ -325,11 +325,11 @@ const Methods = {
325
325
  // 树结构自动转换
326
326
  if (treeOpts.transform) {
327
327
  if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
328
- if (!treeOpts.rowtKey) {
329
- UtilTools.error('vxe.error.reqProp', ['table.tree-config.rowtKey'])
328
+ if (!treeOpts.rowField) {
329
+ UtilTools.error('vxe.error.reqProp', ['table.tree-config.rowField'])
330
330
  }
331
- if (!treeOpts.parentKey) {
332
- UtilTools.error('vxe.error.reqProp', ['table.tree-config.parentKey'])
331
+ if (!treeOpts.parentField) {
332
+ UtilTools.error('vxe.error.reqProp', ['table.tree-config.parentField'])
333
333
  }
334
334
  if (!treeOpts.children) {
335
335
  UtilTools.error('vxe.error.reqProp', ['tree-config.children'])
@@ -340,7 +340,7 @@ const Methods = {
340
340
  }
341
341
  })
342
342
  }
343
- treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowtKey, parentKey: treeOpts.parentKey, children: treeOpts.children })
343
+ treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowField, parentKey: treeOpts.parentField, children: treeOpts.children })
344
344
  fullData = treeData.slice(0)
345
345
  } else {
346
346
  treeData = fullData.slice(0)
@@ -2135,7 +2135,7 @@ const Methods = {
2135
2135
  // 该行为只对当前激活的表格有效
2136
2136
  if (this.isActivated) {
2137
2137
  this.preventEvent(evnt, 'event.keydown', null, () => {
2138
- const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu } = this
2138
+ const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu, rowOpts } = this
2139
2139
  const { selected, actived } = editStore
2140
2140
  const { keyCode } = evnt
2141
2141
  const isBack = keyCode === 8
@@ -2198,7 +2198,7 @@ const Methods = {
2198
2198
  this.keyCtxTimeout = setTimeout(() => {
2199
2199
  this._keyCtx = false
2200
2200
  }, 1000)
2201
- } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && highlightCurrentRow && currentRow))) {
2201
+ } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
2202
2202
  // 退出选中
2203
2203
  if (hasCtrlKey) {
2204
2204
  // 如果是激活编辑状态,则取消编辑
@@ -2227,7 +2227,7 @@ const Methods = {
2227
2227
  this.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
2228
2228
  }
2229
2229
  }
2230
- } else if (treeConfig && highlightCurrentRow && currentRow) {
2230
+ } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
2231
2231
  // 如果是树形表格当前行回车移动到子节点
2232
2232
  const childrens = currentRow[treeOpts.children]
2233
2233
  if (childrens && childrens.length) {
@@ -2245,7 +2245,7 @@ const Methods = {
2245
2245
  // 如果按下了方向键
2246
2246
  if (selected.row && selected.column) {
2247
2247
  this.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
2248
- } else if ((isUpArrow || isDwArrow) && highlightCurrentRow) {
2248
+ } else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
2249
2249
  // 当前行按键上下移动
2250
2250
  this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
2251
2251
  }
@@ -2257,7 +2257,7 @@ const Methods = {
2257
2257
  } else if (actived.row || actived.column) {
2258
2258
  this.moveTabSelected(actived.args, hasShiftKey, evnt)
2259
2259
  }
2260
- } else if (keyboardConfig && (isDel || (treeConfig && highlightCurrentRow && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
2260
+ } else if (keyboardConfig && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
2261
2261
  if (!isEditStatus) {
2262
2262
  const { delMethod, backMethod } = keyboardOpts
2263
2263
  // 如果是删除键
@@ -2289,7 +2289,7 @@ const Methods = {
2289
2289
  // 如果按下 del 键,更新表尾数据
2290
2290
  this.updateFooter()
2291
2291
  }
2292
- } else if (isBack && keyboardOpts.isArrow && treeConfig && highlightCurrentRow && currentRow) {
2292
+ } else if (isBack && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
2293
2293
  // 如果树形表格回退键关闭当前行返回父节点
2294
2294
  const { parent: parentRow } = XEUtils.findTree(this.afterFullData, item => item === currentRow, treeOpts)
2295
2295
  if (parentRow) {
@@ -3052,11 +3052,11 @@ const Methods = {
3052
3052
  * @param {Row} row 行对象
3053
3053
  */
3054
3054
  setCurrentRow (row) {
3055
- const { $el } = this
3055
+ const { $el, rowOpts } = this
3056
3056
  this.clearCurrentRow()
3057
3057
  this.clearCurrentColumn()
3058
3058
  this.currentRow = row
3059
- if (this.highlightCurrentRow) {
3059
+ if (rowOpts.isCurrent || this.highlightCurrentRow) {
3060
3060
  if ($el) {
3061
3061
  XEUtils.arrayEach($el.querySelectorAll(`[rowid="${getRowid(this, row)}"]`), elem => addClass(elem, 'row--current'))
3062
3062
  }
@@ -3102,7 +3102,7 @@ const Methods = {
3102
3102
  * 用于当前行,获取当前行的数据
3103
3103
  */
3104
3104
  getCurrentRecord () {
3105
- return this.highlightCurrentRow ? this.currentRow : null
3105
+ return this.rowOpts.isCurrent || this.highlightCurrentRow ? this.currentRow : null
3106
3106
  },
3107
3107
  /**
3108
3108
  * 用于单选行,获取当已选中的数据
@@ -3164,7 +3164,7 @@ const Methods = {
3164
3164
  this.triggerSortEvent(evnt, column, getNextSortOrder(this, column))
3165
3165
  }
3166
3166
  this.emitEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
3167
- if (this.highlightCurrentColumn) {
3167
+ if (this.columnOpts.isCurrent || this.highlightCurrentColumn) {
3168
3168
  return this.setCurrentColumn(column)
3169
3169
  }
3170
3170
  return this.$nextTick()
@@ -3173,7 +3173,7 @@ const Methods = {
3173
3173
  this.emitEvent('header-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, params), evnt)
3174
3174
  },
3175
3175
  getCurrentColumn () {
3176
- return this.highlightCurrentColumn ? this.currentColumn : null
3176
+ return this.columnOpts.isCurrent || this.highlightCurrentColumn ? this.currentColumn : null
3177
3177
  },
3178
3178
  /**
3179
3179
  * 用于当前列,设置某列行为高亮状态
@@ -3220,7 +3220,7 @@ const Methods = {
3220
3220
  * 如果是双击模式,则单击后选中状态
3221
3221
  */
3222
3222
  triggerCellClickEvent (evnt, params) {
3223
- const { highlightCurrentRow, editStore, radioOpts, expandOpts, treeOpts, editConfig, editOpts, checkboxOpts } = this
3223
+ const { highlightCurrentRow, editStore, radioOpts, expandOpts, treeOpts, editConfig, editOpts, checkboxOpts, rowOpts } = this
3224
3224
  const { actived } = editStore
3225
3225
  const { row, column } = params
3226
3226
  const { type, treeNode } = column
@@ -3247,7 +3247,7 @@ const Methods = {
3247
3247
  if (!triggerTreeNode) {
3248
3248
  if (!triggerExpandNode) {
3249
3249
  // 如果是高亮行
3250
- if (highlightCurrentRow) {
3250
+ if (rowOpts.isCurrent || highlightCurrentRow) {
3251
3251
  if (!triggerCheckbox && !triggerRadio) {
3252
3252
  this.triggerCurrentRowEvent(evnt, params)
3253
3253
  }
@@ -3487,7 +3487,7 @@ const Methods = {
3487
3487
  * 重新懒加载展开行,并展开内容
3488
3488
  * @param {Row} row 行对象
3489
3489
  */
3490
- lazyExpandContent (row) {
3490
+ reloadRowExpand (row) {
3491
3491
  const { expandOpts, expandLazyLoadeds } = this
3492
3492
  const { lazy } = expandOpts
3493
3493
  if (lazy && expandLazyLoadeds.indexOf(row) === -1) {
@@ -3498,10 +3498,10 @@ const Methods = {
3498
3498
  },
3499
3499
  reloadExpandContent (row) {
3500
3500
  if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
3501
- UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', 'lazyExpandContent'])
3501
+ UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', 'reloadRowExpand'])
3502
3502
  }
3503
3503
  // 即将废弃
3504
- return this.lazyExpandContent(row)
3504
+ return this.reloadRowExpand(row)
3505
3505
  },
3506
3506
  /**
3507
3507
  * 展开行事件
@@ -3686,7 +3686,7 @@ const Methods = {
3686
3686
  * 重新懒加载树节点,并展开该节点
3687
3687
  * @param {Row} row 行对象
3688
3688
  */
3689
- lazyTreeChildren (row) {
3689
+ reloadTreeExpand (row) {
3690
3690
  const { treeOpts, treeLazyLoadeds } = this
3691
3691
  const { transform, lazy, hasChild } = treeOpts
3692
3692
  if (lazy && row[hasChild] && treeLazyLoadeds.indexOf(row) === -1) {
@@ -3704,10 +3704,10 @@ const Methods = {
3704
3704
  },
3705
3705
  reloadTreeChilds (row) {
3706
3706
  if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
3707
- UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', 'lazyTreeChildren'])
3707
+ UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
3708
3708
  }
3709
3709
  // 即将废弃
3710
- return this.lazyTreeChildren(row)
3710
+ return this.reloadTreeExpand(row)
3711
3711
  },
3712
3712
  /**
3713
3713
  * 展开树节点事件
@@ -3843,8 +3843,10 @@ const Methods = {
3843
3843
  updateVirtualTreeData () {
3844
3844
  const { scrollYLoad: oldScrollYLoad, treeExpandeds, treeOpts, treeFullData } = this
3845
3845
  const fullData = []
3846
+ const expandMaps = new Map()
3846
3847
  XEUtils.eachTree(treeFullData, (row, index, items, path, parent) => {
3847
- if (!parent || treeExpandeds.indexOf(parent) > -1) {
3848
+ if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
3849
+ expandMaps.set(row, 1)
3848
3850
  fullData.push(row)
3849
3851
  }
3850
3852
  }, treeOpts)