vxe-table 3.11.39 → 3.12.0-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 (61) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.min.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/style.min.css +1 -1
  5. package/es/table/module/custom/panel.js +6 -2
  6. package/es/table/render/index.js +3 -1
  7. package/es/table/src/body.js +56 -13
  8. package/es/table/src/footer.js +28 -3
  9. package/es/table/src/header.js +36 -6
  10. package/es/table/src/methods.js +136 -104
  11. package/es/table/src/table.js +5 -13
  12. package/es/table/style.css +3 -5
  13. package/es/table/style.min.css +1 -1
  14. package/es/ui/index.js +5 -3
  15. package/es/ui/src/log.js +1 -1
  16. package/es/vxe-table/style.css +3 -5
  17. package/es/vxe-table/style.min.css +1 -1
  18. package/lib/index.css +1 -1
  19. package/lib/index.min.css +1 -1
  20. package/lib/index.umd.js +294 -166
  21. package/lib/index.umd.min.js +1 -1
  22. package/lib/style.css +1 -1
  23. package/lib/style.min.css +1 -1
  24. package/lib/table/module/custom/panel.js +6 -4
  25. package/lib/table/module/custom/panel.min.js +1 -1
  26. package/lib/table/render/index.js +3 -1
  27. package/lib/table/render/index.min.js +1 -1
  28. package/lib/table/src/body.js +58 -13
  29. package/lib/table/src/body.min.js +1 -1
  30. package/lib/table/src/footer.js +31 -3
  31. package/lib/table/src/footer.min.js +1 -1
  32. package/lib/table/src/header.js +39 -6
  33. package/lib/table/src/header.min.js +1 -1
  34. package/lib/table/src/methods.js +146 -120
  35. package/lib/table/src/methods.min.js +1 -1
  36. package/lib/table/src/table.js +5 -15
  37. package/lib/table/src/table.min.js +1 -1
  38. package/lib/table/style/style.css +3 -5
  39. package/lib/table/style/style.min.css +1 -1
  40. package/lib/ui/index.js +5 -3
  41. package/lib/ui/index.min.js +1 -1
  42. package/lib/ui/src/log.js +1 -1
  43. package/lib/ui/src/log.min.js +1 -1
  44. package/lib/vxe-table/style/style.css +3 -5
  45. package/lib/vxe-table/style/style.min.css +1 -1
  46. package/package.json +1 -1
  47. package/packages/table/module/custom/panel.ts +7 -2
  48. package/packages/table/render/index.ts +3 -1
  49. package/packages/table/src/body.ts +56 -13
  50. package/packages/table/src/footer.ts +28 -3
  51. package/packages/table/src/header.ts +40 -7
  52. package/packages/table/src/methods.ts +140 -109
  53. package/packages/table/src/table.ts +6 -15
  54. package/packages/ui/index.ts +4 -2
  55. package/styles/components/table.scss +1 -3
  56. /package/es/{iconfont.1735027791418.ttf → iconfont.1735108867776.ttf} +0 -0
  57. /package/es/{iconfont.1735027791418.woff → iconfont.1735108867776.woff} +0 -0
  58. /package/es/{iconfont.1735027791418.woff2 → iconfont.1735108867776.woff2} +0 -0
  59. /package/lib/{iconfont.1735027791418.ttf → iconfont.1735108867776.ttf} +0 -0
  60. /package/lib/{iconfont.1735027791418.woff → iconfont.1735108867776.woff} +0 -0
  61. /package/lib/{iconfont.1735027791418.woff2 → iconfont.1735108867776.woff2} +0 -0
