vxe-table 4.10.13 → 4.10.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.
@@ -38,7 +38,7 @@ hooks.add('tableEditModule', {
38
38
  }
39
39
  }
40
40
  };
41
- function syncActivedCell() {
41
+ const syncActivedCell = () => {
42
42
  const { editStore, tableColumn } = reactData;
43
43
  const editOpts = computeEditOpts.value;
44
44
  const { actived } = editStore;
@@ -51,8 +51,8 @@ hooks.add('tableEditModule', {
51
51
  setEditColumnModel(row, column);
52
52
  }
53
53
  }
54
- }
55
- function insertTreeRow(newRecords, isAppend) {
54
+ };
55
+ const insertTreeRow = (newRecords, isAppend) => {
56
56
  const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData;
57
57
  const treeOpts = computeTreeOpts.value;
58
58
  const { rowField, parentField, mapChildrenField } = treeOpts;
@@ -93,7 +93,7 @@ hooks.add('tableEditModule', {
93
93
  fullAllDataRowIdData[rowid] = rest;
94
94
  }
95
95
  });
96
- }
96
+ };
97
97
  const handleInsertRowAt = (records, targetRow, isInsertNextRow) => {
98
98
  const { treeConfig } = props;
99
99
  const { mergeList, editStore } = reactData;
@@ -325,6 +325,132 @@ hooks.add('tableEditModule', {
325
325
  }
326
326
  });
327
327
  };
