vxe-table 4.8.8 → 4.8.10

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.
@@ -378,9 +378,25 @@ export default defineComponent({
378
378
  const computeSXOpts = computed(() => {
379
379
  return Object.assign({}, getConfig().table.scrollX, props.scrollX);
380
380
  });
381
+ const computeScrollXThreshold = computed(() => {
382
+ const sXOpts = computeSXOpts.value;
383
+ const { threshold } = sXOpts;
384
+ if (threshold) {
385
+ return XEUtils.toNumber(threshold);
386
+ }
387
+ return 0;
388
+ });
381
389
  const computeSYOpts = computed(() => {
382
390
  return Object.assign({}, getConfig().table.scrollY, props.scrollY);
383
391
  });
392
+ const computeScrollYThreshold = computed(() => {
393
+ const sYOpts = computeSYOpts.value;
394
+ const { threshold } = sYOpts;
395
+ if (threshold) {
396
+ return XEUtils.toNumber(threshold);
397
+ }
398
+ return 0;
399
+ });
384
400
  const computeRowHeightMaps = computed(() => {
385
401
  return {
386
402
  default: 48,
@@ -2838,24 +2854,17 @@ export default defineComponent({
2838
2854
  setScrollLeft(bodyElem, scrollLeft);
2839
2855
  setScrollLeft(headerElem, scrollLeft);
2840
2856
  setScrollLeft(footerElem, scrollLeft);
2841
- setScrollLeft(bodyElem, scrollLeft);
2842
- setScrollLeft(headerElem, scrollLeft);
2843
- setScrollLeft(footerElem, scrollLeft);
2844
2857
  };
2845
2858
  const scrollXEvent = (evnt) => {
2846
2859
  const wrapperEl = evnt.currentTarget;
2847
2860
  const { scrollTop, scrollLeft } = wrapperEl;
2848
2861
  const isRollX = true;
2849
2862
  const isRollY = false;
2850
- internalData.lastScrollLeft = scrollLeft;
2851
- reactData.lastScrollTime = Date.now();
2852
2863
  handleSyncScrollX(scrollLeft);
2853
2864
  $xeTable.triggerScrollXEvent(evnt);
2854
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
2865
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
2855
2866
  type: 'table',
2856
- fixed: '',
2857
- scrollTop,
2858
- scrollLeft
2867
+ fixed: ''
2859
2868
  });
2860
2869
  };
2861
2870
  const debounceScrollYCalculate = XEUtils.debounce(function () {
@@ -2877,15 +2886,11 @@ export default defineComponent({
2877
2886
  const { scrollTop, scrollLeft } = wrapperEl;
2878
2887
  const isRollX = false;
2879
2888
  const isRollY = true;
2880
- internalData.lastScrollTop = scrollTop;
2881
- reactData.lastScrollTime = Date.now();
2882
2889
  handleSyncScrollY(scrollTop);
2883
2890
  $xeTable.triggerScrollYEvent(evnt);
2884
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
2891
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
2885
2892
  type: 'table',
2886
- fixed: '',
2887
- scrollTop,
2888
- scrollLeft
2893
+ fixed: ''
2889
2894
  });
2890
2895
  };
2891
2896
  let keyCtxTimeout;
@@ -3545,25 +3550,35 @@ export default defineComponent({
3545
3550
  * 设置为固定列
3546
3551
  */
3547
3552
  setColumnFixed(fieldOrColumn, fixed) {
3548
- const column = handleFieldOrColumn($xeTable, fieldOrColumn);
3549
- const targetColumn = getRootColumn($xeTable, column);
3550
- const isMaxFixedColumn = computeIsMaxFixedColumn.value;
3553
+ let status = false;
3554
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
3551
3555
  const columnOpts = computeColumnOpts.value;
3552
- if (targetColumn && targetColumn.fixed !== fixed) {
3553
- // 是否超过最大固定列数量
3554
- if (!targetColumn.fixed && isMaxFixedColumn) {
3555
- if (VxeUI.modal) {
3556
- VxeUI.modal.message({
3557
- status: 'error',
3558
- content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
3559
- });
3556
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value;
3557
+ for (let i = 0; i < cols.length; i++) {
3558
+ const item = cols[i];
3559
+ const column = handleFieldOrColumn($xeTable, item);
3560
+ const targetColumn = getRootColumn($xeTable, column);
3561
+ if (targetColumn && targetColumn.fixed !== fixed) {
3562
+ // 是否超过最大固定列数量
3563
+ if (!targetColumn.fixed && isMaxFixedColumn) {
3564
+ if (VxeUI.modal) {
3565
+ VxeUI.modal.message({
3566
+ status: 'error',
3567
+ content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
3568
+ });
3569
+ }
3570
+ return nextTick();
3571
+ }
3572
+ XEUtils.eachTree([targetColumn], (column) => {
3573
+ column.fixed = fixed;
3574
+ });
3575
+ tablePrivateMethods.saveCustomStore('update:fixed');
3576
+ if (!status) {
3577
+ status = true;
3560
3578
  }
3561
- return nextTick();
3562
3579
  }
3563
- XEUtils.eachTree([targetColumn], (column) => {
3564
- column.fixed = fixed;
3565
- });
3566
- tablePrivateMethods.saveCustomStore('update:fixed');
3580
+ }
3581
+ if (status) {
3567
3582
  return tableMethods.refreshColumn();
3568
3583
  }
3569
3584
  return nextTick();
@@ -3572,13 +3587,22 @@ export default defineComponent({
3572
3587
  * 取消指定固定列
3573
3588
  */
3574
3589
  clearColumnFixed(fieldOrColumn) {
3575
- const column = handleFieldOrColumn($xeTable, fieldOrColumn);
3576
- const targetColumn = getRootColumn($xeTable, column);
3577
- if (targetColumn && targetColumn.fixed) {
3578
- XEUtils.eachTree([targetColumn], (column) => {
3579
- column.fixed = null;
3580
- });
3581
- tablePrivateMethods.saveCustomStore('update:fixed');
3590
+ let status = false;
3591
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
3592
+ cols.forEach(item => {
3593
+ const column = handleFieldOrColumn($xeTable, item);
3594
+ const targetColumn = getRootColumn($xeTable, column);
3595
+ if (targetColumn && targetColumn.fixed) {
3596
+ XEUtils.eachTree([targetColumn], (column) => {
3597
+ column.fixed = null;
3598
+ });
3599
+ tablePrivateMethods.saveCustomStore('update:fixed');
3600
+ if (!status) {
3601
+ status = true;
3602
+ }
3603
+ }
3604
+ });
3605
+ if (status) {
3582
3606
  return tableMethods.refreshColumn();
3583
3607
  }
3584
3608
  return nextTick();
@@ -3587,9 +3611,18 @@ export default defineComponent({
3587
3611
  * 隐藏指定列
3588
3612
  */
3589
3613
  hideColumn(fieldOrColumn) {
3590
- const column = handleFieldOrColumn($xeTable, fieldOrColumn);
3591
- if (column && column.visible) {
3592
- column.visible = false;
3614
+ let status = false;
3615
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
3616
+ cols.forEach(item => {
3617
+ const column = handleFieldOrColumn($xeTable, item);
3618
+ if (column && column.visible) {
3619
+ column.visible = false;
3620
+ if (!status) {
3621
+ status = true;
3622
+ }
3623
+ }
3624
+ });
3625
+ if (status) {
3593
3626
  return tablePrivateMethods.handleCustom();
3594
3627
  }
3595
3628
  return nextTick();
@@ -3598,25 +3631,43 @@ export default defineComponent({
3598
3631
  * 显示指定列
3599
3632
  */
3600
3633
  showColumn(fieldOrColumn) {
3601
- const column = handleFieldOrColumn($xeTable, fieldOrColumn);
3602
- if (column && !column.visible) {
3603
- column.visible = true;
3634
+ let status = false;
3635
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
3636
+ cols.forEach(item => {
3637
+ const column = handleFieldOrColumn($xeTable, item);
3638
+ if (column && !column.visible) {
3639
+ column.visible = true;
3640
+ if (!status) {
3641
+ status = true;
3642
+ }
3643
+ }
3644
+ });
3645
+ if (status) {
3604
3646
  return tablePrivateMethods.handleCustom();
3605
3647
  }
3606
3648
  return nextTick();
3607
3649
  },
3608
3650
  setColumnWidth(fieldOrColumn, width) {
3609
- const column = handleFieldOrColumn($xeTable, fieldOrColumn);
3610
- if (column) {
3611
- const colWidth = XEUtils.toInteger(width);
3612
- let rdWidth = colWidth;
3613
- if (isScale(width)) {
3614
- const tableBody = refTableBody.value;
3615
- const bodyElem = tableBody ? tableBody.$el : null;
3616
- const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
3617
- rdWidth = Math.floor(colWidth * bodyWidth);
3618
- }
3619
- column.resizeWidth = rdWidth;
3651
+ let status = false;
3652
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
3653
+ cols.forEach(item => {
3654
+ const column = handleFieldOrColumn($xeTable, item);
3655
+ if (column) {
3656
+ const colWidth = XEUtils.toInteger(width);
3657
+ let rdWidth = colWidth;
3658
+ if (isScale(width)) {
3659
+ const tableBody = refTableBody.value;
3660
+ const bodyElem = tableBody ? tableBody.$el : null;
3661
+ const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
3662
+ rdWidth = Math.floor(colWidth * bodyWidth);
3663
+ }
3664
+ column.resizeWidth = rdWidth;
3665
+ if (!status) {
3666
+ status = true;
3667
+ }
3668
+ }
3669
+ });
3670
+ if (status) {
3620
3671
  return tableMethods.refreshColumn();
3621
3672
  }
3622
3673
  return nextTick();
@@ -4584,16 +4635,36 @@ export default defineComponent({
4584
4635
  */
4585
4636
  scrollTo(scrollLeft, scrollTop) {
4586
4637
  const tableBody = refTableBody.value;
4638
+ const tableHeader = refTableHeader.value;
4587
4639
  const tableFooter = refTableFooter.value;
4640
+ const leftBody = refTableLeftBody.value;
4588
4641
  const rightBody = refTableRightBody.value;
4589
4642
  const tableBodyElem = tableBody ? tableBody.$el : null;
4643
+ const leftBodyElem = leftBody ? leftBody.$el : null;
4590
4644
  const rightBodyElem = rightBody ? rightBody.$el : null;
4645
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null;
4591
4646
  const tableFooterElem = tableFooter ? tableFooter.$el : null;
4592
4647
  if (XEUtils.isNumber(scrollLeft)) {
4593
- setScrollLeft(tableFooterElem || tableBodyElem, scrollLeft);
4648
+ const xHandleEl = refScrollXHandleElem.value;
4649
+ if (xHandleEl) {
4650
+ setScrollLeft(xHandleEl, scrollLeft);
4651
+ }
4652
+ else {
4653
+ setScrollLeft(tableBodyElem, scrollLeft);
4654
+ setScrollLeft(tableHeaderElem, scrollLeft);
4655
+ setScrollLeft(tableFooterElem, scrollLeft);
4656
+ }
4594
4657
  }
4595
4658
  if (XEUtils.isNumber(scrollTop)) {
4596
- setScrollTop(rightBodyElem || tableBodyElem, scrollTop);
4659
+ const yHandleEl = refScrollYHandleElem.value;
4660
+ if (yHandleEl) {
4661
+ setScrollTop(yHandleEl, scrollTop);
4662
+ }
4663
+ else {
4664
+ setScrollTop(tableBodyElem, scrollTop);
4665
+ setScrollTop(leftBodyElem, scrollTop);
4666
+ setScrollTop(rightBodyElem, scrollTop);
4667
+ }
4597
4668
  }
4598
4669
  if (reactData.scrollXLoad || reactData.scrollYLoad) {
4599
4670
  return new Promise(resolve => {
@@ -6773,13 +6844,80 @@ export default defineComponent({
6773
6844
  triggerScrollXEvent() {
6774
6845
  loadScrollXData();
6775
6846
  },
6776
- handleScrollEvent(evnt, isRollY, isRollX, params) {
6847
+ handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
6777
6848
  const { highlightHoverRow } = props;
6849
+ const { lastScrollLeft, lastScrollTop } = internalData;
6778
6850
  const tableBody = refTableBody.value;
6779
6851
  const bodyElem = tableBody ? tableBody.$el : null;
6780
6852
  const rowOpts = computeRowOpts.value;
6781
6853
  const validTip = refValidTooltip.value;
6782
6854
  const tooltip = refTooltip.value;
6855
+ const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
6856
+ const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
6857
+ const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
6858
+ const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
6859
+ let isTop = false;
6860
+ let isBottom = false;
6861
+ let isLeft = false;
6862
+ let isRight = false;
6863
+ let direction = '';
6864
+ let isTopBoundary = false;
6865
+ let isBottomBoundary = false;
6866
+ let isLeftBoundary = false;
6867
+ let isRightBoundary = false;
6868
+ if (isRollX) {
6869
+ const xThreshold = computeScrollXThreshold.value;
6870
+ isLeft = scrollLeft <= 0;
6871
+ if (!isLeft) {
6872
+ isRight = scrollLeft + bodyWidth >= scrollWidth;
6873
+ }
6874
+ if (scrollLeft > lastScrollLeft) {
6875
+ direction = 'right';
6876
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
6877
+ isRightBoundary = true;
6878
+ }
6879
+ }
6880
+ else {
6881
+ direction = 'left';
6882
+ if (scrollLeft <= xThreshold) {
6883
+ isLeftBoundary = true;
6884
+ }
6885
+ }
6886
+ tablePrivateMethods.checkScrolling();
6887
+ internalData.lastScrollLeft = scrollLeft;
6888
+ reactData.lastScrollTime = Date.now();
6889
+ }
6890
+ else {
6891
+ const yThreshold = computeScrollYThreshold.value;
6892
+ isTop = scrollTop <= 0;
6893
+ if (!isTop) {
6894
+ isBottom = scrollTop + bodyHeight >= scrollHeight;
6895
+ }
6896
+ if (scrollTop > lastScrollTop) {
6897
+ direction = 'bottom';
6898
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
6899
+ isBottomBoundary = true;
6900
+ }
6901
+ }
6902
+ else {
6903
+ direction = 'top';
6904
+ if (scrollTop <= yThreshold) {
6905
+ isTopBoundary = true;
6906
+ }
6907
+ }
6908
+ internalData.lastScrollTop = scrollTop;
6909
+ reactData.lastScrollTime = Date.now();
6910
+ }
6911
+ const evntParams = Object.assign({ scrollTop,
6912
+ scrollLeft,
6913
+ bodyHeight,
6914
+ bodyWidth,
6915
+ scrollHeight,
6916
+ scrollWidth, isX: isRollX, isY: isRollY, isTop,
6917
+ isBottom,
6918
+ isLeft,
6919
+ isRight,
6920
+ direction }, params);
6783
6921
  if (rowOpts.isHover || highlightHoverRow) {
6784
6922
  $xeTable.clearHoverRow();
6785
6923
  }
@@ -6789,17 +6927,9 @@ export default defineComponent({
6789
6927
  if (tooltip && tooltip.reactData.visible) {
6790
6928
  tooltip.close();
6791
6929
  }
6792
- if (isRollX) {
6793
- tablePrivateMethods.checkScrolling();
6930
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
6931
+ dispatchEvent('scroll-boundary', evntParams, evnt);
6794
6932
  }
6795
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
6796
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
6797
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
6798
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
6799
- const evntParams = Object.assign({ bodyHeight,
6800
- bodyWidth,
6801
- scrollHeight,
6802
- scrollWidth, isX: isRollX, isY: isRollY }, params);
6803
6933
  dispatchEvent('scroll', evntParams, evnt);
6804
6934
  },
6805
6935
  /**
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "4.8.8";
3
+ export const version = "4.8.10";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"4.8.8"}`;
3
+ const version = `table v${"4.8.10"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);