vxe-table 3.12.15 → 3.12.17
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/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/edit/mixin.js +224 -158
- package/es/table/src/body.js +60 -47
- package/es/table/src/methods.js +166 -36
- package/es/table/src/table.js +101 -23
- package/es/table/style.css +26 -0
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +26 -0
- package/es/vxe-table/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +730 -391
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/edit/mixin.js +278 -215
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/src/body.js +71 -59
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +199 -37
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +126 -24
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/style/style.css +26 -0
- package/lib/table/style/style.min.css +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/lib/vxe-table/style/style.css +26 -0
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/table/module/edit/mixin.ts +242 -159
- package/packages/table/src/body.ts +62 -48
- package/packages/table/src/methods.ts +170 -36
- package/packages/table/src/table.ts +108 -24
- package/styles/components/table.scss +26 -0
- /package/es/{iconfont.1739257460253.ttf → iconfont.1739428244406.ttf} +0 -0
- /package/es/{iconfont.1739257460253.woff → iconfont.1739428244406.woff} +0 -0
- /package/es/{iconfont.1739257460253.woff2 → iconfont.1739428244406.woff2} +0 -0
- /package/lib/{iconfont.1739257460253.ttf → iconfont.1739428244406.ttf} +0 -0
- /package/lib/{iconfont.1739257460253.woff → iconfont.1739428244406.woff} +0 -0
- /package/lib/{iconfont.1739257460253.woff2 → iconfont.1739428244406.woff2} +0 -0
|
@@ -5,6 +5,21 @@ import { getCellValue, setCellValue, getRowid } from '../../src/util';
|
|
|
5
5
|
import { browse, removeClass, addClass } from '../../../ui/src/dom';
|
|
6
6
|
import { warnLog, errLog } from '../../../ui/src/log';
|
|
7
7
|
const { getConfig, renderer, getI18n } = VxeUI;
|
|
8
|
+
function getEditColumnModel(row, column) {
|
|
9
|
+
const { model, editRender } = column;
|
|
10
|
+
if (editRender) {
|
|
11
|
+
model.value = getCellValue(row, column);
|
|
12
|
+
model.update = false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function setEditColumnModel(row, column) {
|
|
16
|
+
const { model, editRender } = column;
|
|
17
|
+
if (editRender && model.update) {
|
|
18
|
+
setCellValue(row, column, model.value);
|
|
19
|
+
model.update = false;
|
|
20
|
+
model.value = null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
function removeCellSelectedClass($xeTable) {
|
|
9
24
|
const el = $xeTable.$refs.refElem;
|
|
10
25
|
if (el) {
|
|
@@ -14,6 +29,21 @@ function removeCellSelectedClass($xeTable) {
|
|
|
14
29
|
}
|
|
15
30
|
}
|
|
16
31
|
}
|
|
32
|
+
function syncActivedCell($xeTable) {
|
|
33
|
+
const reactData = $xeTable;
|
|
34
|
+
const { editStore, tableColumn } = reactData;
|
|
35
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
36
|
+
const { actived } = editStore;
|
|
37
|
+
const { row, column } = actived;
|
|
38
|
+
if (row || column) {
|
|
39
|
+
if (editOpts.mode === 'row') {
|
|
40
|
+
tableColumn.forEach((column) => setEditColumnModel(row, column));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
setEditColumnModel(row, column);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
17
47
|
function insertTreeRow(_vm, newRecords, isAppend) {
|
|
18
48
|
const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm;
|
|
19
49
|
const { rowField, parentField, mapChildrenField } = treeOpts;
|
|
@@ -37,7 +67,7 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
37
67
|
}
|
|
38
68
|
parentChilds[funcName](item);
|
|
39
69
|
mapChilds[funcName](item);
|
|
40
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 };
|
|
70
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
|
|
41
71
|
fullDataRowIdData[rowid] = rest;
|
|
42
72
|
fullAllDataRowIdData[rowid] = rest;
|
|
43
73
|
}
|
|
@@ -49,7 +79,7 @@ function insertTreeRow(_vm, newRecords, isAppend) {
|
|
|
49
79
|
}
|
|
50
80
|
afterFullData[funcName](item);
|
|
51
81
|
tableFullTreeData[funcName](item);
|
|
52
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 };
|
|
82
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
|
|
53
83
|
fullDataRowIdData[rowid] = rest;
|
|
54
84
|
fullAllDataRowIdData[rowid] = rest;
|
|
55
85
|
}
|
|
@@ -77,7 +107,7 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
|
|
|
77
107
|
else {
|
|
78
108
|
newRecords.forEach(item => {
|
|
79
109
|
const rowid = getRowid($xeTable, item);
|
|
80
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 };
|
|
110
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
|
|
81
111
|
fullDataRowIdData[rowid] = rest;
|
|
82
112
|
fullAllDataRowIdData[rowid] = rest;
|
|
83
113
|
afterFullData.unshift(item);
|
|
@@ -101,7 +131,7 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
|
|
|
101
131
|
else {
|
|
102
132
|
newRecords.forEach(item => {
|
|
103
133
|
const rowid = getRowid($xeTable, item);
|
|
104
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 };
|
|
134
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
|
|
105
135
|
fullDataRowIdData[rowid] = rest;
|
|
106
136
|
fullAllDataRowIdData[rowid] = rest;
|
|
107
137
|
afterFullData.push(item);
|
|
@@ -142,7 +172,7 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
|
|
|
142
172
|
targetIndex = targetIndex + 1;
|
|
143
173
|
}
|
|
144
174
|
parentMapChilds.splice(targetIndex, 0, item);
|
|
145
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 };
|
|
175
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
|
|
146
176
|
fullDataRowIdData[rowid] = rest;
|
|
147
177
|
fullAllDataRowIdData[rowid] = rest;
|
|
148
178
|
});
|
|
@@ -250,6 +280,178 @@ function handleInsertChildRowAt($xeTable, records, parentRow, targetRow, isInser
|
|
|
250
280
|
}
|
|
251
281
|
return Promise.resolve({ row: null, rows: [] });
|
|
252
282
|
}
|
|
283
|
+
function handleClearEdit($xeTable, evnt, targetRow) {
|
|
284
|
+
const props = $xeTable;
|
|
285
|
+
const reactData = $xeTable;
|
|
286
|
+
const { mouseConfig } = props;
|
|
287
|
+
const { editStore } = reactData;
|
|
288
|
+
const { actived, focused } = editStore;
|
|
289
|
+
const { row, column } = actived;
|
|
290
|
+
const validOpts = $xeTable.computeValidOpts;
|
|
291
|
+
const mouseOpts = $xeTable.computeMouseOpts;
|
|
292
|
+
if (row || column) {
|
|
293
|
+
if (targetRow && getRowid($xeTable, targetRow) !== getRowid($xeTable, row)) {
|
|
294
|
+
return $xeTable.$nextTick();
|
|
295
|
+
}
|
|
296
|
+
syncActivedCell($xeTable);
|
|
297
|
+
actived.args = null;
|
|
298
|
+
actived.row = null;
|
|
299
|
+
actived.column = null;
|
|
300
|
+
$xeTable.updateFooter();
|
|
301
|
+
$xeTable.dispatchEvent('edit-closed', {
|
|
302
|
+
row,
|
|
303
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
304
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
305
|
+
column,
|
|
306
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
307
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
308
|
+
}, evnt || null);
|
|
309
|
+
}
|
|
310
|
+
focused.row = null;
|
|
311
|
+
focused.column = null;
|
|
312
|
+
if (validOpts.autoClear) {
|
|
313
|
+
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
314
|
+
if ($xeTable.clearValidate) {
|
|
315
|
+
return $xeTable.clearValidate();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return $xeTable.$nextTick().then(() => {
|
|
320
|
+
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
|
|
321
|
+
return $xeTable.handleRecalculateCellAreas();
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function handleEditActive($xeTable, params, evnt, isFocus) {
|
|
326
|
+
const props = $xeTable;
|
|
327
|
+
const reactData = $xeTable;
|
|
328
|
+
const { editConfig, mouseConfig } = props;
|
|
329
|
+
const { editStore, tableColumn } = reactData;
|
|
330
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
331
|
+
const { mode } = editOpts;
|
|
332
|
+
const { actived, focused } = editStore;
|
|
333
|
+
const { row, column } = params;
|
|
334
|
+
const { editRender } = column;
|
|
335
|
+
const cell = (params.cell || $xeTable.getCellElement(row, column));
|
|
336
|
+
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
337
|
+
params.cell = cell;
|
|
338
|
+
if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
|
|
339
|
+
// 激活编辑
|
|
340
|
+
if (!$xeTable.isPendingByRow(row)) {
|
|
341
|
+
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
342
|
+
// 判断是否禁用编辑
|
|
343
|
+
let type = 'edit-disabled';
|
|
344
|
+
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }))) {
|
|
345
|
+
if (mouseConfig) {
|
|
346
|
+
$xeTable.clearSelected();
|
|
347
|
+
if ($xeTable.clearCellAreas) {
|
|
348
|
+
$xeTable.clearCellAreas();
|
|
349
|
+
$xeTable.clearCopyCellArea();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
$xeTable.closeTooltip();
|
|
353
|
+
if (actived.column) {
|
|
354
|
+
handleClearEdit($xeTable, evnt);
|
|
355
|
+
}
|
|
356
|
+
type = 'edit-activated';
|
|
357
|
+
column.renderHeight = cell.offsetHeight;
|
|
358
|
+
actived.args = params;
|
|
359
|
+
actived.row = row;
|
|
360
|
+
actived.column = column;
|
|
361
|
+
if (mode === 'row') {
|
|
362
|
+
tableColumn.forEach((column) => getEditColumnModel(row, column));
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
getEditColumnModel(row, column);
|
|
366
|
+
}
|
|
367
|
+
const afterEditMethod = editOpts.afterEditMethod;
|
|
368
|
+
$xeTable.$nextTick(() => {
|
|
369
|
+
if (isFocus) {
|
|
370
|
+
$xeTable.handleFocus(params, evnt);
|
|
371
|
+
}
|
|
372
|
+
if (afterEditMethod) {
|
|
373
|
+
afterEditMethod(Object.assign(Object.assign({}, params), { $table: $xeTable, $grid: $xeTable.xegrid }));
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
$xeTable.dispatchEvent(type, {
|
|
378
|
+
row,
|
|
379
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
380
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
381
|
+
column,
|
|
382
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
383
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
384
|
+
}, evnt);
|
|
385
|
+
// v4已废弃
|
|
386
|
+
if (type === 'edit-activated') {
|
|
387
|
+
$xeTable.dispatchEvent('edit-actived', {
|
|
388
|
+
row,
|
|
389
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
390
|
+
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
391
|
+
column,
|
|
392
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
393
|
+
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
394
|
+
}, evnt);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
const { column: oldColumn } = actived;
|
|
399
|
+
if (mouseConfig) {
|
|
400
|
+
$xeTable.clearSelected();
|
|
401
|
+
if ($xeTable.clearCellAreas) {
|
|
402
|
+
$xeTable.clearCellAreas();
|
|
403
|
+
$xeTable.clearCopyCellArea();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (oldColumn !== column) {
|
|
407
|
+
const { model: oldModel } = oldColumn;
|
|
408
|
+
if (oldModel.update) {
|
|
409
|
+
setCellValue(row, oldColumn, oldModel.value);
|
|
410
|
+
}
|
|
411
|
+
if ($xeTable.clearValidate) {
|
|
412
|
+
$xeTable.clearValidate(row, column);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
column.renderHeight = cell.offsetHeight;
|
|
416
|
+
actived.args = params;
|
|
417
|
+
actived.column = column;
|
|
418
|
+
if (isFocus) {
|
|
419
|
+
setTimeout(() => {
|
|
420
|
+
$xeTable.handleFocus(params, evnt);
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
focused.column = null;
|
|
425
|
+
focused.row = null;
|
|
426
|
+
$xeTable.focus();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return $xeTable.$nextTick();
|
|
430
|
+
}
|
|
431
|
+
function handleEditCell($xeTable, row, fieldOrColumn, isPos) {
|
|
432
|
+
const props = $xeTable;
|
|
433
|
+
const internalData = $xeTable;
|
|
434
|
+
const { editConfig } = props;
|
|
435
|
+
const column = XEUtils.isString(fieldOrColumn) ? $xeTable.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
436
|
+
if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender)) {
|
|
437
|
+
return Promise.resolve(isPos ? $xeTable.scrollToRow(row, column) : null).then(() => {
|
|
438
|
+
const cell = $xeTable.getCellElement(row, column);
|
|
439
|
+
if (cell) {
|
|
440
|
+
handleEditActive($xeTable, {
|
|
441
|
+
row,
|
|
442
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
443
|
+
column,
|
|
444
|
+
columnIndex: $xeTable.getColumnIndex(column),
|
|
445
|
+
cell,
|
|
446
|
+
$table: $xeTable
|
|
447
|
+
}, null, false);
|
|
448
|
+
internalData._lastCallTime = Date.now();
|
|
449
|
+
}
|
|
450
|
+
return $xeTable.$nextTick();
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
return $xeTable.$nextTick();
|
|
454
|
+
}
|
|
253
455
|
export default {
|
|
254
456
|
methods: {
|
|
255
457
|
/**
|
|
@@ -493,12 +695,13 @@ export default {
|
|
|
493
695
|
* 如果是树表格,子节点更改状态不会影响父节点的更新状态
|
|
494
696
|
*/
|
|
495
697
|
_getUpdateRecords() {
|
|
698
|
+
const $xeTable = this;
|
|
496
699
|
const { keepSource, tableFullData, isUpdateByRow, treeConfig, treeOpts, editStore } = this;
|
|
497
700
|
if (keepSource) {
|
|
498
701
|
const { actived } = editStore;
|
|
499
702
|
const { row, column } = actived;
|
|
500
703
|
if (row || column) {
|
|
501
|
-
|
|
704
|
+
syncActivedCell($xeTable);
|
|
502
705
|
}
|
|
503
706
|
if (treeConfig) {
|
|
504
707
|
return XEUtils.filterTree(tableFullData, row => isUpdateByRow(row), treeOpts);
|
|
@@ -511,81 +714,8 @@ export default {
|
|
|
511
714
|
* 处理激活编辑
|
|
512
715
|
*/
|
|
513
716
|
handleEdit(params, evnt) {
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
const { actived, focused } = editStore;
|
|
517
|
-
const { row, column } = params;
|
|
518
|
-
const { editRender } = column;
|
|
519
|
-
const cell = params.cell = (params.cell || this.getCellElement(row, column));
|
|
520
|
-
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
521
|
-
if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
|
|
522
|
-
// 激活编辑
|
|
523
|
-
if (!this.hasPendingByRow(row)) {
|
|
524
|
-
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
|
|
525
|
-
// 判断是否禁用编辑
|
|
526
|
-
let type = 'edit-disabled';
|
|
527
|
-
if (!beforeEditMethod || beforeEditMethod(Object.assign(Object.assign({}, params), { $table: this, $grid: this.$xegrid }))) {
|
|
528
|
-
if (mouseConfig) {
|
|
529
|
-
this.clearSelected(evnt);
|
|
530
|
-
this.clearCellAreas(evnt);
|
|
531
|
-
this.clearCopyCellArea(evnt);
|
|
532
|
-
}
|
|
533
|
-
this.closeTooltip();
|
|
534
|
-
if (actived.column) {
|
|
535
|
-
this.handleClearEdit(evnt);
|
|
536
|
-
}
|
|
537
|
-
type = 'edit-activated';
|
|
538
|
-
column.renderHeight = cell.offsetHeight;
|
|
539
|
-
actived.args = params;
|
|
540
|
-
actived.row = row;
|
|
541
|
-
actived.column = column;
|
|
542
|
-
if (mode === 'row') {
|
|
543
|
-
tableColumn.forEach((column) => this._getColumnModel(row, column));
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
this._getColumnModel(row, column);
|
|
547
|
-
}
|
|
548
|
-
const afterEditMethod = editOpts.afterEditMethod;
|
|
549
|
-
this.$nextTick(() => {
|
|
550
|
-
this.handleFocus(params, evnt);
|
|
551
|
-
if (afterEditMethod) {
|
|
552
|
-
afterEditMethod(Object.assign(Object.assign({}, params), { $table: this, $grid: this.$xegrid }));
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
this.emitEvent(type, params, evnt);
|
|
557
|
-
// v4已废弃
|
|
558
|
-
if (type === 'edit-activated') {
|
|
559
|
-
this.emitEvent('edit-actived', params, evnt);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
const { column: oldColumn } = actived;
|
|
564
|
-
if (mouseConfig) {
|
|
565
|
-
this.clearSelected(evnt);
|
|
566
|
-
this.clearCellAreas(evnt);
|
|
567
|
-
this.clearCopyCellArea(evnt);
|
|
568
|
-
}
|
|
569
|
-
if (oldColumn !== column) {
|
|
570
|
-
const { model: oldModel } = oldColumn;
|
|
571
|
-
if (oldModel.update) {
|
|
572
|
-
setCellValue(row, oldColumn, oldModel.value);
|
|
573
|
-
}
|
|
574
|
-
this.clearValidate();
|
|
575
|
-
}
|
|
576
|
-
column.renderHeight = cell.offsetHeight;
|
|
577
|
-
actived.args = params;
|
|
578
|
-
actived.column = column;
|
|
579
|
-
setTimeout(() => {
|
|
580
|
-
this.handleFocus(params, evnt);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
focused.column = null;
|
|
584
|
-
focused.row = null;
|
|
585
|
-
this.focus();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return this.$nextTick();
|
|
717
|
+
const $xeTable = this;
|
|
718
|
+
return handleEditActive($xeTable, params, evnt, true);
|
|
589
719
|
},
|
|
590
720
|
/**
|
|
591
721
|
* @deprecated
|
|
@@ -594,32 +724,14 @@ export default {
|
|
|
594
724
|
return this.handleEdit(params, evnt);
|
|
595
725
|
},
|
|
596
726
|
_getColumnModel(row, column) {
|
|
597
|
-
|
|
598
|
-
if (editRender) {
|
|
599
|
-
model.value = getCellValue(row, column);
|
|
600
|
-
model.update = false;
|
|
601
|
-
}
|
|
727
|
+
getEditColumnModel(row, column);
|
|
602
728
|
},
|
|
603
729
|
_setColumnModel(row, column) {
|
|
604
|
-
|
|
605
|
-
if (editRender && model.update) {
|
|
606
|
-
setCellValue(row, column, model.value);
|
|
607
|
-
model.update = false;
|
|
608
|
-
model.value = null;
|
|
609
|
-
}
|
|
730
|
+
setEditColumnModel(row, column);
|
|
610
731
|
},
|
|
611
732
|
_syncActivedCell() {
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const { row, column } = actived;
|
|
615
|
-
if (row || column) {
|
|
616
|
-
if (editOpts.mode === 'row') {
|
|
617
|
-
tableColumn.forEach((column) => this._setColumnModel(row, column));
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
this._setColumnModel(row, column);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
733
|
+
const $xeTable = this;
|
|
734
|
+
syncActivedCell($xeTable);
|
|
623
735
|
},
|
|
624
736
|
_clearActived(row) {
|
|
625
737
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -632,53 +744,15 @@ export default {
|
|
|
632
744
|
* 清除激活的编辑
|
|
633
745
|
*/
|
|
634
746
|
_clearEdit(row) {
|
|
635
|
-
|
|
747
|
+
const $xeTable = this;
|
|
748
|
+
return handleClearEdit($xeTable, null, row);
|
|
636
749
|
},
|
|
637
750
|
/**
|
|
638
751
|
* 取消编辑
|
|
639
752
|
*/
|
|
640
753
|
handleClearEdit(evnt, targetRow) {
|
|
641
754
|
const $xeTable = this;
|
|
642
|
-
|
|
643
|
-
const reactData = $xeTable;
|
|
644
|
-
const { mouseConfig } = props;
|
|
645
|
-
const { editStore } = reactData;
|
|
646
|
-
const { actived, focused } = editStore;
|
|
647
|
-
const { row, column } = actived;
|
|
648
|
-
const validOpts = $xeTable.validOpts;
|
|
649
|
-
const mouseOpts = $xeTable.computeMouseOpts;
|
|
650
|
-
if (row || column) {
|
|
651
|
-
if (targetRow && getRowid($xeTable, targetRow) !== getRowid($xeTable, row)) {
|
|
652
|
-
return $xeTable.$nextTick();
|
|
653
|
-
}
|
|
654
|
-
$xeTable._syncActivedCell();
|
|
655
|
-
actived.args = null;
|
|
656
|
-
actived.row = null;
|
|
657
|
-
actived.column = null;
|
|
658
|
-
$xeTable.updateFooter();
|
|
659
|
-
$xeTable.emitEvent('edit-closed', {
|
|
660
|
-
row,
|
|
661
|
-
rowIndex: $xeTable.getRowIndex(row),
|
|
662
|
-
$rowIndex: $xeTable.getVMRowIndex(row),
|
|
663
|
-
column,
|
|
664
|
-
columnIndex: $xeTable.getColumnIndex(column),
|
|
665
|
-
$columnIndex: $xeTable.getVMColumnIndex(column)
|
|
666
|
-
}, evnt);
|
|
667
|
-
}
|
|
668
|
-
focused.row = null;
|
|
669
|
-
focused.column = null;
|
|
670
|
-
if (validOpts.autoClear) {
|
|
671
|
-
if (validOpts.msgMode !== 'full' || getConfig().cellVaildMode === 'obsolete') {
|
|
672
|
-
if ($xeTable.clearValidate) {
|
|
673
|
-
return $xeTable.clearValidate();
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
return $xeTable.$nextTick().then(() => {
|
|
678
|
-
if (mouseConfig && mouseOpts.area && $xeTable.handleRecalculateCellAreas) {
|
|
679
|
-
return $xeTable.handleRecalculateCellAreas();
|
|
680
|
-
}
|
|
681
|
-
});
|
|
755
|
+
return handleClearEdit($xeTable, evnt, targetRow);
|
|
682
756
|
},
|
|
683
757
|
_getActiveRecord() {
|
|
684
758
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -782,11 +856,12 @@ export default {
|
|
|
782
856
|
* 激活行编辑
|
|
783
857
|
*/
|
|
784
858
|
_setEditRow(row, fieldOrColumn) {
|
|
859
|
+
const $xeTable = this;
|
|
785
860
|
let column = XEUtils.find(this.visibleColumn, column => isEnableConf(column.editRender));
|
|
786
861
|
if (fieldOrColumn) {
|
|
787
862
|
column = XEUtils.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
|
|
788
863
|
}
|
|
789
|
-
return
|
|
864
|
+
return handleEditCell($xeTable, row, column, false);
|
|
790
865
|
},
|
|
791
866
|
_setActiveCell(row, fieldOrColumn) {
|
|
792
867
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -799,18 +874,8 @@ export default {
|
|
|
799
874
|
* 激活单元格编辑
|
|
800
875
|
*/
|
|
801
876
|
_setEditCell(row, fieldOrColumn) {
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
if (row && column && isEnableConf(editConfig) && isEnableConf(column.editRender)) {
|
|
805
|
-
return this.scrollToRow(row, true).then(() => {
|
|
806
|
-
const cell = this.getCellElement(row, column);
|
|
807
|
-
if (cell) {
|
|
808
|
-
this.handleEdit({ row, rowIndex: this.getRowIndex(row), column, columnIndex: this.getColumnIndex(column), cell, $table: this });
|
|
809
|
-
this.lastCallTime = Date.now();
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
return this.$nextTick();
|
|
877
|
+
const $xeTable = this;
|
|
878
|
+
return handleEditCell($xeTable, row, fieldOrColumn, true);
|
|
814
879
|
},
|
|
815
880
|
/**
|
|
816
881
|
* 只对 trigger=dblclick 有效,选中单元格
|
|
@@ -832,6 +897,7 @@ export default {
|
|
|
832
897
|
* 处理选中源
|
|
833
898
|
*/
|
|
834
899
|
handleSelected(params, evnt) {
|
|
900
|
+
const $xeTable = this;
|
|
835
901
|
const { mouseConfig, mouseOpts, editOpts, editStore } = this;
|
|
836
902
|
const { actived, selected } = editStore;
|
|
837
903
|
const { row, column } = params;
|
|
@@ -839,7 +905,7 @@ export default {
|
|
|
839
905
|
const selectMethod = () => {
|
|
840
906
|
if (isMouseSelected && (selected.row !== row || selected.column !== column)) {
|
|
841
907
|
if (actived.row !== row || (editOpts.mode === 'cell' ? actived.column !== column : false)) {
|
|
842
|
-
|
|
908
|
+
handleClearEdit($xeTable, evnt);
|
|
843
909
|
this.clearSelected(evnt);
|
|
844
910
|
this.clearCellAreas(evnt);
|
|
845
911
|
this.clearCopyCellArea(evnt);
|
package/es/table/src/body.js
CHANGED
|
@@ -381,7 +381,7 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
|
|
|
381
381
|
const tableReactData = $xeTable;
|
|
382
382
|
const tableInternalData = $xeTable;
|
|
383
383
|
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps;
|
|
384
|
-
const { hasFixedColumn, treeExpandedMaps, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove } = tableReactData;
|
|
384
|
+
const { hasFixedColumn, treeExpandedMaps, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove, rowExpandHeightFlag } = tableReactData;
|
|
385
385
|
const { fullAllDataRowIdData } = tableInternalData;
|
|
386
386
|
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
387
387
|
const radioOpts = $xeTable.computeRadioOpts;
|
|
@@ -414,19 +414,19 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
|
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
const rowid = getRowid($xeTable, row);
|
|
417
|
-
const
|
|
417
|
+
const rowRest = fullAllDataRowIdData[rowid];
|
|
418
418
|
let rowLevel = 0;
|
|
419
419
|
let seq = -1;
|
|
420
420
|
let _rowIndex = 0;
|
|
421
|
-
if (
|
|
422
|
-
rowLevel =
|
|
421
|
+
if (rowRest) {
|
|
422
|
+
rowLevel = rowRest.level;
|
|
423
423
|
if (treeConfig && transform && seqMode === 'increasing') {
|
|
424
|
-
seq =
|
|
424
|
+
seq = rowRest._index + 1;
|
|
425
425
|
}
|
|
426
426
|
else {
|
|
427
|
-
seq =
|
|
427
|
+
seq = rowRest.seq;
|
|
428
428
|
}
|
|
429
|
-
_rowIndex =
|
|
429
|
+
_rowIndex = rowRest._index;
|
|
430
430
|
}
|
|
431
431
|
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex };
|
|
432
432
|
// 行是否被展开
|
|
@@ -493,46 +493,63 @@ function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
|
|
|
493
493
|
// 如果行被展开了
|
|
494
494
|
if (isExpandRow) {
|
|
495
495
|
const expandOpts = $xeTable.computeExpandOpts;
|
|
496
|
-
const { height: expandHeight, padding } = expandOpts;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (treeConfig) {
|
|
502
|
-
cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`;
|
|
503
|
-
}
|
|
504
|
-
const { showOverflow } = expandColumn;
|
|
505
|
-
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? isAllOverflow : showOverflow;
|
|
506
|
-
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex };
|
|
507
|
-
rows.push(h('tr', {
|
|
508
|
-
class: ['vxe-body--expanded-row', {
|
|
509
|
-
'is--padding': padding
|
|
510
|
-
}],
|
|
511
|
-
key: `expand_${rowid}`,
|
|
512
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) : undefined,
|
|
513
|
-
on: trOn
|
|
514
|
-
}, [
|
|
515
|
-
h('td', {
|
|
516
|
-
class: {
|
|
517
|
-
'vxe-body--expanded-column': 1,
|
|
518
|
-
'fixed--hidden': fixedType && !hasFixedColumn,
|
|
519
|
-
'col--ellipsis': hasEllipsis
|
|
520
|
-
},
|
|
496
|
+
const { height: expandHeight, padding, mode: expandMode } = expandOpts;
|
|
497
|
+
if (expandMode === 'fixed') {
|
|
498
|
+
rows.push(h('tr', {
|
|
499
|
+
class: 'vxe-body--row-expanded-place',
|
|
500
|
+
key: `expand_${rowid}`,
|
|
521
501
|
attrs: {
|
|
522
|
-
|
|
502
|
+
rowid
|
|
523
503
|
}
|
|
524
504
|
}, [
|
|
525
|
-
h('
|
|
526
|
-
class:
|
|
527
|
-
|
|
528
|
-
|
|
505
|
+
h('td', {
|
|
506
|
+
class: 'vxe-body--row-expanded-place-column',
|
|
507
|
+
attrs: {
|
|
508
|
+
colspan: tableColumn.length
|
|
529
509
|
},
|
|
530
|
-
style:
|
|
510
|
+
style: {
|
|
511
|
+
height: `${rowExpandHeightFlag ? (rowRest.expandHeight || expandHeight) : 0}px`
|
|
512
|
+
}
|
|
513
|
+
})
|
|
514
|
+
]));
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
const cellStyle = {};
|
|
518
|
+
if (expandHeight) {
|
|
519
|
+
cellStyle.height = `${expandHeight}px`;
|
|
520
|
+
}
|
|
521
|
+
if (treeConfig) {
|
|
522
|
+
cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`;
|
|
523
|
+
}
|
|
524
|
+
const { showOverflow } = expandColumn;
|
|
525
|
+
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? isAllOverflow : showOverflow;
|
|
526
|
+
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex };
|
|
527
|
+
rows.push(h('tr', {
|
|
528
|
+
class: ['vxe-body--expanded-row', {
|
|
529
|
+
'is--padding': padding
|
|
530
|
+
}],
|
|
531
|
+
key: `expand_${rowid}`
|
|
532
|
+
}, [
|
|
533
|
+
h('td', {
|
|
534
|
+
class: ['vxe-body--expanded-column', {
|
|
535
|
+
'fixed--hidden': fixedType && !hasFixedColumn,
|
|
536
|
+
'col--ellipsis': hasEllipsis
|
|
537
|
+
}],
|
|
538
|
+
attrs: {
|
|
539
|
+
colspan: tableColumn.length
|
|
540
|
+
}
|
|
531
541
|
}, [
|
|
532
|
-
|
|
542
|
+
h('div', {
|
|
543
|
+
class: ['vxe-body--expanded-cell', {
|
|
544
|
+
'is--ellipsis': expandHeight
|
|
545
|
+
}],
|
|
546
|
+
style: cellStyle
|
|
547
|
+
}, [
|
|
548
|
+
expandColumn.renderData(h, expandParams)
|
|
549
|
+
])
|
|
533
550
|
])
|
|
534
|
-
])
|
|
535
|
-
|
|
551
|
+
]));
|
|
552
|
+
}
|
|
536
553
|
}
|
|
537
554
|
// 如果是树形表格
|
|
538
555
|
if (isExpandTree) {
|
|
@@ -600,14 +617,13 @@ export default {
|
|
|
600
617
|
const emptyOpts = $xeTable.computeEmptyOpts;
|
|
601
618
|
const mouseOpts = $xeTable.computeMouseOpts;
|
|
602
619
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
603
|
-
const
|
|
604
|
-
const rightFixedWidth = $xeTable.computeRightFixedWidth;
|
|
620
|
+
const expandOpts = $xeTable.computeExpandOpts;
|
|
605
621
|
let renderDataList = tableData;
|
|
606
622
|
let renderColumnList = tableColumn;
|
|
607
623
|
let isOptimizeMode = false;
|
|
608
624
|
// 如果是使用优化模式
|
|
609
625
|
if (scrollXLoad || scrollYLoad || isAllOverflow) {
|
|
610
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
626
|
+
if ((expandColumn && expandOpts.mode !== 'fixed') || spanMethod || footerSpanMethod) {
|
|
611
627
|
// 如果不支持优化模式
|
|
612
628
|
}
|
|
613
629
|
else {
|
|
@@ -687,9 +703,6 @@ export default {
|
|
|
687
703
|
$xeTable.triggerBodyScrollEvent(evnt, fixedType);
|
|
688
704
|
}
|
|
689
705
|
};
|
|
690
|
-
if (scrollYLoad || leftFixedWidth || rightFixedWidth) {
|
|
691
|
-
ons.wheel = $xeTable.triggerBodyWheelEvent;
|
|
692
|
-
}
|
|
693
706
|
return h('div', {
|
|
694
707
|
ref: 'refElem',
|
|
695
708
|
class: ['vxe-table--body-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
|