328
+ const handleEditActive = (params, evnt, isFocus) => {
329
+ const { editConfig, mouseConfig } = props;
330
+ const { editStore, tableColumn } = reactData;
331
+ const editOpts = computeEditOpts.value;
332
+ const { mode } = editOpts;
333
+ const { actived, focused } = editStore;
334
+ const { row, column } = params;
335
+ const { editRender } = column;
336
+ const cell = (params.cell || $xeTable.getCellElement(row, column));
337
+ const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
338
+ params.cell = cell;
339
+ if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
340
+ // 激活编辑
341
+ if (!$xeTable.isPendingByRow(row)) {
342
+ if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
343
+ // 判断是否禁用编辑
344
+ let type = 'edit-disabled';
345
+ if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }))) {
346
+ if (mouseConfig) {
347
+ $xeTable.clearSelected();
348
+ if ($xeTable.clearCellAreas) {
349
+ $xeTable.clearCellAreas();
350
+ $xeTable.clearCopyCellArea();
351
+ }
352
+ }
353
+ $xeTable.closeTooltip();
354
+ if (actived.column) {
355
+ handleClearEdit(evnt);
356
+ }
357
+ type = 'edit-activated';
358
+ column.renderHeight = cell.offsetHeight;
359
+ actived.args = params;
360
+ actived.row = row;
361
+ actived.column = column;
362
+ if (mode === 'row') {
363
+ tableColumn.forEach((column) => getEditColumnModel(row, column));
364
+ }
365
+ else {
366
+ getEditColumnModel(row, column);
367
+ }
368
+ const afterEditMethod = editOpts.afterEditMethod;
369
+ nextTick(() => {
370
+ if (isFocus) {
371
+ $xeTable.handleFocus(params, evnt);
372
+ }
373
+ if (afterEditMethod) {
374
+ afterEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }));
375
+ }
376
+ });
377
+ }
378
+ $xeTable.dispatchEvent(type, {
379
+ row,
380
+ rowIndex: $xeTable.getRowIndex(row),
381
+ $rowIndex: $xeTable.getVMRowIndex(row),
382
+ column,
383
+ columnIndex: $xeTable.getColumnIndex(column),
384
+ $columnIndex: $xeTable.getVMColumnIndex(column)
385
+ }, evnt);
386
+ // v4已废弃
387
+ if (type === 'edit-activated') {
388
+ $xeTable.dispatchEvent('edit-actived', {
389
+ row,
390
+ rowIndex: $xeTable.getRowIndex(row),
391
+ $rowIndex: $xeTable.getVMRowIndex(row),
392
+ column,
393
+ columnIndex: $xeTable.getColumnIndex(column),
394
+ $columnIndex: $xeTable.getVMColumnIndex(column)
395
+ }, evnt);
396
+ }
397
+ }
398
+ else {
399
+ const { column: oldColumn } = actived;
400
+ if (mouseConfig) {
401
+ $xeTable.clearSelected();
402
+ if ($xeTable.clearCellAreas) {
403
+ $xeTable.clearCellAreas();
404
+ $xeTable.clearCopyCellArea();
405
+ }
406
+ }
407
+ if (oldColumn !== column) {
408
+ const { model: oldModel } = oldColumn;
409
+ if (oldModel.update) {
410
+ setCellValue(row, oldColumn, oldModel.value);
411
+ }
412
+ if ($xeTable.clearValidate) {
413
+ $xeTable.clearValidate(row, column);
414
+ }
415
+ }
416
+ column.renderHeight = cell.offsetHeight;
417
+ actived.args = params;
418
+ actived.column = column;
419
+ if (isFocus) {
420
+ setTimeout(() => {
421
+ $xeTable.handleFocus(params, evnt);
422
+ });
423
+ }
424
+ }
425
+ focused.column = null;
426
+ focused.row = null;
427
+ $xeTable.focus();
428
+ }
429
+ }
430
+ return nextTick();
431
+ };
432
+ const handleEditCell = (row, fieldOrColumn, isPos) => {
433
+ const { editConfig } = props;
434
+ const column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
435
+ if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender)) {
436
+ return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
437
+ const cell = $xeTable.getCellElement(row, column);
438
+ if (cell) {
439
+ handleEditActive({
440
+ row,
441
+ rowIndex: $xeTable.getRowIndex(row),
442
+ column,
443
+ columnIndex: $xeTable.getColumnIndex(column),
444
+ cell,
445
+ $table: $xeTable
446
+ }, null, false);
447
+ internalData._lastCallTime = Date.now();
448
+ }
449
+ return nextTick();
450
+ });
451
+ }
452
+ return nextTick();
453
+ };
328
454
  editMethods = {
329
455
  /**
330
456
  * 往表格中插入临时数据
@@ -658,7 +784,7 @@ hooks.add('tableEditModule', {
658
784
  if (fieldOrColumn) {
659
785
  column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
660
786
  }
661
- return $xeTable.setEditCell(row, column);
787
+ return handleEditCell(row, column, false);
662
788
  },
663
789
  setActiveCell(row, fieldOrColumn) {
664
790
  if (process.env.NODE_ENV === 'development') {
@@ -671,26 +797,7 @@ hooks.add('tableEditModule', {
671
797
  * 激活单元格编辑
672
798
  */
673
799
  setEditCell(row, fieldOrColumn) {
674
- const { editConfig } = props;
675
- const column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
676
- if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender)) {
677
- return $xeTable.scrollToRow(row, column).then(() => {
678
- const cell = $xeTable.getCellElement(row, column);
679
- if (cell) {
680
- editPrivateMethods.handleEdit({
681
- row,
682
- rowIndex: $xeTable.getRowIndex(row),
683
- column,
684
- columnIndex: $xeTable.getColumnIndex(column),
685
- cell,
686
- $table: $xeTable
687
- });
688
- internalData._lastCallTime = Date.now();
689
- }
690
- return nextTick();
691
- });
692
- }
693
- return nextTick();
800
+ return handleEditCell(row, fieldOrColumn, true);
694
801
  },
695
802
  /**
696
803
  * 只对 trigger=dblclick 有效,选中单元格
@@ -721,104 +828,7 @@ hooks.add('tableEditModule', {
721
828
  * 处理激活编辑
722
829
  */
