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
@@ -352,15 +352,9 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
352
352
  }
353
353
  // 拖拽行事件
354
354
  if (rowOpts.drag && (!treeConfig || transform)) {
355
- trOn.dragstart = (evnt) => {
356
- $xeTable.handleRowDragDragstartEvent(evnt);
357
- };
358
- trOn.dragover = (evnt) => {
359
- $xeTable.handleRowDragDragoverEvent(evnt);
360
- };
361
- trOn.dragend = (evnt) => {
362
- $xeTable.handleRowDragDragendEvent(evnt);
363
- };
355
+ trOn.dragstart = $xeTable.handleRowDragDragstartEvent;
356
+ trOn.dragend = $xeTable.handleRowDragDragendEvent;
357
+ trOn.dragover = $xeTable.handleRowDragDragoverEvent;
364
358
  }
365
359
  const trClass = [
366
360
  'vxe-body--row',
@@ -506,13 +500,14 @@ export default {
506
500
  const { tId, $scopedSlots } = $xeTable;
507
501
  const { fixedColumn, fixedType, tableColumn } = props;
508
502
  const { showOverflow: allColumnOverflow, spanMethod, footerSpanMethod, mouseConfig } = tableProps;
509
- const { tableData, scrollXLoad, scrollYLoad, isAllOverflow, isDragRowMove, expandColumn } = tableReactData;
510
- const { visibleColumn } = tableInternalData;
503
+ const { tableData, scrollXLoad, scrollYLoad, isAllOverflow, isDragRowMove, expandColumn, dragRow, dragCol } = tableReactData;
504
+ const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData;
511
505
  const rowOpts = $xeTable.computeRowOpts;
512
506
  const sYOpts = $xeTable.computeSYOpts;
513
507
  const emptyOpts = $xeTable.computeEmptyOpts;
514
508
  const mouseOpts = $xeTable.computeMouseOpts;
515
509
  const rowDragOpts = $xeTable.computeRowDragOpts;
510
+ let renderDataList = tableData;
516
511
  let renderColumnList = tableColumn;
517
512
  if (fixedType) {
518
513
  // 如果是使用优化模式
@@ -529,6 +524,54 @@ export default {
529
524
  renderColumnList = visibleColumn;
530
525
  }
531
526
  }
527
+ // 行拖拽
528
+ if (scrollYLoad && dragRow) {
529
+ if (renderDataList.length > 2) {
530
+ const dRowRest = fullAllDataRowIdData[getRowid($xeTable, dragRow)];
531
+ if (dRowRest) {
532
+ const drIndex = dRowRest._index;
533
+ const firstRow = renderDataList[0];
534
+ const lastRow = renderDataList[renderDataList.length - 1];
535
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)];
536
+ const lastRowRest = fullAllDataRowIdData[getRowid($xeTable, lastRow)];
537
+ if (firstRowRest && lastRowRest) {
538
+ const frIndex = firstRowRest._index;
539
+ const lrIndex = lastRowRest._index;
540
+ if (drIndex < frIndex) {
541
+ renderDataList = [dragRow].concat(renderDataList);
542
+ }
543
+ else if (drIndex > lrIndex) {
544
+ renderDataList = renderDataList.concat([dragRow]);
545
+ }
546
+ }
547
+ }
548
+ }
549
+ }
550
+ if (!fixedType) {
551
+ // 列拖拽
552
+ if (scrollXLoad && dragCol) {
553
+ if (renderColumnList.length > 2) {
554
+ const dCowRest = fullColumnIdData[dragCol.id];
555
+ if (dCowRest) {
556
+ const dcIndex = dCowRest._index;
557
+ const firstCol = renderColumnList[0];
558
+ const lastCol = renderColumnList[renderColumnList.length - 1];
559
+ const firstColRest = fullColumnIdData[firstCol.id];
560
+ const lastColRest = fullColumnIdData[lastCol.id];
561
+ if (firstColRest && lastColRest) {
562
+ const fcIndex = firstColRest._index;
563
+ const lcIndex = lastColRest._index;
564
+ if (dcIndex < fcIndex) {
565
+ renderColumnList = [dragCol].concat(renderColumnList);
566
+ }
567
+ else if (dcIndex > lcIndex) {
568
+ renderColumnList = renderColumnList.concat([dragCol]);
569
+ }
570
+ }
571
+ }
572
+ }
573
+ }
574
+ }
532
575
  let emptyContent;
