vxe-table 4.19.12 → 4.19.14

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 (47) hide show
  1. package/dist/all.esm.js +236 -88
  2. package/dist/style.css +1 -1
  3. package/dist/style.min.css +1 -1
  4. package/es/index.css +1 -1
  5. package/es/index.min.css +1 -1
  6. package/es/style.css +1 -1
  7. package/es/style.min.css +1 -1
  8. package/es/table/module/edit/hook.js +5 -5
  9. package/es/table/module/menu/panel.js +5 -5
  10. package/es/table/src/table.js +222 -74
  11. package/es/table/style.css +11 -7
  12. package/es/table/style.min.css +1 -1
  13. package/es/ui/index.js +1 -1
  14. package/es/ui/src/log.js +1 -1
  15. package/es/vxe-table/style.css +11 -7
  16. package/es/vxe-table/style.min.css +1 -1
  17. package/lib/index.css +1 -1
  18. package/lib/index.min.css +1 -1
  19. package/lib/index.umd.js +30 -18
  20. package/lib/index.umd.min.js +1 -1
  21. package/lib/style.css +1 -1
  22. package/lib/style.min.css +1 -1
  23. package/lib/table/module/edit/hook.js +5 -0
  24. package/lib/table/module/edit/hook.min.js +1 -1
  25. package/lib/table/module/menu/panel.js +5 -5
  26. package/lib/table/module/menu/panel.min.js +1 -1
  27. package/lib/table/src/table.js +19 -12
  28. package/lib/table/src/table.min.js +1 -1
  29. package/lib/table/style/style.css +11 -7
  30. package/lib/table/style/style.min.css +1 -1
  31. package/lib/ui/index.js +1 -1
  32. package/lib/ui/index.min.js +1 -1
  33. package/lib/ui/src/log.js +1 -1
  34. package/lib/ui/src/log.min.js +1 -1
  35. package/lib/vxe-table/style/style.css +11 -7
  36. package/lib/vxe-table/style/style.min.css +1 -1
  37. package/package.json +2 -2
  38. package/packages/table/module/edit/hook.ts +5 -5
  39. package/packages/table/module/menu/panel.ts +5 -5
  40. package/packages/table/src/table.ts +224 -74
  41. package/styles/components/table-module/menu.scss +5 -2
  42. /package/es/{iconfont.1781140839085.ttf → iconfont.1781257692019.ttf} +0 -0
  43. /package/es/{iconfont.1781140839085.woff → iconfont.1781257692019.woff} +0 -0
  44. /package/es/{iconfont.1781140839085.woff2 → iconfont.1781257692019.woff2} +0 -0
  45. /package/lib/{iconfont.1781140839085.ttf → iconfont.1781257692019.ttf} +0 -0
  46. /package/lib/{iconfont.1781140839085.woff → iconfont.1781257692019.woff} +0 -0
  47. /package/lib/{iconfont.1781140839085.woff2 → iconfont.1781257692019.woff2} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vxe-table",
3
- "version": "4.19.12",
3
+ "version": "4.19.14",
4
4
  "description": "A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.",
5
5
  "scripts": {
6
6
  "update": "npm install --legacy-peer-deps",
@@ -69,7 +69,7 @@
69
69
  "typescript": "~4.7.4",
70
70
  "vue": "3.4.27",
71
71
  "vue-router": "~4.5.1",
72
- "vxe-pc-ui": "4.14.35"
72
+ "vxe-pc-ui": "4.14.36"
73
73
  },