723
830
  handleEdit(params, evnt) {
724
- const { editConfig, mouseConfig } = props;
725
- const { editStore, tableColumn } = reactData;
726
- const editOpts = computeEditOpts.value;
727
- const { mode } = editOpts;
728
- const { actived, focused } = editStore;
729
- const { row, column } = params;
730
- const { editRender } = column;
731
- const cell = (params.cell || $xeTable.getCellElement(row, column));
732
- const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
733
- params.cell = cell;
734
- if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
735
- // 激活编辑
736
- if (!$xeTable.isPendingByRow(row)) {
737
- if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
738
- // 判断是否禁用编辑
739
- let type = 'edit-disabled';
740
- if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }))) {
741
- if (mouseConfig) {
742
- editMethods.clearSelected();
743
- if ($xeTable.clearCellAreas) {
744
- $xeTable.clearCellAreas();
745
- $xeTable.clearCopyCellArea();
746
- }
747
- }
748
- $xeTable.closeTooltip();
749
- if (actived.column) {
750
- handleClearEdit(evnt);
751
- }
752
- type = 'edit-activated';
753
- column.renderHeight = cell.offsetHeight;
754
- actived.args = params;
755
- actived.row = row;
756
- actived.column = column;
757
- if (mode === 'row') {
758
- tableColumn.forEach((column) => getEditColumnModel(row, column));
759
- }
760
- else {
761
- getEditColumnModel(row, column);
762
- }
763
- const afterEditMethod = editOpts.afterEditMethod;
764
- nextTick(() => {
765
- editPrivateMethods.handleFocus(params, evnt);
766
- if (afterEditMethod) {
767
- afterEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }));
768
- }
769
- });
770
- }
771
- $xeTable.dispatchEvent(type, {
772
- row,
773
- rowIndex: $xeTable.getRowIndex(row),
774
- $rowIndex: $xeTable.getVMRowIndex(row),
775
- column,
776
- columnIndex: $xeTable.getColumnIndex(column),
777
- $columnIndex: $xeTable.getVMColumnIndex(column)
778
- }, evnt);
779
- // v4已废弃
780
- if (type === 'edit-activated') {
781
- $xeTable.dispatchEvent('edit-actived', {
782
- row,
783
- rowIndex: $xeTable.getRowIndex(row),
784
- $rowIndex: $xeTable.getVMRowIndex(row),
785
- column,
786
- columnIndex: $xeTable.getColumnIndex(column),
787
- $columnIndex: $xeTable.getVMColumnIndex(column)
788
- }, evnt);
789
- }
790
- }
791
- else {
792
- const { column: oldColumn } = actived;
793
- if (mouseConfig) {
794
- editMethods.clearSelected();
795
- if ($xeTable.clearCellAreas) {
796
- $xeTable.clearCellAreas();
797
- $xeTable.clearCopyCellArea();
798
- }
799
- }
800
- if (oldColumn !== column) {
801
- const { model: oldModel } = oldColumn;
802
- if (oldModel.update) {
803
- setCellValue(row, oldColumn, oldModel.value);
804
- }
805
- if ($xeTable.clearValidate) {
806
- $xeTable.clearValidate(row, column);
807
- }
808
- }
809
- column.renderHeight = cell.offsetHeight;
810
- actived.args = params;
811
- actived.column = column;
812
- setTimeout(() => {
813
- editPrivateMethods.handleFocus(params, evnt);
814
- });
815
- }
816
- focused.column = null;
817
- focused.row = null;
818
- $xeTable.focus();
819
- }
820
- }
821
- return nextTick();
831
+ return handleEditActive(params, evnt, true);
822
832
  },