533
576
  if ($scopedSlots.empty) {
534
577
  emptyContent = $scopedSlots.empty.call(this, { $table: $xeTable, $grid: $xeTable.xegrid }, h);
@@ -599,10 +642,10 @@ export default {
599
642
  tag: 'tbody',
600
643
  name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`
601
644
  }
602
- }, renderRows(h, this, $xeTable, fixedType, tableData, renderColumnList))
645
+ }, renderRows(h, this, $xeTable, fixedType, renderDataList, renderColumnList))
603
646
  : h('tbody', {
604
647
  ref: 'tbody'
605
- }, renderRows(h, this, $xeTable, fixedType, tableData, renderColumnList))
648
+ }, renderRows(h, this, $xeTable, fixedType, renderDataList, renderColumnList))
606
649
  ]),
607
650
  h('div', {
608
651
  class: 'vxe-table--checkbox-range'
@@ -219,13 +219,13 @@ export default {
219
219
  const { tId } = $xeTable;
220
220
  const { fixedType, fixedColumn, tableColumn } = props;
221
221
  const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps;
222
- const { visibleColumn } = tableInternalData;
223
- const { scrollbarWidth } = tableReactData;
222
+ const { visibleColumn, fullColumnIdData } = tableInternalData;
223
+ const { scrollXLoad, scrollYLoad, scrollbarWidth, dragCol } = tableReactData;
224
224
  let renderColumnList = tableColumn;
225
225
  // 如果是使用优化模式
226
226
  if (fixedType) {
227
227
  // 如果是使用优化模式
228
- if (allColumnFooterOverflow) {
228
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
229
229
  // 如果不支持优化模式
230
230
  if (spanMethod || footerSpanMethod) {
231
231
  renderColumnList = visibleColumn;
@@ -238,6 +238,31 @@ export default {
238
238
  renderColumnList = visibleColumn;
239
239
  }
240
240
  }
241
+ if (!fixedType) {
242
+ // 列拖拽
243
+ if (scrollXLoad && dragCol) {
244
+ if (renderColumnList.length > 2) {
245
+ const dCowRest = fullColumnIdData[dragCol.id];
246
+ if (dCowRest) {
247
+ const dcIndex = dCowRest._index;
248
+ const firstCol = renderColumnList[0];
249
+ const lastCol = renderColumnList[renderColumnList.length - 1];
250
+ const firstColRest = fullColumnIdData[firstCol.id];
251
+ const lastColRest = fullColumnIdData[lastCol.id];
252
+ if (firstColRest && lastColRest) {
253
+ const fcIndex = firstColRest._index;
254
+ const lcIndex = lastColRest._index;
255
+ if (dcIndex < fcIndex) {
256
+ renderColumnList = [dragCol].concat(renderColumnList);
257
+ }
258
+ else if (dcIndex > lcIndex) {
259
+ renderColumnList = renderColumnList.concat([dragCol]);
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ }
241
266
  const ons = {};
242
267
  if (!fixedType) {
243
268
  ons.scroll = this.scrollEvent;
@@ -75,6 +75,7 @@ const renderRows = (h, _vm, cols, $rowIndex) => {
75
75
  'is--sortable': column.sortable,
76
76
  'col--filter': !!column.filters,
77
77
  'is--filter-active': hasFilter,
78
+ 'is--drag-active': !column.fixed && !isDisabledDrag,
78
79
  'is--drag-disabled': isDisabledDrag,
79
80
  'col--current': currentColumn === column
80
81
  }, getClass(headerClassName, params), getClass(headerCellClassName, params)],
@@ -202,9 +203,9 @@ export default {
202
203
  const { fixedType, fixedColumn, tableColumn } = props;
203
204
  const { headerColumn } = this;
204
205
  const { showHeaderOverflow: allColumnHeaderOverflow, spanMethod, footerSpanMethod } = tableProps;
205
- const { isGroup, scrollbarWidth } = tableReactData;
206
- const { visibleColumn } = tableInternalData;
207
- let headerGroups = headerColumn;
206
+ const { isGroup, scrollXLoad, scrollYLoad, scrollbarWidth, dragCol } = tableReactData;
207
+ const { visibleColumn, fullColumnIdData } = tableInternalData;
208
+ let renderHeaderList = headerColumn;
208
209
  let renderColumnList = tableColumn;
209
210
  if (isGroup) {
210
211
  renderColumnList = visibleColumn;
@@ -212,7 +213,7 @@ export default {
212
213
  else {
213
214
  if (fixedType) {
214
215
  // 如果是使用优化模式
215
- if (allColumnHeaderOverflow) {
216
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
216
217
  // 如果不支持优化模式
217
218
  if (spanMethod || footerSpanMethod) {
218
219
  renderColumnList = visibleColumn;
@@ -225,7 +226,36 @@ export default {
225
226
  renderColumnList = visibleColumn;
226
227
  }
227
228
  }
228
- headerGroups = [renderColumnList];
229
+ renderHeaderList = [renderColumnList];
230
+ }
231
+ if (!fixedType) {
232
+ // 列拖拽
233
+ if (scrollXLoad && dragCol) {
234
+ if (renderColumnList.length > 2) {
235
+ const dCowRest = fullColumnIdData[dragCol.id];
236
+ if (dCowRest) {
237
+ const dcIndex = dCowRest._index;
238
+ const firstCol = renderColumnList[0];
239
+ const lastCol = renderColumnList[renderColumnList.length - 1];
240
+ const firstColRest = fullColumnIdData[firstCol.id];
241
+ const lastColRest = fullColumnIdData[lastCol.id];
242
+ if (firstColRest && lastColRest) {
243
+ const fcIndex = firstColRest._index;
244
+ const lcIndex = lastColRest._index;
245
+ console.log(dragCol.id, dcIndex, fcIndex, lcIndex, renderColumnList.length);
246
+ if (dcIndex < fcIndex) {
247
+ renderColumnList = [dragCol].concat(renderColumnList);
248
+ renderHeaderList = [[dragCol].concat(renderHeaderList[0])].concat(renderHeaderList.slice(1));
249
+ }
250
+ else if (dcIndex > lcIndex) {
251
+ renderColumnList = renderColumnList.concat([dragCol]);
252
+ renderHeaderList = [renderHeaderList[0].concat([dragCol])].concat(renderHeaderList.slice(1));
253
+ }
254
+ console.log(renderColumnList.length);
255
+ }
256
+ }
257
+ }
258
+ }
229
259
  }
230
260
  return h('div', {
231
261
  class: ['vxe-table--header-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
@@ -275,7 +305,7 @@ export default {
275
305
  */
276
306
  h('thead', {
277
307
  ref: 'thead'
278
- }, renderHeads(h, this, headerGroups))
308
+ }, renderHeads(h, this, renderHeaderList))
279
309
  ]),
280
310
  /**
281
311
  * 其他
@@ -7,8 +7,6 @@ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible,
7
7
  import { getSlotVNs } from '../../ui/src/vn';
8
8
  import { warnLog, errLog } from '../../ui/src/log';
9
9
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
10
- // const isWebkit = browse['-webkit'] && !browse.edge
11
- // const debounceScrollYDuration = browse.msie ? 80 : 20
12
10
  const customStorageKey = 'VXE_CUSTOM_STORE';
13
11
  // 获取所有的列,排除分组
14
12
  const getColumnList = (columns) => {
@@ -280,7 +278,7 @@ const calcCellHeight = ($xeTable) => {
280
278
  const { showOverflow } = props;
281
279
  const { tableData, scrollXLoad, scrollYLoad } = reactData;
282
280
  const { fullAllDataRowIdData } = internalData;
283
- const el = $xeTable.$el;
281
+ const el = $xeTable.$refs.refElem;
284
282
  if (!showOverflow && (scrollXLoad || scrollYLoad) && el) {
285
283
  let paddingTop = 0;
286
284
  let paddingBottom = 0;
@@ -288,28 +286,27 @@ const calcCellHeight = ($xeTable) => {
288
286
  tableData.forEach((row) => {
289
287
  const rowid = getRowid($xeTable, row);
290
288
  const rowRest = fullAllDataRowIdData[rowid];
291
- const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`);
292
- if (rowRest && trList.length) {
289
+ const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell`);
290
+ if (rowRest && cellList.length) {
293
291
  let height = 0;
294
- for (let i = 0; i < trList.length; i++) {
295
- const trEl = trList[i];
296
- const tdList = trEl.children;
297
- for (let j = 0; j < tdList.length; j++) {
298
- const tdEl = tdList[j];
299
- const cellElem = tdEl.querySelector('.vxe-cell');
300
- if (!calcPadding) {
301
- paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop);
302
- paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom);
303
- calcPadding = true;
304
- }
305
- let cellHeight = paddingTop + paddingBottom;
306
- if (cellElem) {
307
- cellHeight += cellElem.offsetHeight;
308
- }
309
- height = Math.max(height, cellHeight);
292
+ for (let i = 0; i < cellList.length; i++) {
293
+ const cellElem = cellList[i];
294
+ const tdEl = cellElem.parentElement;
295
+ if (!tdEl || !tdEl.clientWidth) {
296
+ break;
310
297
  }
298
+ if (!calcPadding) {
299
+ paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop);
300
+ paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom);
301
+ calcPadding = true;
302
+ }
303
+ let cellHeight = paddingTop + paddingBottom;
304
+ if (cellElem) {
305
+ cellHeight += cellElem.clientHeight;
306
+ }
307
+ height = Math.max(height, cellHeight);
311
308
  }
312
- rowRest.height = height;
309
+ rowRest.height = scrollXLoad ? Math.max(rowRest.height, height) : height;
313
310
  }
314
311
  });
315
312
  }
@@ -424,15 +421,22 @@ function showDropTip($xeTable, evnt, trEl, thEl, showLine, dragPos) {
424
421
  const { scrollbarWidth, scrollbarHeight } = reactData;
425
422
  const { prevDragToChild } = internalData;
426
423
  const wrapperRect = el.getBoundingClientRect();
424
+ const tableWidth = el.clientWidth;
425
+ const tableHeight = el.clientHeight;
427
426
  if (trEl) {
428
427
  const rdLineEl = $xeTable.$refs.refDragRowLineElem;
429
428
  if (rdLineEl) {
430
429
  if (showLine) {
431
430
  const trRect = trEl.getBoundingClientRect();
431
+ let trHeight = trEl.clientHeight;
432
+ const offsetTop = Math.max(1, trRect.y - wrapperRect.y);
433
+ if (offsetTop + trHeight > tableHeight - scrollbarHeight) {
434
+ trHeight = tableHeight - offsetTop - scrollbarHeight;
435
+ }
432
436
  rdLineEl.style.display = 'block';
433
- rdLineEl.style.top = `${Math.max(1, trRect.y - wrapperRect.y)}px`;
434
- rdLineEl.style.height = `${trRect.height}px`;
435
- rdLineEl.style.width = `${wrapperRect.width - scrollbarWidth}px`;
437
+ rdLineEl.style.top = `${offsetTop}px`;
438
+ rdLineEl.style.height = `${trHeight}px`;
439
+ rdLineEl.style.width = `${tableWidth - scrollbarWidth}px`;
436
440
  rdLineEl.setAttribute('drag-pos', dragPos);
437
441
  rdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n');
438
442
  }
@@ -445,17 +449,32 @@ function showDropTip($xeTable, evnt, trEl, thEl, showLine, dragPos) {
445
449
  const cdLineEl = $xeTable.$refs.refDragColLineElem;
446
450
  if (cdLineEl) {
447
451
  if (showLine) {
452
+ const leftContainerElem = $xeTable.$refs.leftContainer;
453
+ const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
454
+ const rightContainerElem = $xeTable.$refs.rightContainer;
455
+ const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
448
456
  const thRect = thEl.getBoundingClientRect();
457
+ let thWidth = thEl.clientWidth;
449
458
  const offsetTop = Math.max(0, thRect.y - wrapperRect.y);
459
+ const startX = leftContainerWidth;
460
+ let offsetLeft = thRect.x - wrapperRect.x;
461
+ if (offsetLeft < startX) {
462
+ thWidth -= startX - offsetLeft;
463
+ offsetLeft = startX;
464
+ }
465
+ const endX = tableWidth - rightContainerWidth - (rightContainerWidth ? 0 : scrollbarWidth);
466
+ if (offsetLeft + thWidth > endX) {
467
+ thWidth = endX - offsetLeft;
468
+ }
450
469
  cdLineEl.style.display = 'block';
451
470
  cdLineEl.style.top = `${offsetTop}px`;
452
- cdLineEl.style.left = `${Math.max(1, thRect.x - wrapperRect.x)}px`;
453
- cdLineEl.style.width = `${thRect.width}px`;
471
+ cdLineEl.style.left = `${offsetLeft}px`;
472
+ cdLineEl.style.width = `${thWidth}px`;
454
473
  if (prevDragToChild) {
455
474
  cdLineEl.style.height = `${thRect.height}px`;
456
475
  }
457
476
  else {
458
- cdLineEl.style.height = `${wrapperRect.height - offsetTop - scrollbarHeight}px`;
477
+ cdLineEl.style.height = `${tableHeight - offsetTop - scrollbarHeight}px`;
459
478
  }
460
479
  cdLineEl.setAttribute('drag-pos', dragPos);
461
480
  cdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n');
@@ -895,7 +914,7 @@ const Methods = {
895
914
  return Promise.resolve(this.restoreCustomStorage()).then(() => {
896
915
  this._isLoading = false;
897
916
  this.cacheColumnMap();
898
- this.parseColumns().then(() => {
917
+ this.parseColumns(true).then(() => {
899
918
  if (this.scrollXLoad) {
900
919
  this.loadScrollXData(true);
901
920
  }
@@ -2444,15 +2463,11 @@ const Methods = {
2444
2463
  /**
2445
2464
  * 刷新列配置
2446
2465
  */
2447
- refreshColumn(initOrder) {
2448
- if (initOrder) {
2449
- const columnList = XEUtils.orderBy(this.collectColumn, 'renderSortNumber');
2450
- this.collectColumn = columnList;
2451
- const tableFullColumn = getColumnList(columnList);
2452
- this.tableFullColumn = tableFullColumn;
2453
- this.cacheColumnMap();
2466
+ refreshColumn(initSort) {
2467
+ if (initSort) {
2468
+ this.handleUpdateColumn();
2454
2469
  }
2455
- return this.parseColumns().then(() => {
2470
+ return this.parseColumns(true).then(() => {
2456
2471
  return this.refreshScroll();
2457
2472
  }).then(() => {
2458
2473
  return this.recalculate();
@@ -2462,7 +2477,7 @@ const Methods = {
2462
2477
  * 刷新列信息
2463
2478
  * 将固定的列左边、右边分别靠边
2464
2479
  */
2465
- parseColumns() {
2480
+ parseColumns(isReset) {
2466
2481
  const $xeTable = this;
2467
2482
  const props = $xeTable;
2468
2483
  const internalData = $xeTable;
@@ -2560,10 +2575,12 @@ const Methods = {
2560
2575
  warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
2561
2576
  }
2562
2577
  }
2563
- const { visibleSize } = handleVirtualXVisible(this);
2564
- scrollXStore.startIndex = 0;
2565
- scrollXStore.endIndex = visibleSize;
2566
- scrollXStore.visibleSize = visibleSize;
2578
+ if (isReset) {
2579
+ const { visibleSize } = handleVirtualXVisible(this);
2580
+ scrollXStore.startIndex = 0;
2581
+ scrollXStore.endIndex = visibleSize;
2582
+ scrollXStore.visibleSize = visibleSize;
2583
+ }
2567
2584
  }
2568
2585
  // 如果列被显示/隐藏,则清除合并状态
2569
2586
  // 如果列被设置为固定,则清除合并状态
@@ -2581,12 +2598,15 @@ const Methods = {
2581
2598
  });
2582
2599
  this.visibleColumn = visibleColumn;
2583
2600
  this.handleTableColumn();
2584
- return this.updateFooter().then(() => {
2585
- return this.recalculate();
2586
- }).then(() => {
2587
- this.updateCellAreas();
2588
- return this.recalculate();
2589
- });
2601
+ if (isReset) {
2602
+ return this.updateFooter().then(() => {
2603
+ return this.recalculate();
2604
+ }).then(() => {
2605
+ this.updateCellAreas();
2606
+ return this.recalculate();
2607
+ });
2608
+ }
2609
+ return this.updateFooter();
2590
2610
  },
2591
2611
  /**
2592
2612
  * 指定列宽的列进行拆分
@@ -2881,48 +2901,6 @@ const Methods = {
2881
2901
  this.checkScrolling();
2882
2902
  }
2883
2903
  },
2884
- calcCellHeight() {
2885
- const $xeTable = this;
2886
- const props = $xeTable;
2887
- const reactData = $xeTable;
2888
- const internalData = $xeTable;
2889
- const { showOverflow } = props;
2890
- const { tableData, scrollXLoad, scrollYLoad } = reactData;
2891
- const { fullAllDataRowIdData } = internalData;
2892
- const el = $xeTable.$el;
2893
- if (!showOverflow && (scrollXLoad || scrollYLoad) && el) {
2894
- let paddingTop = 0;
2895
- let paddingBottom = 0;
2896
- let calcPadding = false;
2897
- tableData.forEach((row) => {
2898
- const rowid = getRowid($xeTable, row);
2899
- const rowRest = fullAllDataRowIdData[rowid];
2900
- const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`);
2901
- if (rowRest && trList.length) {
2902
- let height = 0;
2903
- for (let i = 0; i < trList.length; i++) {
2904
- const trEl = trList[i];
2905
- const tdList = trEl.children;
2906
- for (let j = 0; j < tdList.length; j++) {
2907
- const tdEl = tdList[j];
2908
- const cellElem = tdEl.querySelector('.vxe-cell');
2909
- if (!calcPadding) {
2910
- paddingTop = XEUtils.toNumber(getComputedStyle(tdEl).paddingTop);
2911
- paddingBottom = XEUtils.toNumber(getComputedStyle(tdEl).paddingBottom);
2912
- calcPadding = true;
2913
- }
2914
- let cellHeight = paddingTop + paddingBottom;
2915
- if (cellElem) {
2916
- cellHeight += cellElem.offsetHeight;
2917
- }
2918
- height = Math.max(height, cellHeight);
2919
- }
2920
- }
2921
- rowRest.height = scrollXLoad ? Math.max(rowRest.height, height) : height;
2922
- }
2923
- });
2924
- }
2925
- },
2926
2904
  updateHeight() {
2927
2905
  this.customHeight = calcTableHeight(this, 'height');
2928
2906
  this.customMinHeight = calcTableHeight(this, 'minHeight');
@@ -2986,7 +2964,7 @@ const Methods = {
2986
2964
  else {
2987
2965
  if (fixedType) {
2988
2966
  // 如果是使用优化模式
2989
- if (allColumnHeaderOverflow) {
2967
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
2990
2968
  // 如果不支持优化模式
2991
2969
  if (spanMethod || footerSpanMethod) {
2992
2970
  renderColumnList = visibleColumn;
@@ -3113,7 +3091,7 @@ const Methods = {
3113
3091
  let renderColumnList = tableColumn;
3114
3092
  if (fixedType) {
3115
3093
  // 如果是使用优化模式
3116
- if (allColumnFooterOverflow) {
3094
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3117
3095
  // 如果不支持优化模式
3118
3096
  if (spanMethod || footerSpanMethod) {
3119
3097
  renderColumnList = visibleColumn;
@@ -5164,7 +5142,8 @@ const Methods = {
5164
5142
  const triggerFilter = getEventTargetNode(evnt, cell, 'vxe-cell--filter').flag;
5165
5143
  let triggerDrag = false;
5166
5144
  if (!(triggerInput || triggerCheckbox || triggerSort || triggerFilter)) {
5167
- if (columnOpts.drag && trigger === 'cell' && !(disabledMethod && disabledMethod(params))) {
5145
+ const { column } = params;
5146
+ if (columnOpts.drag && !column.fixed && trigger === 'cell' && !(disabledMethod && disabledMethod(params))) {
5168
5147
  triggerDrag = true;
5169
5148
  $xeTable.handleHeaderCellDragMousedownEvent(evnt, params);
5170
5149
  }
@@ -5486,7 +5465,7 @@ const Methods = {
5486
5465
  evnt.dataTransfer.setDragImage(img, 0, 0);
5487
5466
  }
5488
5467
  },
5489
- handleHeaderCellDragDragendEvent(evnt) {
5468
+ handleColDragSwapEvent(evnt, isSyncColumn, dragCol, prevDragCol, prevDragPos, prevDragToChild) {
5490
5469
  const $xeTable = this;
5491
5470
  const props = $xeTable;
5492
5471
  const reactData = $xeTable;
@@ -5494,15 +5473,14 @@ const Methods = {
5494
5473
  const { mouseConfig } = props;
5495
5474
  const columnDragOpts = $xeTable.computeColumnDragOpts;
5496
5475
  const { isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts;
5497
- const { dragCol } = reactData;
5498
- const { collectColumn, prevDragCol, prevDragPos, prevDragToChild } = internalData;
5476
+ const { collectColumn } = internalData;
5499
5477
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
5500
5478
  if (prevDragCol && dragCol) {
5501
5479
  // 判断是否有拖动
5502
5480
  if (prevDragCol !== dragCol) {
5503
5481
  const oldColumn = dragCol;
5504
5482
  const newColumn = prevDragCol;
5505
- Promise.resolve(dragEndMethod
5483
+ return Promise.resolve(dragEndMethod
5506
5484
  ? dragEndMethod({
5507
5485
  oldColumn,
5508
5486
  newColumn,
@@ -5619,9 +5597,6 @@ const Methods = {
5619
5597
  $xeTable.clearCopyCellArea();
5620
5598
  }
5621
5599
  }
5622
- $xeTable.refreshColumn(true).then(() => {
5623
- $xeTable.updateCellAreas();
5624
- });
5625
5600
  $xeTable.dispatchEvent('column-dragend', {
5626
5601
  oldColumn,
5627
5602
  newColumn,
@@ -5632,11 +5607,26 @@ const Methods = {
5632
5607
  oldIndex: oafIndex
5633
5608
  }
5634
5609
  }, evnt);
5635
- $xeTable.saveCustomStore('update:sort');
5610
+ if (isSyncColumn) {
5611
+ $xeTable.handleUpdateColumn();
5612
+ $xeTable.parseColumns(false).then(() => {
5613
+ $xeTable.updateCellAreas();
5614
+ return $xeTable.saveCustomStore('update:sort');
5615
+ });
5616
+ }
5636
5617
  }).catch(() => {
5637
5618
  });
5638
5619
  }
5639
5620
  }
5621
+ return Promise.resolve();
5622
+ },
5623
+ handleHeaderCellDragDragendEvent(evnt) {
5624
+ const $xeTable = this;
5625
+ const reactData = $xeTable;
5626
+ const internalData = $xeTable;
5627
+ const { dragCol } = reactData;
5628
+ const { prevDragCol, prevDragPos, prevDragToChild } = internalData;
5629
+ $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild);
5640
5630
  hideDropTip($xeTable);
5641
5631
  clearColDropOrigin($xeTable);
5642
5632
  internalData.prevDragToChild = false;
@@ -5644,6 +5634,9 @@ const Methods = {
5644
5634
  reactData.dragCol = null;
5645
5635
  setTimeout(() => {
5646
5636
  reactData.isDragColMove = false;
5637
+ $xeTable.recalculate().then(() => {
5638
+ $xeTable.loadScrollXData();
5639
+ });
5647
5640
  }, 500);
5648
5641
  },
5649
5642
  handleHeaderCellDragDragoverEvent(evnt) {
@@ -5663,10 +5656,10 @@ const Methods = {
5663
5656
  const column = $xeTable.getColumnById(colid);
5664
5657
  if (column) {
5665
5658
  evnt.preventDefault();
5666
- const { dragCol } = reactData;
5667
- const offsetX = evnt.clientX - thEl.getBoundingClientRect().x;
5659
+ const { clientX } = evnt;
5660
+ const offsetX = clientX - thEl.getBoundingClientRect().x;
5668
5661
  const dragPos = offsetX < thEl.clientWidth / 2 ? 'left' : 'right';
5669
- if ((dragCol && dragCol.id === column.id) || (!isCrossDrag && column.parentId)) {
5662
+ if (column.fixed || (dragCol && dragCol.id === column.id) || (!isCrossDrag && column.parentId)) {
5670
5663
  showDropTip($xeTable, evnt, null, thEl, false, dragPos);
5671
5664
  return;
5672
5665
  }
@@ -5679,6 +5672,36 @@ const Methods = {
5679
5672
  targetColumn: column,
5680
5673
  dragPos
5681
5674
  }, evnt);
5675
+ // 边缘滚动
5676
+ const el = $xeTable.$refs.refElem;
5677
+ if (!el) {
5678
+ return;
5679
+ }
5680
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
5681
+ const tableBody = $xeTable.$refs.tableBody;
5682
+ const tableBodyElem = tableBody ? tableBody.$el : null;
5683
+ const scrollTargetEl = xHandleEl || tableBodyElem;
5684
+ if (scrollTargetEl) {
5685
+ const wrapperRect = el.getBoundingClientRect();
5686
+ const tableWidth = el.clientWidth;
5687
+ const leftContainerElem = $xeTable.$refs.leftContainer;
5688
+ const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
5689
+ const rightContainerElem = $xeTable.$refs.rightContainer;
5690
+ const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
5691
+ const srartX = wrapperRect.x + leftContainerWidth;
5692
+ const endX = wrapperRect.x + tableWidth - rightContainerWidth;
5693
+ const distSize = 28;
5694
+ const startDistSize = clientX - srartX;
5695
+ const endDistSize = endX - clientX;
5696
+ if (startDistSize > 0 && startDistSize <= distSize) {
5697
+ const scrollRatio = Math.floor(tableWidth / (startDistSize > distSize / 2 ? 240 : 120));
5698
+ scrollTargetEl.scrollLeft -= scrollRatio * (distSize - startDistSize);
5699
+ }
5700
+ else if (endDistSize > 0 && endDistSize <= distSize) {
5701
+ const scrollRatio = Math.floor(tableWidth / (endDistSize > distSize / 2 ? 240 : 120));
5702
+ scrollTargetEl.scrollLeft += scrollRatio * (distSize - endDistSize);
5703
+ }
5704
+ }
5682
5705
  }
5683
5706
  },
5684
5707
  handleHeaderCellDragMousedownEvent(evnt, params) {
@@ -6925,6 +6948,15 @@ const Methods = {
6925
6948
  });
6926
6949
  this.tableColumn = tableColumn;
6927
6950
  },
6951
+ handleUpdateColumn() {
6952
+ const $xeTable = this;
6953
+ const internalData = $xeTable;
6954
+ const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
6955
+ internalData.collectColumn = columnList;
6956
+ const tableFullColumn = getColumnList(columnList);
6957
+ internalData.tableFullColumn = tableFullColumn;
6958
+ $xeTable.cacheColumnMap();
6959
+ },
6928
6960
  updateScrollXData() {
6929
6961
  const $xeTable = this;
6930
6962
  const props = $xeTable;