@@ -234,15 +234,15 @@ export default {
234
234
  const { fixedType, fixedColumn, tableColumn } = props
235
235
 
236
236
  const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps
237
- const { visibleColumn } = tableInternalData
238
- const { scrollbarWidth } = tableReactData
237
+ const { visibleColumn, fullColumnIdData } = tableInternalData
238
+ const { scrollXLoad, scrollYLoad, scrollbarWidth, dragCol } = tableReactData
239
239
 
240
240
  let renderColumnList = tableColumn
241
241
 
242
242
  // 如果是使用优化模式
243
243
  if (fixedType) {
244
244
  // 如果是使用优化模式
245
- if (allColumnFooterOverflow) {
245
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
246
246
  // 如果不支持优化模式
247
247
  if (spanMethod || footerSpanMethod) {
248
248
  renderColumnList = visibleColumn
@@ -254,6 +254,31 @@ export default {
254
254
  }
255
255
  }
256
256
 
257
+ if (!fixedType) {
258
+ // 列拖拽
259
+ if (scrollXLoad && dragCol) {
260
+ if (renderColumnList.length > 2) {
261
+ const dCowRest = fullColumnIdData[dragCol.id]
262
+ if (dCowRest) {
263
+ const dcIndex = dCowRest._index
264
+ const firstCol = renderColumnList[0]
265
+ const lastCol = renderColumnList[renderColumnList.length - 1]
266
+ const firstColRest = fullColumnIdData[firstCol.id]
267
+ const lastColRest = fullColumnIdData[lastCol.id]
268
+ if (firstColRest && lastColRest) {
269
+ const fcIndex = firstColRest._index
270
+ const lcIndex = lastColRest._index
271
+ if (dcIndex < fcIndex) {
272
+ renderColumnList = [dragCol].concat(renderColumnList)
273
+ } else if (dcIndex > lcIndex) {
274
+ renderColumnList = renderColumnList.concat([dragCol])
275
+ }
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
281
+
257
282
  const ons: Record<string, any> = {}
258
283
  if (!fixedType) {
259
284
  ons.scroll = this.scrollEvent
@@ -84,6 +84,7 @@ const renderRows = (h: CreateElement, _vm: any, cols: VxeTableDefines.ColumnInfo
84
84
  'is--sortable': column.sortable,
85
85
  'col--filter': !!column.filters,
86
86
  'is--filter-active': hasFilter,
87
+ 'is--drag-active': !column.fixed && !isDisabledDrag,
87
88
  'is--drag-disabled': isDisabledDrag,
88
89
  'col--current': currentColumn === column
89
90
  }, getClass(headerClassName, params), getClass(headerCellClassName, params)],
@@ -220,16 +221,18 @@ export default {
220
221
  const { headerColumn } = this
221
222
 
222
223
  const { showHeaderOverflow: allColumnHeaderOverflow, spanMethod, footerSpanMethod } = tableProps
223
- const { isGroup, scrollbarWidth } = tableReactData
224
- const { visibleColumn } = tableInternalData
225
- let headerGroups = headerColumn
226
- let renderColumnList = tableColumn
224
+ const { isGroup, scrollXLoad, scrollYLoad, scrollbarWidth, dragCol } = tableReactData
225
+ const { visibleColumn, fullColumnIdData } = tableInternalData
226
+
227
+ let renderHeaderList: VxeTableDefines.ColumnInfo[][] = headerColumn
228
+ let renderColumnList: VxeTableDefines.ColumnInfo[] = tableColumn
229
+
227
230
  if (isGroup) {
228
231
  renderColumnList = visibleColumn
229
232
  } else {
230
233
  if (fixedType) {
231
234
  // 如果是使用优化模式
232
- if (allColumnHeaderOverflow) {
235
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
233
236
  // 如果不支持优化模式
234
237
  if (spanMethod || footerSpanMethod) {
235
238
  renderColumnList = visibleColumn
@@ -240,8 +243,38 @@ export default {
240
243
  renderColumnList = visibleColumn
241
244
  }
242
245
  }
243
- headerGroups = [renderColumnList]
246
+ renderHeaderList = [renderColumnList]
247
+ }
248
+
249
+ if (!fixedType) {
250
+ // 列拖拽
251
+ if (scrollXLoad && dragCol) {
252
+ if (renderColumnList.length > 2) {
253
+ const dCowRest = fullColumnIdData[dragCol.id]
254
+ if (dCowRest) {
255
+ const dcIndex = dCowRest._index
256
+ const firstCol = renderColumnList[0]
257
+ const lastCol = renderColumnList[renderColumnList.length - 1]
258
+ const firstColRest = fullColumnIdData[firstCol.id]
259
+ const lastColRest = fullColumnIdData[lastCol.id]
260
+ if (firstColRest && lastColRest) {
261
+ const fcIndex = firstColRest._index
262
+ const lcIndex = lastColRest._index
263
+ console.log(dragCol.id, dcIndex, fcIndex, lcIndex, renderColumnList.length)
264
+ if (dcIndex < fcIndex) {
265
+ renderColumnList = [dragCol].concat(renderColumnList)
266
+ renderHeaderList = [[dragCol].concat(renderHeaderList[0])].concat(renderHeaderList.slice(1))
267
+ } else if (dcIndex > lcIndex) {
268
+ renderColumnList = renderColumnList.concat([dragCol])
269
+ renderHeaderList = [renderHeaderList[0].concat([dragCol])].concat(renderHeaderList.slice(1))
270
+ }
271
+ console.log(renderColumnList.length)
272
+ }
273
+ }
274
+ }
275
+ }
244
276
  }
277
+
245
278
  return h('div', {
246
279
  class: ['vxe-table--header-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
247
280
  attrs: {
@@ -290,7 +323,7 @@ export default {
290
323
  */
291
324
  h('thead', {
292
325
  ref: 'thead'
293
- }, renderHeads(h, this, headerGroups))
326
+ }, renderHeads(h, this, renderHeaderList))
294
327
  ]),
295
328
  /**
296
329
  * 其他
@@ -11,9 +11,6 @@ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf } from
11
11
 
12
12
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
13
13
 
14
- // const isWebkit = browse['-webkit'] && !browse.edge
15
- // const debounceScrollYDuration = browse.msie ? 80 : 20
16
-
17
14
  const customStorageKey = 'VXE_CUSTOM_STORE'
18
15
 
19
16
  // 获取所有的列,排除分组
@@ -300,7 +297,7 @@ const calcCellHeight = ($xeTable: any) => {
300
297
  const { showOverflow } = props
301
298
  const { tableData, scrollXLoad, scrollYLoad } = reactData
302
299
  const { fullAllDataRowIdData } = internalData
303
- const el = $xeTable.$el
300
+ const el = $xeTable.$refs.refElem as HTMLDivElement
304
301
  if (!showOverflow && (scrollXLoad || scrollYLoad) && el) {
305
302
  let paddingTop = 0
306
303
  let paddingBottom = 0
@@ -308,28 +305,27 @@ const calcCellHeight = ($xeTable: any) => {
308
305
  tableData.forEach((row: any) => {
309
306
  const rowid = getRowid($xeTable, row)
310
307
  const rowRest = fullAllDataRowIdData[rowid]
311
- const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`)
312
- if (rowRest && trList.length) {
308
+ const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell`)
309
+ if (rowRest && cellList.length) {
313
310
  let height = 0
314
- for (let i = 0; i < trList.length; i++) {
315
- const trEl = trList[i] as HTMLTableRowElement
316
- const tdList = trEl.children
317
- for (let j = 0; j < tdList.length; j++) {
318
- const tdEl = tdList[j]
319
- const cellElem = tdEl.querySelector('.vxe-cell') as HTMLDivElement
320
- if (!calcPadding) {
321
- paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop)
322
- paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom)
323
- calcPadding = true
324
- }
325
- let cellHeight = paddingTop + paddingBottom
326
- if (cellElem) {
327
- cellHeight += cellElem.offsetHeight
328
- }
329
- height = Math.max(height, cellHeight)
311
+ for (let i = 0; i < cellList.length; i++) {
312
+ const cellElem = cellList[i] as HTMLElement
313
+ const tdEl = cellElem.parentElement as HTMLTableCellElement
314
+ if (!tdEl || !tdEl.clientWidth) {
315
+ break
316
+ }
317
+ if (!calcPadding) {
318
+ paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop)
319
+ paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom)
320
+ calcPadding = true
330
321
  }
322
+ let cellHeight = paddingTop + paddingBottom
323
+ if (cellElem) {
324
+ cellHeight += cellElem.clientHeight
325
+ }
326
+ height = Math.max(height, cellHeight)
331
327
  }
332
- rowRest.height = height
328
+ rowRest.height = scrollXLoad ? Math.max(rowRest.height, height) : height
333
329
  }
334
330
  })
335
331
  }
@@ -450,15 +446,22 @@ function showDropTip ($xeTable: any, evnt: DragEvent | MouseEvent, trEl: HTMLEle
450
446
  const { scrollbarWidth, scrollbarHeight } = reactData
451
447
  const { prevDragToChild } = internalData
452
448
  const wrapperRect = el.getBoundingClientRect()
449
+ const tableWidth = el.clientWidth
450
+ const tableHeight = el.clientHeight
453
451
  if (trEl) {
454
452
  const rdLineEl = $xeTable.$refs.refDragRowLineElem as HTMLElement
455
453
  if (rdLineEl) {
456
454
  if (showLine) {
457
455
  const trRect = trEl.getBoundingClientRect()
456
+ let trHeight = trEl.clientHeight
457
+ const offsetTop = Math.max(1, trRect.y - wrapperRect.y)
458
+ if (offsetTop + trHeight > tableHeight - scrollbarHeight) {
459
+ trHeight = tableHeight - offsetTop - scrollbarHeight
460
+ }
458
461
  rdLineEl.style.display = 'block'
459
- rdLineEl.style.top = `${Math.max(1, trRect.y - wrapperRect.y)}px`
460
- rdLineEl.style.height = `${trRect.height}px`
461
- rdLineEl.style.width = `${wrapperRect.width - scrollbarWidth}px`
462
+ rdLineEl.style.top = `${offsetTop}px`
463
+ rdLineEl.style.height = `${trHeight}px`
464
+ rdLineEl.style.width = `${tableWidth - scrollbarWidth}px`
462
465
  rdLineEl.setAttribute('drag-pos', dragPos)
463
466
  rdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
464
467
  } else {
@@ -469,16 +472,31 @@ function showDropTip ($xeTable: any, evnt: DragEvent | MouseEvent, trEl: HTMLEle
469
472
  const cdLineEl = $xeTable.$refs.refDragColLineElem as HTMLElement
470
473
  if (cdLineEl) {
471
474
  if (showLine) {
475
+ const leftContainerElem = $xeTable.$refs.leftContainer as HTMLDivElement
476
+ const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
477
+ const rightContainerElem = $xeTable.$refs.rightContainer as HTMLDivElement
478
+ const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
472
479
  const thRect = thEl.getBoundingClientRect()
480
+ let thWidth = thEl.clientWidth
473
481
  const offsetTop = Math.max(0, thRect.y - wrapperRect.y)
482
+ const startX = leftContainerWidth
483
+ let offsetLeft = thRect.x - wrapperRect.x
484
+ if (offsetLeft < startX) {
485
+ thWidth -= startX - offsetLeft
486
+ offsetLeft = startX
487
+ }
488
+ const endX = tableWidth - rightContainerWidth - (rightContainerWidth ? 0 : scrollbarWidth)
489
+ if (offsetLeft + thWidth > endX) {
490
+ thWidth = endX - offsetLeft
491
+ }
474
492
  cdLineEl.style.display = 'block'
475
493
  cdLineEl.style.top = `${offsetTop}px`
476
- cdLineEl.style.left = `${Math.max(1, thRect.x - wrapperRect.x)}px`
477
- cdLineEl.style.width = `${thRect.width}px`
494
+ cdLineEl.style.left = `${offsetLeft}px`
495
+ cdLineEl.style.width = `${thWidth}px`
478
496
  if (prevDragToChild) {
479
497
  cdLineEl.style.height = `${thRect.height}px`
480
498
  } else {
481
- cdLineEl.style.height = `${wrapperRect.height - offsetTop - scrollbarHeight}px`
499
+ cdLineEl.style.height = `${tableHeight - offsetTop - scrollbarHeight}px`
482
500
  }
483
501
  cdLineEl.setAttribute('drag-pos', dragPos)
484
502
  cdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
@@ -925,7 +943,7 @@ const Methods = {
925
943
  ).then(() => {
926
944
  this._isLoading = false
927
945
  this.cacheColumnMap()
928
- this.parseColumns().then(() => {
946
+ this.parseColumns(true).then(() => {
929
947
  if (this.scrollXLoad) {
930
948
  this.loadScrollXData(true)
931
949
  }
@@ -2466,15 +2484,11 @@ const Methods = {
2466
2484
  /**
2467
2485
  * 刷新列配置
2468
2486
  */
2469
- refreshColumn (initOrder: any) {
2470
- if (initOrder) {
2471
- const columnList = XEUtils.orderBy(this.collectColumn, 'renderSortNumber')
2472
- this.collectColumn = columnList
2473
- const tableFullColumn = getColumnList(columnList)
2474
- this.tableFullColumn = tableFullColumn
2475
- this.cacheColumnMap()
2487
+ refreshColumn (initSort?: boolean) {
2488
+ if (initSort) {
2489
+ this.handleUpdateColumn()
2476
2490
  }
2477
- return this.parseColumns().then(() => {
2491
+ return this.parseColumns(true).then(() => {
2478
2492
  return this.refreshScroll()
2479
2493
  }).then(() => {
2480
2494
  return this.recalculate()
@@ -2484,7 +2498,7 @@ const Methods = {
2484
2498
  * 刷新列信息
2485
2499
  * 将固定的列左边、右边分别靠边
2486
2500
  */
2487
- parseColumns () {
2501
+ parseColumns (isReset: boolean) {
2488
2502
  const $xeTable = this
2489
2503
  const props = $xeTable
2490
2504
  const internalData = $xeTable
@@ -2575,10 +2589,12 @@ const Methods = {
2575
2589
  warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
2576
2590
  }
2577
2591
  }
2578
- const { visibleSize } = handleVirtualXVisible(this)
2579
- scrollXStore.startIndex = 0
2580
- scrollXStore.endIndex = visibleSize
2581
- scrollXStore.visibleSize = visibleSize
2592
+ if (isReset) {
2593
+ const { visibleSize } = handleVirtualXVisible(this)
2594
+ scrollXStore.startIndex = 0
2595
+ scrollXStore.endIndex = visibleSize
2596
+ scrollXStore.visibleSize = visibleSize
2597
+ }
2582
2598
  }
2583
2599
  // 如果列被显示/隐藏,则清除合并状态
2584
2600
  // 如果列被设置为固定,则清除合并状态
@@ -2596,12 +2612,15 @@ const Methods = {
2596
2612
  })
2597
2613
  this.visibleColumn = visibleColumn
2598
2614
  this.handleTableColumn()
2599
- return this.updateFooter().then(() => {
2600
- return this.recalculate()
2601
- }).then(() => {
2602
- this.updateCellAreas()
2603
- return this.recalculate()
2604
- })
2615
+ if (isReset) {
2616
+ return this.updateFooter().then(() => {
2617
+ return this.recalculate()
2618
+ }).then(() => {
2619
+ this.updateCellAreas()
2620
+ return this.recalculate()
2621
+ })
2622
+ }
2623
+ return this.updateFooter()
2605
2624
  },
2606
2625
  /**
2607
2626
  * 指定列宽的列进行拆分
@@ -2890,49 +2909,6 @@ const Methods = {
2890
2909
  this.checkScrolling()
2891
2910
  }
2892
2911
  },
2893
- calcCellHeight () {
2894
- const $xeTable = this
2895
- const props = $xeTable
2896
- const reactData = $xeTable
2897
- const internalData = $xeTable
2898
-
2899
- const { showOverflow } = props
2900
- const { tableData, scrollXLoad, scrollYLoad } = reactData
2901
- const { fullAllDataRowIdData } = internalData
2902
- const el = $xeTable.$el
2903
- if (!showOverflow && (scrollXLoad || scrollYLoad) && el) {
2904
- let paddingTop = 0
2905
- let paddingBottom = 0
2906
- let calcPadding = false
2907
- tableData.forEach((row: any) => {
2908
- const rowid = getRowid($xeTable, row)
2909
- const rowRest = fullAllDataRowIdData[rowid]
2910
- const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`)
2911
- if (rowRest && trList.length) {
2912
- let height = 0
2913
- for (let i = 0; i < trList.length; i++) {
2914
- const trEl = trList[i] as HTMLTableRowElement
2915
- const tdList = trEl.children
2916
- for (let j = 0; j < tdList.length; j++) {
2917
- const tdEl = tdList[j]
2918
- const cellElem = tdEl.querySelector('.vxe-cell') as HTMLDivElement
2919
- if (!calcPadding) {
2920
- paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop)
2921
- paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom)
2922
- calcPadding = true
2923
- }
2924
- let cellHeight = paddingTop + paddingBottom
2925
- if (cellElem) {
2926
- cellHeight += cellElem.offsetHeight
2927
- }
2928
- height = Math.max(height, cellHeight)
2929
- }
2930
- }
2931
- rowRest.height = scrollXLoad ? Math.max(rowRest.height, height) : height
2932
- }
2933
- })
2934
- }
2935
- },
2936
2912
  updateHeight () {
2937
2913
  this.customHeight = calcTableHeight(this, 'height')
2938
2914
  this.customMinHeight = calcTableHeight(this, 'minHeight')
@@ -3033,7 +3009,7 @@ const Methods = {
3033
3009
  } else {
3034
3010
  if (fixedType) {
3035
3011
  // 如果是使用优化模式
3036
- if (allColumnHeaderOverflow) {
3012
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
3037
3013
  // 如果不支持优化模式
3038
3014
  if (spanMethod || footerSpanMethod) {
3039
3015
  renderColumnList = visibleColumn
@@ -3163,7 +3139,7 @@ const Methods = {
3163
3139
 
3164
3140
  if (fixedType) {
3165
3141
  // 如果是使用优化模式
3166
- if (allColumnFooterOverflow) {
3142
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3167
3143
  // 如果不支持优化模式
3168
3144
  if (spanMethod || footerSpanMethod) {
3169
3145
  renderColumnList = visibleColumn
@@ -5181,7 +5157,8 @@ const Methods = {
5181
5157
  const triggerFilter = getEventTargetNode(evnt, cell, 'vxe-cell--filter').flag
5182
5158
  let triggerDrag = false
5183
5159
  if (!(triggerInput || triggerCheckbox || triggerSort || triggerFilter)) {
5184
- if (columnOpts.drag && trigger === 'cell' && !(disabledMethod && disabledMethod(params))) {
5160
+ const { column } = params
5161
+ if (columnOpts.drag && !column.fixed && trigger === 'cell' && !(disabledMethod && disabledMethod(params))) {
5185
5162
  triggerDrag = true
5186
5163
  $xeTable.handleHeaderCellDragMousedownEvent(evnt, params)
5187
5164
  }
@@ -5519,7 +5496,7 @@ const Methods = {
5519
5496
  evnt.dataTransfer.setDragImage(img, 0, 0)
5520
5497
  }
5521
5498
  },
5522
- handleHeaderCellDragDragendEvent (evnt: DragEvent) {
5499
+ handleColDragSwapEvent (evnt: DragEvent, isSyncColumn: boolean | undefined, dragCol: VxeTableDefines.ColumnInfo | null | undefined, prevDragCol: VxeTableDefines.ColumnInfo | undefined, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
5523
5500
  const $xeTable = this
5524
5501
  const props = $xeTable
5525
5502
  const reactData = $xeTable
@@ -5528,15 +5505,14 @@ const Methods = {
5528
5505
  const { mouseConfig } = props
5529
5506
  const columnDragOpts = $xeTable.computeColumnDragOpts
5530
5507
  const { isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts
5531
- const { dragCol } = reactData
5532
- const { collectColumn, prevDragCol, prevDragPos, prevDragToChild } = internalData
5508
+ const { collectColumn } = internalData
5533
5509
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
5534
5510
  if (prevDragCol && dragCol) {
5535
5511
  // 判断是否有拖动
5536
5512
  if (prevDragCol !== dragCol) {
5537
- const oldColumn: VxeTableDefines.ColumnInfo = dragCol
5538
- const newColumn: VxeTableDefines.ColumnInfo = prevDragCol
5539
- Promise.resolve(
5513
+ const oldColumn = dragCol
5514
+ const newColumn = prevDragCol
5515
+ return Promise.resolve(
5540
5516
  dragEndMethod
5541
5517
  ? dragEndMethod({
5542
5518
  oldColumn,
@@ -5663,10 +5639,6 @@ const Methods = {
5663
5639
  }
5664
5640
  }
5665
5641
 
5666
- $xeTable.refreshColumn(true).then(() => {
5667
- $xeTable.updateCellAreas()
5668
- })
5669
-
5670
5642
  $xeTable.dispatchEvent('column-dragend', {
5671
5643
  oldColumn,
5672
5644
  newColumn,
@@ -5678,11 +5650,27 @@ const Methods = {
5678
5650
  }
5679
5651
  }, evnt)
5680
5652
 
5681
- $xeTable.saveCustomStore('update:sort')
5653
+ if (isSyncColumn) {
5654
+ $xeTable.handleUpdateColumn()
5655
+ $xeTable.parseColumns(false).then(() => {
5656
+ $xeTable.updateCellAreas()
5657
+ return $xeTable.saveCustomStore('update:sort')
5658
+ })
5659
+ }
5682
5660
  }).catch(() => {
5683
5661
  })
5684
5662
  }
5685
5663
  }
5664
+ return Promise.resolve()
5665
+ },
5666
+ handleHeaderCellDragDragendEvent (evnt: DragEvent) {
5667
+ const $xeTable = this
5668
+ const reactData = $xeTable
5669
+ const internalData = $xeTable
5670
+
5671
+ const { dragCol } = reactData
5672
+ const { prevDragCol, prevDragPos, prevDragToChild } = internalData
5673
+ $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild)
5686
5674
  hideDropTip($xeTable)
5687
5675
  clearColDropOrigin($xeTable)
5688
5676
  internalData.prevDragToChild = false
@@ -5690,6 +5678,9 @@ const Methods = {
5690
5678
  reactData.dragCol = null
5691
5679
  setTimeout(() => {
5692
5680
  reactData.isDragColMove = false
5681
+ $xeTable.recalculate().then(() => {
5682
+ $xeTable.loadScrollXData()
5683
+ })
5693
5684
  }, 500)
5694
5685
  },
5695
5686
  handleHeaderCellDragDragoverEvent (evnt: DragEvent) {
@@ -5710,10 +5701,10 @@ const Methods = {
5710
5701
  const column = $xeTable.getColumnById(colid)
5711
5702
  if (column) {
5712
5703
  evnt.preventDefault()
5713
- const { dragCol } = reactData
5714
- const offsetX = evnt.clientX - thEl.getBoundingClientRect().x
5704
+ const { clientX } = evnt
5705
+ const offsetX = clientX - thEl.getBoundingClientRect().x
5715
5706
  const dragPos = offsetX < thEl.clientWidth / 2 ? 'left' : 'right'
5716
- if ((dragCol && dragCol.id === column.id) || (!isCrossDrag && column.parentId)) {
5707
+ if (column.fixed || (dragCol && dragCol.id === column.id) || (!isCrossDrag && column.parentId)) {
5717
5708
  showDropTip($xeTable, evnt, null, thEl, false, dragPos)
5718
5709
  return
5719
5710
  }
@@ -5726,6 +5717,36 @@ const Methods = {
5726
5717
  targetColumn: column,
5727
5718
  dragPos
5728
5719
  }, evnt)
5720
+
5721
+ // 边缘滚动
5722
+ const el = $xeTable.$refs.refElem as HTMLElement
5723
+ if (!el) {
5724
+ return
5725
+ }
5726
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
5727
+ const tableBody = $xeTable.$refs.tableBody
5728
+ const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
5729
+ const scrollTargetEl = xHandleEl || tableBodyElem
5730
+ if (scrollTargetEl) {
5731
+ const wrapperRect = el.getBoundingClientRect()
5732
+ const tableWidth = el.clientWidth
5733
+ const leftContainerElem = $xeTable.$refs.leftContainer as HTMLDivElement
5734
+ const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
5735
+ const rightContainerElem = $xeTable.$refs.rightContainer as HTMLDivElement
5736
+ const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0
5737
+ const srartX = wrapperRect.x + leftContainerWidth
5738
+ const endX = wrapperRect.x + tableWidth - rightContainerWidth
5739
+ const distSize = 28
5740
+ const startDistSize = clientX - srartX
5741
+ const endDistSize = endX - clientX
5742
+ if (startDistSize > 0 && startDistSize <= distSize) {
5743
+ const scrollRatio = Math.floor(tableWidth / (startDistSize > distSize / 2 ? 240 : 120))
5744
+ scrollTargetEl.scrollLeft -= scrollRatio * (distSize - startDistSize)
5745
+ } else if (endDistSize > 0 && endDistSize <= distSize) {
5746
+ const scrollRatio = Math.floor(tableWidth / (endDistSize > distSize / 2 ? 240 : 120))
5747
+ scrollTargetEl.scrollLeft += scrollRatio * (distSize - endDistSize)
5748
+ }
5749
+ }
5729
5750
  }
5730
5751
  },
5731
5752
  handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
@@ -6983,6 +7004,16 @@ const Methods = {
6983
7004
  })
6984
7005
  this.tableColumn = tableColumn
6985
7006
  },
7007
+ handleUpdateColumn () {
7008
+ const $xeTable = this
7009
+ const internalData = $xeTable
7010
+
7011
+ const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber')
7012
+ internalData.collectColumn = columnList
7013
+ const tableFullColumn = getColumnList(columnList)
7014
+ internalData.tableFullColumn = tableFullColumn
7015
+ $xeTable.cacheColumnMap()
7016
+ },
6986
7017
  updateScrollXData () {
6987
7018
  const $xeTable = this
6988
7019
  const props = $xeTable
@@ -23,7 +23,7 @@ import keyboardMixin from '../module/keyboard/mixin'
23
23
  import validatorMixin from '../module/validator/mixin'
24
24
  import customMixin from '../module/custom/mixin'
25
25
 
26
- import type { VxeLoadingComponent, VxeTooltipComponent, VxeTabsConstructor, VxeTabsPrivateMethods, VxeComponentStyleType } from 'vxe-pc-ui'
26
+ import type { VxeLoadingComponent, VxeTooltipComponent, VxeTabsConstructor, VxeTabsPrivateMethods } from 'vxe-pc-ui'
27
27
 
28
28
  const { getConfig, getIcon, getI18n, renderer, globalResize, globalEvents, globalMixins, renderEmptyElement } = VxeUI
29
29
 
@@ -778,18 +778,6 @@ export default {
778
778
  y: overflowY && scrollYLoad
779
779
  }
780
780
  },
781
- computeTableStyle () {
782
- const $xeTable = this
783
- const reactData = $xeTable
784
-
785
- const { tableData } = reactData
786
- const columnOpts = $xeTable.computeColumnOpts
787
- const stys: VxeComponentStyleType = {}
788
- if (columnOpts.drag) {
789
- stys['--vxe-ui-table-drag-column-move-delay'] = `${Math.max(0.06, Math.min(0.3, tableData.length / 800))}s`
790
- }
791
- return stys
792
- },
793
781
  tabsResizeFlag () {
794
782
  const $xeTable = this
795
783
  const $xeTabs = $xeTable.$xeTabs
@@ -844,6 +832,11 @@ export default {
844
832
  maxHeight () {
845
833
  this.$nextTick(() => this.recalculate(true))
846
834
  },
835
+ computeSize () {
836
+ this.$nextTick(() => {
837
+ this.recalculate(true).then(() => this.refreshScroll())
838
+ })
839
+ },
847
840
  syncResize (value: any) {
848
841
  if (value) {
849
842
  handleUupdateResize(this)
@@ -1255,7 +1248,6 @@ export default {
1255
1248
  const tableBorder = $xeTable.computeTableBorder
1256
1249
  const virtualScrollBars = $xeTable.computeVirtualScrollBars
1257
1250
  const isArea = mouseConfig && mouseOpts.area
1258
- const tableStyle = $xeTable.computeTableStyle
1259
1251
  const columnDragOpts = $xeTable.computeColumnDragOpts
1260
1252
  return h('div', {
1261
1253
  ref: 'refElem',
@@ -1290,7 +1282,6 @@ export default {
1290
1282
  'is--virtual-x': scrollXLoad,
1291
1283
  'is--virtual-y': scrollYLoad
1292
1284
  }],
1293
- style: tableStyle,
1294
1285
  attrs: {
1295
1286
  spellcheck: false
1296
1287
  },
@@ -49,11 +49,13 @@ VxeUI.setConfig({
49
49
  },
50
50
  rowDragConfig: {
51
51
  showIcon: true,
52
- animation: true
52
+ animation: true,
53
+ showGuidesStatus: true
53
54
  },
54
55
  columnDragConfig: {
55
56
  showIcon: true,
56
- animation: true
57
+ animation: true,
58
+ showGuidesStatus: true
57
59
  },
58
60
  checkboxConfig: {
59
61
  // trigger: 'default',
@@ -732,7 +732,7 @@
732
732
  &.col--drag-cell {
733
733
  .vxe-header--column {
734
734
  user-select: none;
735
- &:not(.is--drag-disabled) {
735
+ &.is--drag-active {
736
736
  cursor: grab;
737
737
  &:active {
738
738
  cursor: grabbing;
@@ -1377,7 +1377,6 @@
1377
1377
  .vxe-header--col-list-move {
1378
1378
  transition-property: transform;
1379
1379
  transition-duration: 0.35s;
1380
- transition-delay: var(--vxe-ui-table-drag-column-move-delay, 0.3s);
1381
1380
  }
1382
1381
 
1383
1382
  .vxe-table--drag-col-line,
@@ -1459,7 +1458,6 @@
1459
1458
  .vxe-body--row-list-move {
1460
1459
  transition-property: transform;
1461
1460
  transition-duration: 0.35s;
1462
- transition-delay: 0.05s;
1463
1461
  }
1464
1462
  .vxe-table--drag-sort-tip {
1465
1463
  display: none;