823
833
  /**
824
834
  * @deprecated
@@ -8508,6 +8508,7 @@ export default defineComponent({
8508
8508
  }
8509
8509
  },
8510
8510
  triggerBodyScrollEvent(evnt, fixedType) {
8511
+ const { scrollYLoad, scrollXLoad } = reactData;
8511
8512
  const { elemStore, intoRunScroll, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData;
8512
8513
  const xHandleEl = refScrollXHandleElem.value;
8513
8514
  const yHandleEl = refScrollYHandleElem.value;
@@ -8566,13 +8567,17 @@ export default defineComponent({
8566
8567
  setScrollTop(rightScrollElem, scrollTop);
8567
8568
  }
8568
8569
  setScrollTop(yHandleEl, scrollTop);
8569
- $xeTable.triggerScrollYEvent(evnt);
8570
+ if (scrollYLoad) {
8571
+ $xeTable.triggerScrollYEvent(evnt);
8572
+ }
8570
8573
  }
8571
8574
  if (isRollX) {
8572
8575
  setScrollLeft(xHandleEl, scrollLeft);
8573
8576
  setScrollLeft(headerScrollElem, scrollLeft);
8574
8577
  setScrollLeft(footerScrollElem, scrollLeft);
8575
- $xeTable.triggerScrollXEvent(evnt);
8578
+ if (scrollXLoad) {
8579
+ $xeTable.triggerScrollXEvent(evnt);
8580
+ }
8576
8581
  }
8577
8582
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8578
8583
  type: 'body',
@@ -8580,6 +8585,7 @@ export default defineComponent({
8580
8585
  });
8581
8586
  },
8582
8587
  triggerHeaderScrollEvent(evnt, fixedType) {
8588
+ const { scrollXLoad } = reactData;
8583
8589
  const { elemStore, intoRunScroll, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData;
8584
8590
  const yHandleEl = refScrollYHandleElem.value;
8585
8591
  const xHandleEl = refScrollXHandleElem.value;
@@ -8609,13 +8615,16 @@ export default defineComponent({
8609
8615
  setScrollLeft(xHandleEl, scrollLeft);
8610
8616
  setScrollLeft(footerScrollElem, scrollLeft);
8611
8617
  setScrollLeft(bodyScrollElem, scrollLeft);
8612
- $xeTable.triggerScrollXEvent(evnt);
8618
+ if (scrollXLoad) {
8619
+ $xeTable.triggerScrollXEvent(evnt);
8620
+ }
8613
8621
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8614
8622
  type: 'header',
8615
8623
  fixed: fixedType
8616
8624
  });
8617
8625
  },
8618
8626
  triggerFooterScrollEvent(evnt, fixedType) {
8627
+ const { scrollXLoad } = reactData;
8619
8628
  const { elemStore, intoRunScroll, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData;
8620
8629
  const yHandleEl = refScrollYHandleElem.value;
8621
8630
  const xHandleEl = refScrollXHandleElem.value;
@@ -8645,7 +8654,9 @@ export default defineComponent({
8645
8654
  setScrollLeft(xHandleEl, scrollLeft);
8646
8655
  setScrollLeft(headerScrollElem, scrollLeft);
8647
8656
  setScrollLeft(bodyScrollElem, scrollLeft);
8648
- $xeTable.triggerScrollXEvent(evnt);
8657
+ if (scrollXLoad) {
8658
+ $xeTable.triggerScrollXEvent(evnt);
8659
+ }
8649
8660
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8650
8661
  type: 'footer',
8651
8662
  fixed: fixedType
@@ -8657,6 +8668,7 @@ export default defineComponent({
8657
8668
  return;
8658
8669
  }
8659
8670
  const { highlightHoverRow } = tableProps;
8671
+ const { scrollYLoad } = reactData;
8660
8672
  const { elemStore, lastScrollTop, lastScrollLeft } = internalData;
8661
8673
  const rowOpts = computeRowOpts.value;
8662
8674
  const xHandleEl = refScrollXHandleElem.value;
@@ -8699,7 +8711,9 @@ export default defineComponent({
8699
8711
  setScrollTop(bodyScrollElem, currTopNum);
8700
8712
  setScrollTop(leftScrollElem, currTopNum);
8701
8713
  setScrollTop(rightScrollElem, currTopNum);
8702
- $xeTable.triggerScrollYEvent(evnt);
8714
+ if (scrollYLoad) {
8715
+ $xeTable.triggerScrollYEvent(evnt);
8716
+ }
8703
8717
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, currTopNum, scrollLeft, {
8704
8718
  type: 'table',
8705
8719
  fixed: ''
@@ -8718,6 +8732,7 @@ export default defineComponent({
8718
8732
  }
8719
8733
  },
8720
8734
  triggerVirtualScrollXEvent(evnt) {
8735
+ const { scrollXLoad } = reactData;
8721
8736
  const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
8722
8737
  if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8723
8738
  return;
@@ -8742,13 +8757,16 @@ export default defineComponent({
8742
8757
  setScrollLeft(bodyScrollElem, scrollLeft);
8743
8758
  setScrollLeft(headerScrollElem, scrollLeft);
8744
8759
  setScrollLeft(footerScrollElem, scrollLeft);
8745
- $xeTable.triggerScrollXEvent(evnt);
8760
+ if (scrollXLoad) {
8761
+ $xeTable.triggerScrollXEvent(evnt);
8762
+ }
8746
8763
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8747
8764
  type: 'table',
8748
8765
  fixed: ''
8749
8766
  });
8750
8767
  },
8751
8768
  triggerVirtualScrollYEvent(evnt) {
8769
+ const { scrollYLoad } = reactData;
8752
8770
  const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
8753
8771
  if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8754
8772
  return;
@@ -8773,7 +8791,9 @@ export default defineComponent({
8773
8791
  setScrollTop(bodyScrollElem, scrollTop);
8774
8792
  setScrollTop(leftScrollElem, scrollTop);
8775
8793
  setScrollTop(rightScrollElem, scrollTop);
8776
- $xeTable.triggerScrollYEvent(evnt);
8794
+ if (scrollYLoad) {
8795
+ $xeTable.triggerScrollYEvent(evnt);
8796
+ }
8777
8797
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8778
8798
  type: 'table',
8779
8799
  fixed: ''
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.10.13";
3
+ export const version = "4.10.14";
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.10.13"}`;
3
+ const version = `table v${"4.10.14"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);