vxe-table 3.12.14 → 3.12.16
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.
- package/es/style.css +1 -1
- package/es/table/module/edit/mixin.js +250 -168
- package/es/table/module/export/mixin.js +3 -2
- package/es/table/module/validator/mixin.js +6 -1
- package/es/table/src/body.js +1 -0
- package/es/table/src/methods.js +166 -100
- package/es/table/src/table.js +0 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +540 -375
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +305 -225
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/mixin.js +3 -2
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +8 -0
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/body.js +1 -0
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +219 -143
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +0 -1
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/table/module/edit/mixin.ts +273 -168
- package/packages/table/module/export/mixin.ts +3 -2
- package/packages/table/module/validator/mixin.ts +6 -1
- package/packages/table/src/body.ts +1 -0
- package/packages/table/src/methods.ts +172 -96
- package/packages/table/src/table.ts +0 -1
- /package/es/{iconfont.1739181382716.ttf → iconfont.1739333092714.ttf} +0 -0
- /package/es/{iconfont.1739181382716.woff → iconfont.1739333092714.woff} +0 -0
- /package/es/{iconfont.1739181382716.woff2 → iconfont.1739333092714.woff2} +0 -0
- /package/lib/{iconfont.1739181382716.ttf → iconfont.1739333092714.ttf} +0 -0
- /package/lib/{iconfont.1739181382716.woff → iconfont.1739333092714.woff} +0 -0
- /package/lib/{iconfont.1739181382716.woff2 → iconfont.1739333092714.woff2} +0 -0
|
@@ -16,6 +16,58 @@ const {
|
|
|
16
16
|
renderer,
|
|
17
17
|
getI18n
|
|
18
18
|
} = _ui.VxeUI;
|
|
19
|
+
function getEditColumnModel(row, column) {
|
|
20
|
+
const {
|
|
21
|
+
model,
|
|
22
|
+
editRender
|
|
23
|
+
} = column;
|
|
24
|
+
if (editRender) {
|
|
25
|
+
model.value = (0, _util.getCellValue)(row, column);
|
|
26
|
+
model.update = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function setEditColumnModel(row, column) {
|
|
30
|
+
const {
|
|
31
|
+
model,
|
|
32
|
+
editRender
|
|
33
|
+
} = column;
|
|
34
|
+
if (editRender && model.update) {
|
|
35
|
+
(0, _util.setCellValue)(row, column, model.value);
|
|
36
|
+
model.update = false;
|
|
37
|
+
model.value = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function removeCellSelectedClass($xeTable) {
|
|
41
|
+
const el = $xeTable.$refs.refElem;
|
|
42
|
+
if (el) {
|
|
43
|
+
const cell = el.querySelector('.col--selected');
|
|
44
|
+
if (cell) {
|
|
45
|
+
(0, _dom.removeClass)(cell, 'col--selected');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function syncActivedCell($xeTable) {
|
|
50
|
+
const reactData = $xeTable;
|
|
51
|
+
const {
|
|
52
|
+
editStore,
|
|
53
|
+
tableColumn
|
|
54
|
+
} = reactData;
|
|
55
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
56
|
+
const {
|
|
57
|
+
actived
|
|
58
|
+
} = editStore;
|
|
59
|
+
const {
|
|
60
|
+
row,
|
|
61
|
+
column
|
|
62
|
+
} = actived;
|
|
63
|
+
if (row || column) {
|
|
64
|
+
if (editOpts.mode === 'row') {
|
|
65
|
+
tableColumn.forEach(column => setEditColumnModel(row, column));
|
|
66
|
+
} else {
|
|
67
|
+
setEditColumnModel(row, column);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
19
71
|
function insertTreeRow(_vm, newRecords, isAppend) {
|
|
20
72
|
const {
|
|
21
73
|
tableFullTreeData,
|
|
@@ -370,6 +422,214 @@ function handleInsertChildRowAt($xeTable, records, parentRow, targetRow, isInser
|
|
|
370
422
|
rows: []
|
|
371
423
|
});
|
|
372
424
|
}
|
|
425
|
+
function handleClearEdit($xeTable, evnt, targetRow) {
|
|
426
|
+
const props = $xeTable;
|
|
427
|
+
const reactData = $xeTable;
|
|
428
|
+
const {
|
|
429
|
+
mouseConfig
|
|
430
|
+
} = props;
|
|
431
|
+
const {
|
|
432
|
+
editStore
|
|
433
|
+
} = reactData;
|
|
434
|
+
const {
|
|
435
|
+
actived,
|
|
436
|
+
focused
|
|
437
|
+
} = editStore;
|
|
438
|
+
const {
|
|
439
|
+
row,
|
|
440
|
+
column
|
|
441
|
+
} = actived;
|
|
442
|
+
const validOpts = $xeTable.computeValidOpts;
|
|
443
|
+
const mouseOpts = $xeTable.computeMouseOpts;
|
|
444
|
+
if (row || column) {
|
|
445
|
+
if (targetRow && (0, _util.getRowid)($xeTable, targetRow) !== (0, _util.getRowid)($xeTable, row)) {
|
|
446
|
+
return $xeTable.$nextTick();
|
|
447
|
+
}
|
|
448
|
+
syncActivedCell($xeTable);
|
|
449
|
+
actived.args = null;
|
|
450
|
+
actived.row = null;
|
|
451
|
+
actived.column = null;
|
|
452
|
+
$xeTable.updateFooter();
|
|
453
|
+
$xeTable.dispatchEvent('edit-closed', {
|
|
454
|
+
row,
|
|
455
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
456
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
457
|
+
column,
|
|
458
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
459
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
460
|
+
}, evnt || null);
|
|
461
|
+
}
|
|
462
|
+
focused.row = null;
|
|
463
|
+
focused.column = null;
|
|
464
|
+
if (validOpts.autoClear) {
|
|
465
|
+
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
466
|
+
if ($xeTable.clearValidate) {
|
|
467
|
+
return $xeTable.clearValidate();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return $xeTable.$nextTick().then(() => {
|
|
472
|
+
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
|
|
473
|
+
return $xeTable.handleRecalculateCellAreas();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function handleEditActive($xeTable, params, evnt, isFocus) {
|
|
478
|
+
const props = $xeTable;
|
|
479
|
+
const reactData = $xeTable;
|
|
480
|
+
const {
|
|
481
|
+
editConfig,
|
|
482
|
+
mouseConfig
|
|
483
|
+
} = props;
|
|
484
|
+
const {
|
|
485
|
+
editStore,
|
|
486
|
+
tableColumn
|
|
487
|
+
} = reactData;
|
|
488
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
489
|
+
const {
|
|
490
|
+
mode
|
|
491
|
+
} = editOpts;
|
|
492
|
+
const {
|
|
493
|
+
actived,
|
|
494
|
+
focused
|
|
495
|
+
} = editStore;
|
|
496
|
+
const {
|
|
497
|
+
row,
|
|
498
|
+
column
|
|
499
|
+
} = params;
|
|
500
|
+
const {
|
|
501
|
+
editRender
|
|
502
|
+
} = column;
|
|
503
|
+
const cell = params.cell || $xeTable.getCellElement(row, column);
|
|
504
|
+
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
505
|
+
params.cell = cell;
|
|
506
|
+
if (cell && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(editRender)) {
|
|
507
|
+
// 激活编辑
|
|
508
|
+
if (!$xeTable.isPendingByRow(row)) {
|
|
509
|
+
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
510
|
+
// 判断是否禁用编辑
|
|
511
|
+
let type = 'edit-disabled';
|
|
512
|
+
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), {
|
|
513
|
+
$table: $xeTable,
|
|
514
|
+
$grid: $xeTable.xegrid
|
|
515
|
+
}))) {
|
|
516
|
+
if (mouseConfig) {
|
|
517
|
+
$xeTable.clearSelected();
|
|
518
|
+
if ($xeTable.clearCellAreas) {
|
|
519
|
+
$xeTable.clearCellAreas();
|
|
520
|
+
$xeTable.clearCopyCellArea();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
$xeTable.closeTooltip();
|
|
524
|
+
if (actived.column) {
|
|
525
|
+
handleClearEdit($xeTable, evnt);
|
|
526
|
+
}
|
|
527
|
+
type = 'edit-activated';
|
|
528
|
+
column.renderHeight = cell.offsetHeight;
|
|
529
|
+
actived.args = params;
|
|
530
|
+
actived.row = row;
|
|
531
|
+
actived.column = column;
|
|
532
|
+
if (mode === 'row') {
|
|
533
|
+
tableColumn.forEach(column => getEditColumnModel(row, column));
|
|
534
|
+
} else {
|
|
535
|
+
getEditColumnModel(row, column);
|
|
536
|
+
}
|
|
537
|
+
const afterEditMethod = editOpts.afterEditMethod;
|
|
538
|
+
$xeTable.$nextTick(() => {
|
|
539
|
+
if (isFocus) {
|
|
540
|
+
$xeTable.handleFocus(params, evnt);
|
|
541
|
+
}
|
|
542
|
+
if (afterEditMethod) {
|
|
543
|
+
afterEditMethod(Object.assign(Object.assign({}, params), {
|
|
544
|
+
$table: $xeTable,
|
|
545
|
+
$grid: $xeTable.xegrid
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
$xeTable.dispatchEvent(type, {
|
|
551
|
+
row,
|
|
552
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
553
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
554
|
+
column,
|
|
555
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
556
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
557
|
+
}, evnt);
|
|
558
|
+
// v4已废弃
|
|
559
|
+
if (type === 'edit-activated') {
|
|
560
|
+
$xeTable.dispatchEvent('edit-actived', {
|
|
561
|
+
row,
|
|
562
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
563
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
564
|
+
column,
|
|
565
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
566
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
567
|
+
}, evnt);
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
const {
|
|
571
|
+
column: oldColumn
|
|
572
|
+
} = actived;
|
|
573
|
+
if (mouseConfig) {
|
|
574
|
+
$xeTable.clearSelected();
|
|
575
|
+
if ($xeTable.clearCellAreas) {
|
|
576
|
+
$xeTable.clearCellAreas();
|
|
577
|
+
$xeTable.clearCopyCellArea();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (oldColumn !== column) {
|
|
581
|
+
const {
|
|
582
|
+
model: oldModel
|
|
583
|
+
} = oldColumn;
|
|
584
|
+
if (oldModel.update) {
|
|
585
|
+
(0, _util.setCellValue)(row, oldColumn, oldModel.value);
|
|
586
|
+
}
|
|
587
|
+
if ($xeTable.clearValidate) {
|
|
588
|
+
$xeTable.clearValidate(row, column);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
column.renderHeight = cell.offsetHeight;
|
|
592
|
+
actived.args = params;
|
|
593
|
+
actived.column = column;
|
|
594
|
+
if (isFocus) {
|
|
595
|
+
setTimeout(() => {
|
|
596
|
+
$xeTable.handleFocus(params, evnt);
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
focused.column = null;
|
|
601
|
+
focused.row = null;
|
|
602
|
+
$xeTable.focus();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return $xeTable.$nextTick();
|
|
606
|
+
}
|
|
607
|
+
function handleEditCell($xeTable, row, fieldOrColumn, isPos) {
|
|
608
|
+
const props = $xeTable;
|
|
609
|
+
const internalData = $xeTable;
|
|
610
|
+
const {
|
|
611
|
+
editConfig
|
|
612
|
+
} = props;
|
|
613
|
+
const column = _xeUtils.default.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
614
|
+
if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender)) {
|
|
615
|
+
return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
|
|
616
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
617
|
+
if (cell) {
|
|
618
|
+
handleEditActive($xeTable, {
|
|
619
|
+
row,
|
|
620
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
621
|
+
column,
|
|
622
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
623
|
+
cell,
|
|
624
|
+
$table: $xeTable
|
|
625
|
+
}, null, false);
|
|
626
|
+
internalData._lastCallTime = Date.now();
|
|
627
|
+
}
|
|
628
|
+
return $xeTable.$nextTick();
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
return $xeTable.$nextTick();
|
|
632
|
+
}
|
|
373
633
|
var _default = exports.default = {
|
|
374
634
|
methods: {
|
|
375
635
|
/**
|
|
@@ -437,7 +697,7 @@ var _default = exports.default = {
|
|
|
437
697
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
438
698
|
const {
|
|
439
699
|
actived,
|
|
440
|
-
|
|
700
|
+
removeMaps,
|
|
441
701
|
insertMaps
|
|
442
702
|
} = editStore;
|
|
443
703
|
const {
|
|
@@ -452,7 +712,8 @@ var _default = exports.default = {
|
|
|
452
712
|
// 如果是新增,则保存记录
|
|
453
713
|
rows.forEach(row => {
|
|
454
714
|
if (!$xeTable.isInsertByRow(row)) {
|
|
455
|
-
|
|
715
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
716
|
+
removeMaps[rowid] = row;
|
|
456
717
|
}
|
|
457
718
|
});
|
|
458
719
|
// 如果绑定了多选属性,则更新状态
|
|
@@ -627,7 +888,19 @@ var _default = exports.default = {
|
|
|
627
888
|
* 获取已删除的数据
|
|
628
889
|
*/
|
|
629
890
|
_getRemoveRecords() {
|
|
630
|
-
|
|
891
|
+
const $xeTable = this;
|
|
892
|
+
const reactData = $xeTable;
|
|
893
|
+
const {
|
|
894
|
+
editStore
|
|
895
|
+
} = reactData;
|
|
896
|
+
const {
|
|
897
|
+
removeMaps
|
|
898
|
+
} = editStore;
|
|
899
|
+
const removeRecords = [];
|
|
900
|
+
_xeUtils.default.each(removeMaps, row => {
|
|
901
|
+
removeRecords.push(row);
|
|
902
|
+
});
|
|
903
|
+
return removeRecords;
|
|
631
904
|
},
|
|
632
905
|
/**
|
|
633
906
|
* 获取更新数据
|
|
@@ -635,6 +908,7 @@ var _default = exports.default = {
|
|
|
635
908
|
* 如果是树表格,子节点更改状态不会影响父节点的更新状态
|
|
636
909
|
*/
|
|
637
910
|
_getUpdateRecords() {
|
|
911
|
+
const $xeTable = this;
|
|
638
912
|
const {
|
|
639
913
|
keepSource,
|
|
640
914
|
tableFullData,
|
|
@@ -652,7 +926,7 @@ var _default = exports.default = {
|
|
|
652
926
|
column
|
|
653
927
|
} = actived;
|
|
654
928
|
if (row || column) {
|
|
655
|
-
|
|
929
|
+
syncActivedCell($xeTable);
|
|
656
930
|
}
|
|
657
931
|
if (treeConfig) {
|
|
658
932
|
return _xeUtils.default.filterTree(tableFullData, row => isUpdateByRow(row), treeOpts);
|
|
@@ -665,105 +939,8 @@ var _default = exports.default = {
|
|
|
665
939
|
* 处理激活编辑
|
|
666
940
|
*/
|
|
667
941
|
handleEdit(params, evnt) {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
editOpts,
|
|
671
|
-
tableColumn,
|
|
672
|
-
editConfig,
|
|
673
|
-
mouseConfig
|
|
674
|
-
} = this;
|
|
675
|
-
const {
|
|
676
|
-
mode
|
|
677
|
-
} = editOpts;
|
|
678
|
-
const {
|
|
679
|
-
actived,
|
|
680
|
-
focused
|
|
681
|
-
} = editStore;
|
|
682
|
-
const {
|
|
683
|
-
row,
|
|
684
|
-
column
|
|
685
|
-
} = params;
|
|
686
|
-
const {
|
|
687
|
-
editRender
|
|
688
|
-
} = column;
|
|
689
|
-
const cell = params.cell = params.cell || this.getCellElement(row, column);
|
|
690
|
-
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
691
|
-
if (cell && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(editRender)) {
|
|
692
|
-
// 激活编辑
|
|
693
|
-
if (!this.hasPendingByRow(row)) {
|
|
694
|
-
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
695
|
-
// 判断是否禁用编辑
|
|
696
|
-
let type = 'edit-disabled';
|
|
697
|
-
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), {
|
|
698
|
-
$table: this,
|
|
699
|
-
$grid: this.$xegrid
|
|
700
|
-
}))) {
|
|
701
|
-
if (mouseConfig) {
|
|
702
|
-
this.clearSelected(evnt);
|
|
703
|
-
this.clearCellAreas(evnt);
|
|
704
|
-
this.clearCopyCellArea(evnt);
|
|
705
|
-
}
|
|
706
|
-
this.closeTooltip();
|
|
707
|
-
if (actived.column) {
|
|
708
|
-
this.handleClearEdit(evnt);
|
|
709
|
-
}
|
|
710
|
-
type = 'edit-activated';
|
|
711
|
-
column.renderHeight = cell.offsetHeight;
|
|
712
|
-
actived.args = params;
|
|
713
|
-
actived.row = row;
|
|
714
|
-
actived.column = column;
|
|
715
|
-
if (mode === 'row') {
|
|
716
|
-
tableColumn.forEach(column => this._getColumnModel(row, column));
|
|
717
|
-
} else {
|
|
718
|
-
this._getColumnModel(row, column);
|
|
719
|
-
}
|
|
720
|
-
const afterEditMethod = editOpts.afterEditMethod;
|
|
721
|
-
this.$nextTick(() => {
|
|
722
|
-
this.handleFocus(params, evnt);
|
|
723
|
-
if (afterEditMethod) {
|
|
724
|
-
afterEditMethod(Object.assign(Object.assign({}, params), {
|
|
725
|
-
$table: this,
|
|
726
|
-
$grid: this.$xegrid
|
|
727
|
-
}));
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
this.emitEvent(type, params, evnt);
|
|
732
|
-
// v4已废弃
|
|
733
|
-
if (type === 'edit-activated') {
|
|
734
|
-
this.emitEvent('edit-actived', params, evnt);
|
|
735
|
-
}
|
|
736
|
-
} else {
|
|
737
|
-
const {
|
|
738
|
-
column: oldColumn
|
|
739
|
-
} = actived;
|
|
740
|
-
if (mouseConfig) {
|
|
741
|
-
this.clearSelected(evnt);
|
|
742
|
-
this.clearCellAreas(evnt);
|
|
743
|
-
this.clearCopyCellArea(evnt);
|
|
744
|
-
}
|
|
745
|
-
if (oldColumn !== column) {
|
|
746
|
-
const {
|
|
747
|
-
model: oldModel
|
|
748
|
-
} = oldColumn;
|
|
749
|
-
if (oldModel.update) {
|
|
750
|
-
(0, _util.setCellValue)(row, oldColumn, oldModel.value);
|
|
751
|
-
}
|
|
752
|
-
this.clearValidate();
|
|
753
|
-
}
|
|
754
|
-
column.renderHeight = cell.offsetHeight;
|
|
755
|
-
actived.args = params;
|
|
756
|
-
actived.column = column;
|
|
757
|
-
setTimeout(() => {
|
|
758
|
-
this.handleFocus(params, evnt);
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
focused.column = null;
|
|
762
|
-
focused.row = null;
|
|
763
|
-
this.focus();
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
return this.$nextTick();
|
|
942
|
+
const $xeTable = this;
|
|
943
|
+
return handleEditActive($xeTable, params, evnt, true);
|
|
767
944
|
},
|
|
768
945
|
/**
|
|
769
946
|
* @deprecated
|
|
@@ -772,46 +949,14 @@ var _default = exports.default = {
|
|
|
772
949
|
return this.handleEdit(params, evnt);
|
|
773
950
|
},
|
|
774
951
|
_getColumnModel(row, column) {
|
|
775
|
-
|
|
776
|
-
model,
|
|
777
|
-
editRender
|
|
778
|
-
} = column;
|
|
779
|
-
if (editRender) {
|
|
780
|
-
model.value = (0, _util.getCellValue)(row, column);
|
|
781
|
-
model.update = false;
|
|
782
|
-
}
|
|
952
|
+
getEditColumnModel(row, column);
|
|
783
953
|
},
|
|
784
954
|
_setColumnModel(row, column) {
|
|
785
|
-
|
|
786
|
-
model,
|
|
787
|
-
editRender
|
|
788
|
-
} = column;
|
|
789
|
-
if (editRender && model.update) {
|
|
790
|
-
(0, _util.setCellValue)(row, column, model.value);
|
|
791
|
-
model.update = false;
|
|
792
|
-
model.value = null;
|
|
793
|
-
}
|
|
955
|
+
setEditColumnModel(row, column);
|
|
794
956
|
},
|
|
795
957
|
_syncActivedCell() {
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
editStore,
|
|
799
|
-
editOpts
|
|
800
|
-
} = this;
|
|
801
|
-
const {
|
|
802
|
-
actived
|
|
803
|
-
} = editStore;
|
|
804
|
-
const {
|
|
805
|
-
row,
|
|
806
|
-
column
|
|
807
|
-
} = actived;
|
|
808
|
-
if (row || column) {
|
|
809
|
-
if (editOpts.mode === 'row') {
|
|
810
|
-
tableColumn.forEach(column => this._setColumnModel(row, column));
|
|
811
|
-
} else {
|
|
812
|
-
this._setColumnModel(row, column);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
958
|
+
const $xeTable = this;
|
|
959
|
+
syncActivedCell($xeTable);
|
|
815
960
|
},
|
|
816
961
|
_clearActived(row) {
|
|
817
962
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -824,63 +969,15 @@ var _default = exports.default = {
|
|
|
824
969
|
* 清除激活的编辑
|
|
825
970
|
*/
|
|
826
971
|
_clearEdit(row) {
|
|
827
|
-
|
|
972
|
+
const $xeTable = this;
|
|
973
|
+
return handleClearEdit($xeTable, null, row);
|
|
828
974
|
},
|
|
829
975
|
/**
|
|
830
976
|
* 取消编辑
|
|
831
977
|
*/
|
|
832
978
|
handleClearEdit(evnt, targetRow) {
|
|
833
979
|
const $xeTable = this;
|
|
834
|
-
|
|
835
|
-
const reactData = $xeTable;
|
|
836
|
-
const {
|
|
837
|
-
mouseConfig
|
|
838
|
-
} = props;
|
|
839
|
-
const {
|
|
840
|
-
editStore
|
|
841
|
-
} = reactData;
|
|
842
|
-
const {
|
|
843
|
-
actived,
|
|
844
|
-
focused
|
|
845
|
-
} = editStore;
|
|
846
|
-
const {
|
|
847
|
-
row,
|
|
848
|
-
column
|
|
849
|
-
} = actived;
|
|
850
|
-
const validOpts = $xeTable.validOpts;
|
|
851
|
-
const mouseOpts = $xeTable.computeMouseOpts;
|
|
852
|
-
if (row || column) {
|
|
853
|
-
if (targetRow && (0, _util.getRowid)($xeTable, targetRow) !== (0, _util.getRowid)($xeTable, row)) {
|
|
854
|
-
return $xeTable.$nextTick();
|
|
855
|
-
}
|
|
856
|
-
$xeTable._syncActivedCell();
|
|
857
|
-
actived.args = null;
|
|
858
|
-
actived.row = null;
|
|
859
|
-
actived.column = null;
|
|
860
|
-
$xeTable.updateFooter();
|
|
861
|
-
$xeTable.emitEvent('edit-closed', {
|
|
862
|
-
row,
|
|
863
|
-
rowIndex: $xeTable.getRowIndex(row),
|
|
864
|
-
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
865
|
-
column,
|
|
866
|
-
columnIndex: $xeTable.getColumnIndex(column),
|
|
867
|
-
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
868
|
-
}, evnt);
|
|
869
|
-
}
|
|
870
|
-
focused.row = null;
|
|
871
|
-
focused.column = null;
|
|
872
|
-
if (validOpts.autoClear) {
|
|
873
|
-
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
874
|
-
if ($xeTable.clearValidate) {
|
|
875
|
-
return $xeTable.clearValidate();
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
return $xeTable.$nextTick().then(() => {
|
|
880
|
-
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
|
|
881
|
-
return $xeTable.handleRecalculateCellAreas();
|
|
882
|
-
}
|
|
883
|
-
});
|
|
980
|
+
return handleClearEdit($xeTable, evnt, targetRow);
|
|
884
981
|
},
|
|
885
982
|
_getActiveRecord() {
|
|
886
983
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -997,11 +1094,12 @@ var _default = exports.default = {
|
|
|
997
1094
|
* 激活行编辑
|
|
998
1095
|
*/
|
|
999
1096
|
_setEditRow(row, fieldOrColumn) {
|
|
1097
|
+
const $xeTable = this;
|
|
1000
1098
|
let column = _xeUtils.default.find(this.visibleColumn, column => (0, _utils.isEnableConf)(column.editRender));
|
|
1001
1099
|
if (fieldOrColumn) {
|
|
1002
1100
|
column = _xeUtils.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
1003
1101
|
}
|
|
1004
|
-
return
|
|
1102
|
+
return handleEditCell($xeTable, row, column, false);
|
|
1005
1103
|
},
|
|
1006
1104
|
_setActiveCell(row, fieldOrColumn) {
|
|
1007
1105
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -1014,27 +1112,8 @@ var _default = exports.default = {
|
|
|
1014
1112
|
* 激活单元格编辑
|
|
1015
1113
|
*/
|
|
1016
1114
|
_setEditCell(row, fieldOrColumn) {
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
} = this;
|
|
1020
|
-
const column = _xeUtils.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
1021
|
-
if (row && column && (0, _utils.isEnableConf)(editConfig) && (0, _utils.isEnableConf)(column.editRender)) {
|
|
1022
|
-
return this.scrollToRow(row, true).then(() => {
|
|
1023
|
-
const cell = this.getCellElement(row, column);
|
|
1024
|
-
if (cell) {
|
|
1025
|
-
this.handleEdit({
|
|
1026
|
-
row,
|
|
1027
|
-
rowIndex: this.getRowIndex(row),
|
|
1028
|
-
column,
|
|
1029
|
-
columnIndex: this.getColumnIndex(column),
|
|
1030
|
-
cell,
|
|
1031
|
-
$table: this
|
|
1032
|
-
});
|
|
1033
|
-
this.lastCallTime = Date.now();
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
return this.$nextTick();
|
|
1115
|
+
const $xeTable = this;
|
|
1116
|
+
return handleEditCell($xeTable, row, fieldOrColumn, true);
|
|
1038
1117
|
},
|
|
1039
1118
|
/**
|
|
1040
1119
|
* 只对 trigger=dblclick 有效,选中单元格
|
|
@@ -1066,6 +1145,7 @@ var _default = exports.default = {
|
|
|
1066
1145
|
* 处理选中源
|
|
1067
1146
|
*/
|
|
1068
1147
|
handleSelected(params, evnt) {
|
|
1148
|
+
const $xeTable = this;
|
|
1069
1149
|
const {
|
|
1070
1150
|
mouseConfig,
|
|
1071
1151
|
mouseOpts,
|
|
@@ -1084,7 +1164,7 @@ var _default = exports.default = {
|
|
|
1084
1164
|
const selectMethod = () => {
|
|
1085
1165
|
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
1086
1166
|
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
1087
|
-
|
|
1167
|
+
handleClearEdit($xeTable, evnt);
|
|
1088
1168
|
this.clearSelected(evnt);
|
|
1089
1169
|
this.clearCellAreas(evnt);
|
|
1090
1170
|
this.clearCopyCellArea(evnt);
|
|
@@ -1092,7 +1172,7 @@ var _default = exports.default = {
|
|
|
1092
1172
|
selected.row = row;
|
|
1093
1173
|
selected.column = column;
|
|
1094
1174
|
if (isMouseSelected) {
|
|
1095
|
-
this.
|
|
1175
|
+
this.addCellSelectedClass();
|
|
1096
1176
|
}
|
|
1097
1177
|
this.focus();
|
|
1098
1178
|
if (evnt) {
|
|
@@ -1121,13 +1201,14 @@ var _default = exports.default = {
|
|
|
1121
1201
|
* 清除所选中源状态
|
|
1122
1202
|
*/
|
|
1123
1203
|
_clearSelected() {
|
|
1204
|
+
const $xeTable = this;
|
|
1124
1205
|
const {
|
|
1125
1206
|
selected
|
|
1126
1207
|
} = this.editStore;
|
|
1127
1208
|
selected.row = null;
|
|
1128
1209
|
selected.column = null;
|
|
1129
1210
|
this.reColTitleSdCls();
|
|
1130
|
-
|
|
1211
|
+
removeCellSelectedClass($xeTable);
|
|
1131
1212
|
return this.$nextTick();
|
|
1132
1213
|
},
|
|
1133
1214
|
reColTitleSdCls() {
|
|
@@ -1136,23 +1217,22 @@ var _default = exports.default = {
|
|
|
1136
1217
|
_xeUtils.default.arrayEach(headerElem.querySelectorAll('.col--title-selected'), elem => (0, _dom.removeClass)(elem, 'col--title-selected'));
|
|
1137
1218
|
}
|
|
1138
1219
|
},
|
|
1139
|
-
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
addColSdCls() {
|
|
1220
|
+
addCellSelectedClass() {
|
|
1221
|
+
const $xeTable = this;
|
|
1222
|
+
const reactData = $xeTable;
|
|
1223
|
+
const {
|
|
1224
|
+
editStore
|
|
1225
|
+
} = reactData;
|
|
1146
1226
|
const {
|
|
1147
1227
|
selected
|
|
1148
|
-
} =
|
|
1228
|
+
} = editStore;
|
|
1149
1229
|
const {
|
|
1150
1230
|
row,
|
|
1151
1231
|
column
|
|
1152
1232
|
} = selected;
|
|
1153
|
-
|
|
1233
|
+
removeCellSelectedClass($xeTable);
|
|
1154
1234
|
if (row && column) {
|
|
1155
|
-
const cell =
|
|
1235
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
1156
1236
|
if (cell) {
|
|
1157
1237
|
(0, _dom.addClass)(cell, 'col--selected');
|
|
1158
1238
|
}
|