74
74
  "vetur": {
75
75
  "tags": "helper/vetur/tags.json",
@@ -88,7 +88,7 @@ hooks.add('tableEditModule', {
88
88
  }
89
89
  pChilds[funcName](item)
90
90
  pMapChilds[funcName](item)
91
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: pChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
91
+ const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: pChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
92
92
  fullDataRowIdData[rowid] = rest
93
93
  fullAllDataRowIdData[rowid] = rest
94
94
  } else {
@@ -97,7 +97,7 @@ hooks.add('tableEditModule', {
97
97
  }
98
98
  afterFullData[funcName](item)
99
99
  tableFullTreeData[funcName](item)
100
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
100
+ const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
101
101
  fullDataRowIdData[rowid] = rest
102
102
  fullAllDataRowIdData[rowid] = rest
103
103
  }
@@ -148,7 +148,7 @@ hooks.add('tableEditModule', {
148
148
  } else {
149
149
  newRecords.forEach(item => {
150
150
  const rowid = getRowid($xeTable, item)
151
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
151
+ const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
152
152
  fullDataRowIdData[rowid] = rest
153
153
  fullAllDataRowIdData[rowid] = rest
154
154
  afterFullData.unshift(item)
@@ -177,7 +177,7 @@ hooks.add('tableEditModule', {
177
177
  } else {
178
178
  newRecords.forEach(item => {
179
179
  const rowid = getRowid($xeTable, item)
180
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, treeIndex: -1, _tIndex: -1, $index: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
180
+ const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, treeIndex: -1, _tIndex: -1, $index: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
181
181
  fullDataRowIdData[rowid] = rest
182
182
  fullAllDataRowIdData[rowid] = rest
183
183
  afterFullData.push(item)
@@ -215,7 +215,7 @@ hooks.add('tableEditModule', {
215
215
  })
216
216
  XEUtils.eachTree(treeRecords, (item) => {
217
217
  const rowid = getRowid($xeTable, item)
218
- const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
218
+ const rest = { row: item, rowid, _seq: -1, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
219
219
  if (item[childrenField]) {
220
220
  item[mapChildrenField] = item[childrenField]
221
221
  }
@@ -53,7 +53,7 @@ export default defineVxeComponent({
53
53
  return options.every(item => item.visible === false)
54
54
  ? renderEmptyElement($xeTable)
55
55
  : h('ul', {
56
- class: 'vxe-context-menu--option-wrapper',
56
+ class: 'vxe-table--context-menu-group-wrapper',
57
57
  key: gIndex
58
58
  }, options.map((item, index) => {
59
59
  const { children, loading } = item
@@ -66,7 +66,7 @@ export default defineVxeComponent({
66
66
  return item.visible === false
67
67
  ? renderEmptyElement($xeTable)
68
68
  : h('li', {
69
- class: [item.className, {
69
+ class: ['vxe-table--context-menu--option', item.className, {
70
70
  'link--loading': loading,
71
71
  'link--disabled': item.disabled,
72
72
  'link--active': item === ctxMenuStore.selected
@@ -116,12 +116,12 @@ export default defineVxeComponent({
116
116
  suffixOpts.content ? h('span', `${suffixOpts.content}`) : renderEmptyElement($xeTable)
117
117
  ])
118
118
  ]),
119
- hasChildMenus && item.children
119
+ hasChildMenus && children
120
120
  ? h('ul', {
121
121
  class: ['vxe-table--context-menu-clild-wrapper', {
122
122
  'is--show': item === ctxMenuStore.selected && ctxMenuStore.showChild
123
123
  }]
124
- }, item.children.map((child, cIndex) => {
124
+ }, children.map((child, cIndex) => {
125
125
  const { loading: childLoading } = child
126
126
  const childPrefixOpts = Object.assign({}, child.prefixConfig)
127
127
  const childPrefixIcon = childPrefixOpts.icon || child.prefixIcon
@@ -131,7 +131,7 @@ export default defineVxeComponent({
131
131
  return child.visible === false
132
132
  ? null
133
133
  : h('li', {
134
- class: [child.className, {
134
+ class: ['vxe-table--context-menu--option', child.className, {
135
135
  'link--loading': childLoading,
136
136
  'link--disabled': child.disabled,
137
137
  'link--active': child === ctxMenuStore.selectChild
@@ -1,6 +1,6 @@
1
1
  import { h, ComponentPublicInstance, reactive, ref, Ref, provide, inject, nextTick, Teleport, onActivated, onDeactivated, onBeforeUnmount, onUnmounted, watch, computed, onMounted } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
- import XEUtils from 'xe-utils'
3
+ import XEUtils, { isNaN } from 'xe-utils'
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, wheelScrollTopTo, wheelScrollLeftTo, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey, checkTargetElement, hasEventInputTarget } from '../../ui/src/dom'
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
6
6
  import { VxeUI } from '../../ui'
@@ -686,22 +686,32 @@ export default defineVxeComponent({
686
686
  const { tableFullColumn } = internalData
687
687
  const { updateColFlag } = reactData
688
688
  const editDirtyOpts = computeEditDirtyOpts.value
689
- const { includeFields, excludeFields } = editDirtyOpts
689
+ const { extraFields, includeFields, excludeFields } = editDirtyOpts
690
690
  const kpFields: string[] = []
691
691
  if (updateColFlag) {
692
692
  if (includeFields && includeFields.length) {
693
693
  return includeFields
694
694
  }
695
- const exfMaps: Record<string, number> = {}
695
+ const excludeFdMaps: Record<string, number> = {}
696
696
  if (excludeFields && excludeFields.length) {
697
697
  excludeFields.forEach(field => {
698
- exfMaps[field] = 1
698
+ excludeFdMaps[field] = 1
699
+ })
700
+ }
701
+ const addFdMaps: Record<string, number> = {}
702
+ if (extraFields && extraFields.length) {
703
+ extraFields.forEach(field => {
704
+ if (!addFdMaps[field]) {
705
+ addFdMaps[field] = 1
706
+ kpFields.push(field)
707
+ }
699
708
  })
700
709
  }
701
710
  for (let i = 0; i < tableFullColumn.length; i++) {
702
711
  const column = tableFullColumn[i]
703
712
  const { field, type, editRender, cellRender } = column
704
- if (field && !type && (editRender || cellRender) && !exfMaps[field]) {
713
+ if (field && !type && (editRender || cellRender) && !addFdMaps[field] && !excludeFdMaps[field]) {
714
+ addFdMaps[field] = 1
705
715
  kpFields.push(field)
706
716
  }
707
717
  }
@@ -2204,25 +2214,62 @@ export default defineVxeComponent({
2204
2214
  }
2205
2215
  }
2206
2216
 
2217
+ const updateAfterTreeIndex = () => {
2218
+ const { fullDataRowIdData, fullAllDataRowIdData, afterFullData, afterTreeFullData } = internalData
2219
+ const treeOpts = computeTreeOpts.value
2220
+ const { transform, mapChildrenField } = treeOpts
2221
+ const childrenField = treeOpts.children || treeOpts.childrenField
2222
+ const fullMaps: Record<string, any> = {}
2223
+ let rowNum = 0
2224
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
2225
+ XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
2226
+ const rowid = handleGetRowId(row)
2227
+ const rowRest = fullAllDataRowIdData[rowid]
2228
+ const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
2229
+ if (rowRest) {
2230
+ rowRest.seq = seq
2231
+ rowRest._seq = rowNum
2232
+ rowRest.treeIndex = index
2233
+ rowRest._tIndex = rowNum
2234
+ } else {
2235
+ const rest = { row, rowid, _seq: rowNum, seq, index: -1, $index: -1, _index: -1, treeIndex: -1, _tIndex: rowNum, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
2236
+ fullAllDataRowIdData[rowid] = rest
2237
+ fullDataRowIdData[rowid] = rest
2238
+ }
2239
+ rowNum++
2240
+ fullMaps[rowid] = row
2241
+ }, { children: transform ? mapChildrenField : childrenField })
2242
+ if (transform) {
2243
+ afterFullData.forEach((row, index) => {
2244
+ const rowid = handleGetRowId(row)
2245
+ const rowRest = fullAllDataRowIdData[rowid]
2246
+ if (rowRest) {
2247
+ rowRest._index = index
2248
+ }
2249
+ })
2250
+ }
2251
+ internalData.afterFullRowMaps = fullMaps
2252
+ }
2253
+
2207
2254
  const updateAfterListIndex = () => {
2208
- const { treeConfig } = props
2209
2255
  const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
2210
2256
  const { handleGetRowId } = createHandleGetRowId($xeTable)
2211
2257
  const fullMaps: Record<string, any> = {}
2258
+ let rowNum = 0
2212
2259
  afterFullData.forEach((row, index) => {
2213
2260
  const rowid = handleGetRowId(row)
2214
2261
  const rowRest = fullAllDataRowIdData[rowid]
2215
2262
  const seq = index + 1
2216
2263
  if (rowRest) {
2217
- if (!treeConfig) {
2218
- rowRest.seq = seq
2219
- }
2264
+ rowRest.seq = seq
2265
+ rowRest._seq = rowNum
2220
2266
  rowRest._index = index
2221
2267
  } else {
2222
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, treeIndex: -1, _tIndex: -1, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
2268
+ const rest = { row, rowid, _seq: rowNum, seq, index: -1, $index: -1, _index: index, treeIndex: -1, _tIndex: -1, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
2223
2269
  fullAllDataRowIdData[rowid] = rest
2224
2270
  fullDataRowIdData[rowid] = rest
2225
2271
  }
2272
+ rowNum++
2226
2273
  fullMaps[rowid] = row
2227
2274
  })
2228
2275
  internalData.afterFullRowMaps = fullMaps
@@ -2234,44 +2281,8 @@ export default defineVxeComponent({
2234
2281
  */
2235
2282
  const updateAfterDataIndex = () => {
2236
2283
  const { treeConfig } = props
2237
- const { fullDataRowIdData, fullAllDataRowIdData, afterFullData, afterTreeFullData } = internalData
2238
- const treeOpts = computeTreeOpts.value
2239
- const { transform } = treeOpts
2240
- const childrenField = treeOpts.children || treeOpts.childrenField
2241
- const fullMaps: Record<string, any> = {}
2242
2284
  if (treeConfig) {
2243
- let _treeIndex = 0
2244
- const { handleGetRowId } = createHandleGetRowId($xeTable)
2245
- XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
2246
- const rowid = handleGetRowId(row)
2247
- const rowRest = fullAllDataRowIdData[rowid]
2248
- const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
2249
- if (rowRest) {
2250
- rowRest.seq = seq
2251
- rowRest.treeIndex = index
2252
- rowRest._tIndex = _treeIndex
2253
- } else {
2254
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: -1, treeIndex: -1, _tIndex: _treeIndex, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
2255
- fullAllDataRowIdData[rowid] = rest
2256
- fullDataRowIdData[rowid] = rest
2257
- }
2258
- _treeIndex++
2259
- fullMaps[rowid] = row
2260
- }, { children: transform ? treeOpts.mapChildrenField : childrenField })
2261
- if (transform) {
2262
- afterFullData.forEach((row, index) => {
2263
- const rowid = handleGetRowId(row)
2264
- const rowRest = fullAllDataRowIdData[rowid]
2265
- const seq = index + 1
2266
- if (rowRest) {
2267
- if (!treeConfig) {
2268
- rowRest.seq = seq
2269
- }
2270
- rowRest._index = index
2271
- }
2272
- })
2273
- }
2274
- internalData.afterFullRowMaps = fullMaps
2285
+ updateAfterTreeIndex()
2275
2286
  } else {
2276
2287
  updateAfterListIndex()
2277
2288
  }
@@ -3493,9 +3504,12 @@ export default defineVxeComponent({
3493
3504
  })
3494
3505
  }
3495
3506
 
3496
- const minRunDelay = 50
3507
+ const defaultMinRunDelay = 50
3497
3508
 
3498
- const handleLazyRecalculate = (reFull: boolean, reWidth: boolean, reHeight: boolean) => {
3509
+ const handleLazyRecalculate = (reFull: boolean, reWidth: boolean, reHeight: boolean, options?: {
3510
+ minRunDelay?: number // 多少毫秒内至少执行一次
3511
+ }) => {
3512
+ const minRunDelay = (options ? options.minRunDelay : defaultMinRunDelay) || defaultMinRunDelay
3499
3513
  return new Promise<void>(resolve => {
3500
3514
  const $xeGanttView = internalData.xeGanttView
3501
3515
  const { customStore } = reactData
@@ -3521,6 +3535,7 @@ export default defineVxeComponent({
3521
3535
  }
3522
3536
  if (rceTimeout) {
3523
3537
  clearTimeout(rceTimeout)
3538
+ // 多少毫秒内至少执行一次
3524
3539
  if (rceRunTime && rceRunTime + minRunDelay < Date.now()) {
3525
3540
  resolve(
3526
3541
  handleRecalculateStyle(reFull, reWidth, reHeight)
@@ -3548,17 +3563,17 @@ export default defineVxeComponent({
3548
3563
  })
3549
3564
  }
3550
3565
 
3551
- let resizePending = false
3552
-
3553
3566
  const handleResizeEvent = () => {
3554
- if (resizePending) {
3567
+ if (internalData.rsePending) {
3555
3568
  return
3556
3569
  }
3557
- resizePending = true
3558
- handleLazyRecalculate(true, true, true).then(() => {
3559
- resizePending = false
3570
+ internalData.rsePending = true
3571
+ handleLazyRecalculate(true, true, true, {
3572
+ minRunDelay: 200
3573
+ }).then(() => {
3574
+ internalData.rsePending = false
3560
3575
  }).catch(() => {
3561
- resizePending = false
3576
+ internalData.rsePending = false
3562
3577
  })
3563
3578
  }
3564
3579
 
@@ -4349,7 +4364,11 @@ export default defineVxeComponent({
4349
4364
  const { transform } = treeOpts
4350
4365
  const allList = fullData || internalData.tableFullData
4351
4366
  // 如果gt为0,则总是启用
4352
- const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length)
4367
+ let scrollYLoad = !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length)
4368
+ if (scrollYLoad && (treeConfig && !transform)) {
4369
+ errLog('vxe.error.notSupportProp', ['[table] virtual-y-config.enabled=true', 'tree-config.transform=false', 'tree-config.transform=true'])
4370
+ scrollYLoad = false
4371
+ }
4353
4372
  reactData.scrollYLoad = scrollYLoad
4354
4373
  syncGanttScrollYStatus()
4355
4374
  return scrollYLoad
@@ -5177,7 +5196,7 @@ export default defineVxeComponent({
5177
5196
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
5178
5197
  const rowid = getRowid($xeTable, childRow)
5179
5198
  const parentRow = parentItem || parentRest.row
5180
- const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
5199
+ const rest = { row: childRow, rowid, _seq: -1, seq: -1, index, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
5181
5200
  fullDataRowIdData[rowid] = rest
5182
5201
  fullAllDataRowIdData[rowid] = rest
5183
5202
  }, { children: childrenField })
@@ -9562,19 +9581,21 @@ export default defineVxeComponent({
9562
9581
 
9563
9582
  const idMaps: Record<string, boolean> = {}
9564
9583
  const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
9584
+ let rowNum = 0
9565
9585
  const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
9566
9586
  let rowRest = fullAllDataRowIdMaps[rowid]
9567
9587
  if (idMaps[rowid]) {
9568
9588
  errLog('vxe.error.repeatKey', [currKeyField, rowid])
9569
9589
  }
9570
9590
  if (!rowRest) {
9571
- rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, _tIndex: -1, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
9591
+ rowRest = { row, rowid, _seq: -1, seq, index: -1, _index: -1, $index: -1, treeIndex: index, _tIndex: -1, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
9572
9592
  fullDataRowIdMaps[rowid] = rowRest
9573
9593
  fullAllDataRowIdMaps[rowid] = rowRest
9574
9594
  }
9575
9595
  rowRest.treeLoaded = false
9576
9596
  rowRest.expandLoaded = false
9577
9597
 
9598
+ rowRest._seq = rowNum++
9578
9599
  rowRest.row = row
9579
9600
  rowRest.items = items
9580
9601
  rowRest.parent = parentRow
@@ -9590,6 +9611,7 @@ export default defineVxeComponent({
9590
9611
  rowExpandedMaps[rowid] = row
9591
9612
  }
9592
9613
 
9614
+ rowNum++
9593
9615
  idMaps[rowid] = true
9594
9616
  fullDataRowIdMaps[rowid] = rowRest
9595
9617
  fullAllDataRowIdMaps[rowid] = rowRest
@@ -9602,7 +9624,7 @@ export default defineVxeComponent({
9602
9624
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
9603
9625
  XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
9604
9626
  const rowid = handleUpdateRowId(row)
9605
- if (treeConfig && lazy) {
9627
+ if (lazy) {
9606
9628
  if (row[hasChildField] && row[childrenField] === undefined) {
9607
9629
  row[childrenField] = null
9608
9630
  }
@@ -10871,31 +10893,162 @@ export default defineVxeComponent({
10871
10893
  const { treeConfig } = props
10872
10894
  const { row } = params
10873
10895
  const { isRowGroupStatus } = reactData
10874
- const { afterFullData } = internalData
10896
+ const { fullAllDataRowIdData, afterFullData, afterTreeFullData, afterGroupFullData } = internalData
10875
10897
  const checkboxOpts = computeCheckboxOpts.value
10876
- const { checkMethod, trigger } = checkboxOpts
10898
+ const aggregateOpts = computeAggregateOpts.value
10899
+ const treeOpts = computeTreeOpts.value
10900
+ const { checkMethod, trigger, checkStrictly } = checkboxOpts
10877
10901
  if (trigger === 'manual') {
10878
10902
  return
10879
10903
  }
10880
10904
  evnt.stopPropagation()
10881
- if (checkboxOpts.isShiftKey && evnt.shiftKey && !(treeConfig || isRowGroupStatus)) {
10905
+
10906
+ if (checkboxOpts.isShiftKey && evnt.shiftKey) {
10907
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
10882
10908
  const checkboxRecords = $xeTable.getCheckboxRecords()
10883
- if (checkboxRecords.length) {
10884
- const firstRow = checkboxRecords[0]
10885
- const _rowIndex = $xeTable.getVTRowIndex(row)
10886
- const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
10887
- if (_rowIndex !== _firstRowIndex) {
10909
+ let currSeq = -1
10910
+ let currRow: any = null
10911
+ const currRowid = handleGetRowId(row)
10912
+ const rowRest = fullAllDataRowIdData[currRowid]
10913
+ if (rowRest) {
10914
+ currRow = rowRest.row
10915
+ currSeq = rowRest._seq
10916
+ }
10917
+ if (currRow && checkboxRecords.length) {
10918
+ let rangeRows: any[] = []
10919
+ let firstSeq = -1
10920
+ let firstRow: any = null
10921
+ let firstRowid = ''
10922
+ let lastSeq = -1
10923
+ let lastRow: any = null
10924
+ let lastRowid = ''
10925
+ // 根据序号取出范围最小/最大的行
10926
+ const selectMaps: Record<string, any> = {}
10927
+ checkboxRecords.forEach(item => {
10928
+ const rowid = handleGetRowId(item)
10929
+ const rowRest = fullAllDataRowIdData[rowid]
10930
+ if (rowRest) {
10931
+ if (!firstRow || firstSeq > rowRest._seq) {
10932
+ firstRowid = rowRest.rowid
10933
+ firstRow = rowRest.row
10934
+ firstSeq = rowRest._seq
10935
+ }
10936
+ if (!lastRow || lastSeq < rowRest._seq) {
10937
+ lastRowid = rowRest.rowid
10938
+ lastRow = rowRest.row
10939
+ lastSeq = rowRest._seq
10940
+ }
10941
+ }
10942
+ selectMaps[rowid] = item
10943
+ })
10944
+ // 如果已选只有一条并选择当前则跳过
10945
+ if (firstRow && lastRow && (checkboxRecords.length > 1 || currRowid !== firstRowid) && (Math.abs(firstSeq - lastSeq) > 1 || Math.abs(currSeq - firstSeq) > 1 || Math.abs(currSeq - lastSeq) > 1)) {
10946
+ // 树与分组
10947
+ if (treeConfig || isRowGroupStatus) {
10948
+ const { transform } = treeOpts
10949
+ const childrenField = treeOpts.children || treeOpts.childrenField
10950
+ const iteratorChildField = treeConfig ? (transform ? treeOpts.mapChildrenField : childrenField) : aggregateOpts.mapChildrenField as string
10951
+ let isMatchFirst = false
10952
+ let matchStartRowid = ''
10953
+ let matchEndRowid = ''
10954
+
10955
+ const handleGetChildRowid = (rowid: string, isLast: 0 | 1): string => {
10956
+ const rowRest = fullAllDataRowIdData[rowid]
10957
+ if (rowRest) {
10958
+ const item = rowRest.row
10959
+ const childList = item[iteratorChildField]
10960
+ if (childList && childList.length) {
10961
+ const targetRow = isLast ? XEUtils.last(childList) : XEUtils.first(childList)
10962
+ return handleGetChildRowid(handleGetRowId(targetRow), isLast)
10963
+ }
10964
+ }
10965
+ return rowid
10966
+ }
10967
+
10968
+ const handleGetSelectParentRowid = (rowid: string): string => {
10969
+ const rowRest = fullAllDataRowIdData[rowid]
10970
+ if (rowRest) {
10971
+ const parentItem = rowRest.parent
10972
+ if (parentItem) {
10973
+ const parentRowid = handleGetRowId(parentItem)
10974
+ if (selectMaps[parentRowid]) {
10975
+ return handleGetSelectParentRowid(parentRowid)
10976
+ }
10977
+ }
10978
+ }
10979
+ return rowid
10980
+ }
10981
+
10982
+ const handleGetRootRow = (row: string): VxeTableDefines.RowCacheItem | null => {
10983
+ const rowid = handleGetRowId(row)
10984
+ if (rowid) {
10985
+ const rest = fullAllDataRowIdData[rowid]
10986
+ if (rest) {
10987
+ return rest.parent ? handleGetRootRow(rest.parent) : rest
10988
+ }
10989
+ }
10990
+ return null
10991
+ }
10992
+
10993
+ if (currSeq < firstSeq) {
10994
+ matchStartRowid = handleGetChildRowid(currRowid, 0)
10995
+ matchEndRowid = handleGetChildRowid(firstRowid, 1)
10996
+ } else {
10997
+ if (currSeq > lastSeq) {
10998
+ matchStartRowid = handleGetSelectParentRowid(lastRowid)
10999
+ } else {
11000
+ matchStartRowid = handleGetChildRowid(firstRowid, 0)
11001
+ }
11002
+ matchEndRowid = handleGetChildRowid(currRowid, 1)
11003
+ }
11004
+
11005
+ const handleRangeRow = (item: any) => {
11006
+ const rowid = handleGetRowId(item)
11007
+ const childList = item[iteratorChildField]
11008
+ if (!isMatchFirst && rowid === matchStartRowid) {
11009
+ isMatchFirst = true
11010
+ }
11011
+ // 如果是父子关联,则排除父节点
11012
+ if (isMatchFirst && (checkStrictly || !childList || !childList.length)) {
11013
+ rangeRows.push(item)
11014
+ }
11015
+ // break
11016
+ return rowid === matchEndRowid
11017
+ }
11018
+ if (treeConfig) {
11019
+ const matchStartRowRest = fullAllDataRowIdData[matchStartRowid]
11020
+ const firstRootRowRest = matchStartRowRest ? handleGetRootRow(matchStartRowRest.row) : null
11021
+ if (firstRootRowRest) {
11022
+ // 优化查找复杂度
11023
+ XEUtils.findTree(afterTreeFullData.slice(firstRootRowRest.treeIndex), handleRangeRow, { children: iteratorChildField })
11024
+ } else {
11025
+ XEUtils.findTree(afterTreeFullData, handleRangeRow, { children: iteratorChildField })
11026
+ }
11027
+ } else {
11028
+ XEUtils.findTree(afterGroupFullData, handleRangeRow, { children: iteratorChildField })
11029
+ }
11030
+ } else {
11031
+ const _currRowIndex = $xeTable.getVTRowIndex(currRow)
11032
+ const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
11033
+ const _lastRowIndex = $xeTable.getVTRowIndex(lastRow)
11034
+ if (_currRowIndex < _firstRowIndex) {
11035
+ rangeRows = afterFullData.slice(_currRowIndex, _firstRowIndex + 1)
11036
+ } else if (_currRowIndex > _lastRowIndex) {
11037
+ rangeRows = afterFullData.slice(_lastRowIndex, _currRowIndex + 1)
11038
+ } else {
11039
+ rangeRows = afterFullData.slice(_firstRowIndex, _currRowIndex + 1)
11040
+ }
11041
+ }
10888
11042
  $xeTable.setAllCheckboxRow(false)
10889
- const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
10890
11043
  nextTick(() => {
10891
11044
  handleCheckedCheckboxRow(rangeRows, true, false)
10892
11045
  })
10893
11046
  dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
10894
- return
10895
11047
  }
10896
11048
  }
10897
11049
  }
10898
- if (isRowGroupStatus || !checkMethod || checkMethod({ $table: $xeTable, row })) {
11050
+
11051
+ if (!checkMethod || checkMethod({ $table: $xeTable, row })) {
10899
11052
  $xeTable.handleBatchSelectRows([row], checked)
10900
11053
  $xeTable.checkSelectionStatus()
10901
11054
  dispatchEvent('checkbox-change', Object.assign({
@@ -14470,9 +14623,6 @@ export default defineVxeComponent({
14470
14623
  if (props.editConfig && editOpts.activeMethod) {
14471
14624
  warnLog('vxe.error.delProp', ['edit-config.activeMethod', 'edit-config.beforeEditMethod'])
14472
14625
  }
14473
- if (props.treeConfig && checkboxOpts.isShiftKey) {
14474
- errLog('vxe.error.errConflicts', ['tree-config', 'checkbox-config.isShiftKey'])
14475
- }
14476
14626
  if (checkboxOpts.halfField) {
14477
14627
  warnLog('vxe.error.delProp', ['checkbox-config.halfField', 'checkbox-config.indeterminateField'])
14478
14628
  }
@@ -18,13 +18,16 @@
18
18
  font-family: var(--vxe-ui-font-family);
19
19
  background-color: var(--vxe-ui-layout-background-color);
20
20
  }
21
+ .vxe-context-menu--option {
22
+ color: var(--vxe-ui-font-color);
23
+ }
21
24
  .vxe-context-menu--link {
22
25
  display: flex;
23
26
  flex-direction: row;
24
27
  width: var(--vxe-ui-table-menu-item-width);
25
28
  line-height: 26px;
26
29
  padding: 0 0.8em;
27
- color: var(--vxe-ui-font-color);
30
+ color: inherit;
28
31
  cursor: pointer;
29
32
  .vxe-context-menu--link-prefix,
30
33
  .vxe-context-menu--link-suffix {
@@ -41,7 +44,7 @@
41
44
  white-space: nowrap;
42
45
  }
43
46
  }
44
- .vxe-context-menu--option-wrapper,
47
+ .vxe-table--context-menu-group-wrapper,
45
48
  .vxe-table--context-menu-clild-wrapper {
46
49
  margin: 0;
47
50
  padding: 0;