vxe-table 4.18.13 → 4.19.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.
- package/README.md +2 -2
- package/es/grid/src/grid.js +1 -1
- 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/hook.js +36 -12
- package/es/table/module/keyboard/hook.js +2 -2
- package/es/table/src/emits.js +2 -0
- package/es/table/src/props.js +2 -2
- package/es/table/src/table.js +331 -141
- package/es/table/src/util.js +12 -3
- package/es/ui/index.js +3 -3
- package/es/ui/src/dom.js +4 -0
- package/es/ui/src/log.js +1 -1
- package/lib/grid/src/grid.js +1 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +108 -55
- 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/hook.js +42 -12
- package/lib/table/module/edit/hook.min.js +1 -1
- package/lib/table/module/keyboard/hook.js +2 -2
- package/lib/table/module/keyboard/hook.min.js +1 -1
- package/lib/table/src/emits.js +1 -1
- package/lib/table/src/emits.min.js +1 -1
- package/lib/table/src/props.js +2 -2
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +39 -30
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +12 -3
- package/lib/table/src/util.min.js +1 -1
- package/lib/ui/index.js +3 -3
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +5 -0
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +3 -3
- package/packages/grid/src/grid.ts +1 -1
- package/packages/table/module/edit/hook.ts +44 -12
- package/packages/table/module/keyboard/hook.ts +2 -2
- package/packages/table/src/emits.ts +2 -0
- package/packages/table/src/props.ts +2 -2
- package/packages/table/src/table.ts +326 -136
- package/packages/table/src/util.ts +15 -5
- package/packages/ui/index.ts +2 -2
- package/packages/ui/src/dom.ts +5 -0
- /package/es/{iconfont.1776926463538.ttf → iconfont.1778035441293.ttf} +0 -0
- /package/es/{iconfont.1776926463538.woff → iconfont.1778035441293.woff} +0 -0
- /package/es/{iconfont.1776926463538.woff2 → iconfont.1778035441293.woff2} +0 -0
- /package/lib/{iconfont.1776926463538.ttf → iconfont.1778035441293.ttf} +0 -0
- /package/lib/{iconfont.1776926463538.woff → iconfont.1778035441293.woff} +0 -0
- /package/lib/{iconfont.1776926463538.woff2 → iconfont.1778035441293.woff2} +0 -0
package/es/table/src/table.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, reactive, ref, provide, inject, nextTick, Teleport, onActivated, onDeactivated, onBeforeUnmount, onUnmounted, watch, computed, onMounted } from 'vue';
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
3
3
|
import XEUtils from 'xe-utils';
|
|
4
|
-
import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, wheelScrollTopTo, wheelScrollLeftTo, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey, checkTargetElement } from '../../ui/src/dom';
|
|
4
|
+
import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, wheelScrollTopTo, wheelScrollLeftTo, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey, checkTargetElement, hasEventInputTarget } from '../../ui/src/dom';
|
|
5
5
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
|
|
6
6
|
import { VxeUI } from '../../ui';
|
|
7
7
|
import { createReactData, createInternalData, getRowUniqueId, createRowId, clearTableAllStatus, getColumnList, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight, getLastChildColumn } from './util';
|
|
@@ -332,8 +332,8 @@ export default defineVxeComponent({
|
|
|
332
332
|
const computeClipOpts = computed(() => {
|
|
333
333
|
return Object.assign({}, getConfig().table.clipConfig, props.clipConfig);
|
|
334
334
|
});
|
|
335
|
-
const
|
|
336
|
-
return Object.assign({}, getConfig().table.
|
|
335
|
+
const computeUndoRedoHistoryOpts = computed(() => {
|
|
336
|
+
return Object.assign({}, getConfig().table.undoRedoHistoryConfig, props.undoRedoHistoryConfig);
|
|
337
337
|
});
|
|
338
338
|
const computeFNROpts = computed(() => {
|
|
339
339
|
const fnrOpts = computeFnrOpts.value;
|
|
@@ -768,7 +768,7 @@ export default defineVxeComponent({
|
|
|
768
768
|
computeRowGroupFields,
|
|
769
769
|
computeRowGroupColumns,
|
|
770
770
|
computeAggFuncColumns,
|
|
771
|
-
|
|
771
|
+
computeUndoRedoHistoryOpts,
|
|
772
772
|
computeFNROpts,
|
|
773
773
|
computeSXOpts,
|
|
774
774
|
computeSYOpts
|
|
@@ -1720,7 +1720,7 @@ export default defineVxeComponent({
|
|
|
1720
1720
|
errLog('vxe.error.errConflicts', ['mouse-config.area', 'column.type=expand']);
|
|
1721
1721
|
}
|
|
1722
1722
|
if (expandOpts.mode !== 'inside' && (treeConfig && !treeOpts.transform)) {
|
|
1723
|
-
errLog('vxe.error.notConflictProp', ['tree-config.transform=false', 'expand-config.mode=
|
|
1723
|
+
errLog('vxe.error.notConflictProp', ['tree-config.transform=false', 'expand-config.mode=inside']);
|
|
1724
1724
|
}
|
|
1725
1725
|
if (props.spanMethod) {
|
|
1726
1726
|
warnLog('vxe.error.notSupportProp', ['column.type=expand', 'span-method', 'span-method=null']);
|
|
@@ -3642,6 +3642,7 @@ export default defineVxeComponent({
|
|
|
3642
3642
|
}
|
|
3643
3643
|
$xeTable.clearMergeCells();
|
|
3644
3644
|
$xeTable.clearMergeFooterItems();
|
|
3645
|
+
$xeTable.handleClearStack();
|
|
3645
3646
|
$xeTable.handleTableData(true);
|
|
3646
3647
|
$xeTable.updateFooter();
|
|
3647
3648
|
$xeTable.handleUpdateBodyMerge();
|
|
@@ -7623,6 +7624,12 @@ export default defineVxeComponent({
|
|
|
7623
7624
|
}
|
|
7624
7625
|
return nextTick();
|
|
7625
7626
|
},
|
|
7627
|
+
undo() {
|
|
7628
|
+
return $xeTable.handleUndoStackEvent(null);
|
|
7629
|
+
},
|
|
7630
|
+
redo() {
|
|
7631
|
+
return $xeTable.handleRedoStackEvent(null);
|
|
7632
|
+
},
|
|
7626
7633
|
getCustomStoreData() {
|
|
7627
7634
|
const { id } = props;
|
|
7628
7635
|
const customOpts = computeCustomOpts.value;
|
|
@@ -8024,6 +8031,8 @@ export default defineVxeComponent({
|
|
|
8024
8031
|
const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT);
|
|
8025
8032
|
const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
|
|
8026
8033
|
const hasDeleteKey = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE);
|
|
8034
|
+
const isY = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.Y);
|
|
8035
|
+
const isZ = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.Z);
|
|
8027
8036
|
const isF2 = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.F2);
|
|
8028
8037
|
const isContextMenu = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.CONTEXT_MENU);
|
|
8029
8038
|
const isControlKey = hasControlKey(evnt);
|
|
@@ -8033,6 +8042,7 @@ export default defineVxeComponent({
|
|
|
8033
8042
|
const operCtxMenu = isContentMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow);
|
|
8034
8043
|
const isEditStatus = isEnableConf(editConfig) && actived.column && actived.row;
|
|
8035
8044
|
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
8045
|
+
const selectColumn = selected.column;
|
|
8036
8046
|
if (operCtxMenu) {
|
|
8037
8047
|
// 如果配置了右键菜单; 支持方向键操作、回车
|
|
8038
8048
|
evnt.preventDefault();
|
|
@@ -8064,10 +8074,10 @@ export default defineVxeComponent({
|
|
|
8064
8074
|
}
|
|
8065
8075
|
}
|
|
8066
8076
|
}
|
|
8067
|
-
else if (isSpacebar && keyboardConfig && keyboardOpts.isChecked && selected.row &&
|
|
8077
|
+
else if (isSpacebar && keyboardConfig && keyboardOpts.isChecked && selected.row && selectColumn && (selectColumn.type === 'checkbox' || selectColumn.type === 'radio')) {
|
|
8068
8078
|
// 空格键支持选中复选框
|
|
8069
8079
|
evnt.preventDefault();
|
|
8070
|
-
if (
|
|
8080
|
+
if (selectColumn.type === 'checkbox') {
|
|
8071
8081
|
$xeTable.handleToggleCheckRowEvent(evnt, selected.args);
|
|
8072
8082
|
}
|
|
8073
8083
|
else {
|
|
@@ -8077,7 +8087,7 @@ export default defineVxeComponent({
|
|
|
8077
8087
|
else if (isF2 && isEnableConf(editConfig)) {
|
|
8078
8088
|
if (!isEditStatus) {
|
|
8079
8089
|
// 如果按下了 F2 键
|
|
8080
|
-
if (selected.row &&
|
|
8090
|
+
if (selected.row && selectColumn) {
|
|
8081
8091
|
evnt.preventDefault();
|
|
8082
8092
|
$xeTable.handleEdit(selected.args, evnt);
|
|
8083
8093
|
}
|
|
@@ -8085,7 +8095,7 @@ export default defineVxeComponent({
|
|
|
8085
8095
|
}
|
|
8086
8096
|
else if (isContextMenu) {
|
|
8087
8097
|
// 如果按下上下文键
|
|
8088
|
-
internalData._keyCtx = selected.row &&
|
|
8098
|
+
internalData._keyCtx = selected.row && selectColumn && bodyMenu.length;
|
|
8089
8099
|
clearTimeout(internalData.keyCtxTimeout);
|
|
8090
8100
|
internalData.keyCtxTimeout = setTimeout(() => {
|
|
8091
8101
|
internalData._keyCtx = false;
|
|
@@ -8110,89 +8120,91 @@ export default defineVxeComponent({
|
|
|
8110
8120
|
// 如果是激活状态,退则出到上一行/下一行
|
|
8111
8121
|
if (selected.row || actived.row) {
|
|
8112
8122
|
const activeRow = selected.row || actived.row;
|
|
8113
|
-
const activeColumn =
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
if (
|
|
8117
|
-
|
|
8123
|
+
const activeColumn = selectColumn || actived.column;
|
|
8124
|
+
if (activeColumn) {
|
|
8125
|
+
const activeParams = selected.row ? selected.args : actived.args;
|
|
8126
|
+
if (hasShiftKey) {
|
|
8127
|
+
if (keyboardOpts.enterToTab) {
|
|
8128
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt);
|
|
8129
|
+
}
|
|
8130
|
+
else {
|
|
8131
|
+
$xeTable.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt);
|
|
8132
|
+
}
|
|
8118
8133
|
}
|
|
8119
8134
|
else {
|
|
8120
|
-
$xeTable.
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8135
|
+
const _rowIndex = $xeTable.getVTRowIndex(activeRow);
|
|
8136
|
+
const _columnIndex = $xeTable.getVTColumnIndex(activeColumn);
|
|
8137
|
+
if (keyboardOpts.enterToTab) {
|
|
8138
|
+
const ttrParams = {
|
|
8139
|
+
row: activeRow,
|
|
8140
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8141
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8142
|
+
_rowIndex,
|
|
8143
|
+
column: activeColumn,
|
|
8144
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8145
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8146
|
+
_columnIndex,
|
|
8147
|
+
$table: $xeTable
|
|
8148
|
+
};
|
|
8149
|
+
if (!beforeTabMethod || beforeTabMethod(ttrParams) !== false) {
|
|
8150
|
+
evnt.preventDefault();
|
|
8151
|
+
// 最后一行按下Tab键,自动追加一行
|
|
8152
|
+
if (isLastTabAppendRow) {
|
|
8153
|
+
const newColumn = visibleColumn[0];
|
|
8154
|
+
if (_rowIndex >= afterFullData.length - 1 && _columnIndex >= visibleColumn.length - 1) {
|
|
8155
|
+
if (actived.row) {
|
|
8156
|
+
$xeTable.handleClearEdit(evnt);
|
|
8157
|
+
}
|
|
8158
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8159
|
+
$xeTable.scrollToRow(newRow, newColumn);
|
|
8160
|
+
$xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), { row: newRow, column: newColumn }), evnt);
|
|
8161
|
+
});
|
|
8162
|
+
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt);
|
|
8163
|
+
return;
|
|
8146
8164
|
}
|
|
8147
|
-
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8148
|
-
$xeTable.scrollToRow(newRow, newColumn);
|
|
8149
|
-
$xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), { row: newRow, column: newColumn }), evnt);
|
|
8150
|
-
});
|
|
8151
|
-
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt);
|
|
8152
|
-
return;
|
|
8153
8165
|
}
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8166
|
+
if (tabMethod) {
|
|
8167
|
+
tabMethod(ttrParams);
|
|
8168
|
+
}
|
|
8169
|
+
else {
|
|
8170
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt);
|
|
8171
|
+
}
|
|
8160
8172
|
}
|
|
8161
8173
|
}
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8174
|
+
else {
|
|
8175
|
+
const etrParams = {
|
|
8176
|
+
row: activeRow,
|
|
8177
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8178
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8179
|
+
_rowIndex,
|
|
8180
|
+
column: activeColumn,
|
|
8181
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8182
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8183
|
+
_columnIndex,
|
|
8184
|
+
$table: $xeTable
|
|
8185
|
+
};
|
|
8186
|
+
if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
|
|
8187
|
+
evnt.preventDefault();
|
|
8188
|
+
// 最后一行按下回车键,自动追加一行
|
|
8189
|
+
if (isLastEnterAppendRow) {
|
|
8190
|
+
if (_rowIndex >= afterFullData.length - 1) {
|
|
8191
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8192
|
+
$xeTable.scrollToRow(newRow, activeColumn);
|
|
8193
|
+
$xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), { row: newRow }), evnt);
|
|
8194
|
+
});
|
|
8195
|
+
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt);
|
|
8196
|
+
return;
|
|
8197
|
+
}
|
|
8186
8198
|
}
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8199
|
+
if (enterMethod) {
|
|
8200
|
+
enterMethod(etrParams);
|
|
8201
|
+
}
|
|
8202
|
+
else {
|
|
8203
|
+
if (actived.row) {
|
|
8204
|
+
$xeTable.handleClearEdit(evnt);
|
|
8205
|
+
}
|
|
8206
|
+
$xeTable.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt);
|
|
8194
8207
|
}
|
|
8195
|
-
$xeTable.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt);
|
|
8196
8208
|
}
|
|
8197
8209
|
}
|
|
8198
8210
|
}
|
|
@@ -8220,7 +8232,7 @@ export default defineVxeComponent({
|
|
|
8220
8232
|
else if (operArrow && keyboardConfig && keyboardOpts.isArrow) {
|
|
8221
8233
|
if (!isEditStatus) {
|
|
8222
8234
|
// 如果按下了方向键
|
|
8223
|
-
if (mouseOpts.selected && selected.row &&
|
|
8235
|
+
if (mouseOpts.selected && selected.row && selectColumn) {
|
|
8224
8236
|
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt);
|
|
8225
8237
|
}
|
|
8226
8238
|
else {
|
|
@@ -8239,59 +8251,61 @@ export default defineVxeComponent({
|
|
|
8239
8251
|
// 如果按下了 Tab 键切换
|
|
8240
8252
|
if (selected.row || actived.row) {
|
|
8241
8253
|
const activeRow = selected.row || actived.row;
|
|
8242
|
-
const activeColumn =
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8254
|
+
const activeColumn = selectColumn || actived.column;
|
|
8255
|
+
if (activeColumn) {
|
|
8256
|
+
const activeParams = selected.row ? selected.args : actived.args;
|
|
8257
|
+
const _rowIndex = $xeTable.getVTRowIndex(activeRow);
|
|
8258
|
+
const _columnIndex = $xeTable.getVTColumnIndex(activeColumn);
|
|
8259
|
+
const ttrParams = {
|
|
8260
|
+
row: activeRow,
|
|
8261
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8262
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8263
|
+
_rowIndex,
|
|
8264
|
+
column: activeColumn,
|
|
8265
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8266
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8267
|
+
_columnIndex,
|
|
8268
|
+
$table: $xeTable
|
|
8269
|
+
};
|
|
8270
|
+
if (!beforeTabMethod || beforeTabMethod(ttrParams) !== false) {
|
|
8271
|
+
evnt.preventDefault();
|
|
8272
|
+
// 最后一行按下Tab键,自动追加一行
|
|
8273
|
+
if (isLastTabAppendRow) {
|
|
8274
|
+
const newColumn = visibleColumn[0];
|
|
8275
|
+
if (_rowIndex >= afterFullData.length - 1 && _columnIndex >= visibleColumn.length - 1) {
|
|
8276
|
+
if (actived.row) {
|
|
8277
|
+
$xeTable.handleClearEdit(evnt);
|
|
8278
|
+
}
|
|
8279
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8280
|
+
$xeTable.scrollToRow(newRow, newColumn);
|
|
8281
|
+
$xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), { row: newRow, column: newColumn }), evnt);
|
|
8282
|
+
});
|
|
8283
|
+
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt);
|
|
8284
|
+
return;
|
|
8285
|
+
}
|
|
8286
|
+
}
|
|
8287
|
+
if (tabMethod) {
|
|
8288
|
+
tabMethod(ttrParams);
|
|
8289
|
+
}
|
|
8290
|
+
else {
|
|
8263
8291
|
if (actived.row) {
|
|
8264
8292
|
$xeTable.handleClearEdit(evnt);
|
|
8265
8293
|
}
|
|
8266
|
-
$xeTable.
|
|
8267
|
-
$xeTable.scrollToRow(newRow, newColumn);
|
|
8268
|
-
$xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), { row: newRow, column: newColumn }), evnt);
|
|
8269
|
-
});
|
|
8270
|
-
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt);
|
|
8271
|
-
return;
|
|
8272
|
-
}
|
|
8273
|
-
}
|
|
8274
|
-
if (tabMethod) {
|
|
8275
|
-
tabMethod(ttrParams);
|
|
8276
|
-
}
|
|
8277
|
-
else {
|
|
8278
|
-
if (actived.row) {
|
|
8279
|
-
$xeTable.handleClearEdit(evnt);
|
|
8294
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt);
|
|
8280
8295
|
}
|
|
8281
|
-
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt);
|
|
8282
8296
|
}
|
|
8283
8297
|
}
|
|
8284
8298
|
}
|
|
8285
8299
|
}
|
|
8286
|
-
else if (keyboardConfig && keyboardOpts.isDel && hasDeleteKey && isEnableConf(editConfig) && (selected.row ||
|
|
8300
|
+
else if (keyboardConfig && keyboardOpts.isDel && hasDeleteKey && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8287
8301
|
// 如果是删除键
|
|
8288
8302
|
if (!isEditStatus) {
|
|
8289
8303
|
const { delMethod } = keyboardOpts;
|
|
8290
8304
|
const params = {
|
|
8291
8305
|
row: selected.row,
|
|
8292
8306
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8293
|
-
column:
|
|
8294
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8307
|
+
column: selectColumn,
|
|
8308
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8295
8309
|
$table: $xeTable,
|
|
8296
8310
|
$grid: $xeGrid,
|
|
8297
8311
|
$gantt: $xeGantt
|
|
@@ -8302,7 +8316,11 @@ export default defineVxeComponent({
|
|
|
8302
8316
|
delMethod(params);
|
|
8303
8317
|
}
|
|
8304
8318
|
else {
|
|
8305
|
-
|
|
8319
|
+
const selectCellValue = getCellValue(selected.row, selectColumn);
|
|
8320
|
+
if (selectCellValue !== null) {
|
|
8321
|
+
$xeTable.handlePushStack();
|
|
8322
|
+
setCellValue(selected.row, selectColumn, null);
|
|
8323
|
+
}
|
|
8306
8324
|
}
|
|
8307
8325
|
// 如果按下 del 键,更新表尾数据
|
|
8308
8326
|
$xeTable.updateFooter();
|
|
@@ -8310,16 +8328,16 @@ export default defineVxeComponent({
|
|
|
8310
8328
|
}
|
|
8311
8329
|
}
|
|
8312
8330
|
}
|
|
8313
|
-
else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row ||
|
|
8331
|
+
else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8314
8332
|
if (!isEditStatus) {
|
|
8315
8333
|
const { backMethod } = keyboardOpts;
|
|
8316
8334
|
// 如果是删除键
|
|
8317
|
-
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row ||
|
|
8335
|
+
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8318
8336
|
const params = {
|
|
8319
8337
|
row: selected.row,
|
|
8320
8338
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8321
|
-
column:
|
|
8322
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8339
|
+
column: selectColumn,
|
|
8340
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8323
8341
|
$table: $xeTable,
|
|
8324
8342
|
$grid: $xeGrid,
|
|
8325
8343
|
$gantt: $xeGantt
|
|
@@ -8330,8 +8348,9 @@ export default defineVxeComponent({
|
|
|
8330
8348
|
backMethod(params);
|
|
8331
8349
|
}
|
|
8332
8350
|
else {
|
|
8333
|
-
|
|
8334
|
-
|
|
8351
|
+
$xeTable.handleEdit(params, evnt, {
|
|
8352
|
+
isClear: true
|
|
8353
|
+
});
|
|
8335
8354
|
}
|
|
8336
8355
|
dispatchEvent('cell-backspace-value', params, evnt);
|
|
8337
8356
|
}
|
|
@@ -8356,6 +8375,20 @@ export default defineVxeComponent({
|
|
|
8356
8375
|
.then(() => $xeTable.triggerCurrentRowEvent(evnt, params));
|
|
8357
8376
|
}
|
|
8358
8377
|
}
|
|
8378
|
+
else if (keyboardConfig && keyboardOpts.isUndoRedo && isControlKey && (isZ || isY) && !hasEventInputTarget(evnt.target)) {
|
|
8379
|
+
if (evnt.target) {
|
|
8380
|
+
if (isY || (hasShiftKey && isZ)) {
|
|
8381
|
+
// 恢复被撤销的操作:Ctrl + Y 或 Ctrl + Shift + Z
|
|
8382
|
+
evnt.preventDefault();
|
|
8383
|
+
$xeTable.handleRedoStackEvent(evnt);
|
|
8384
|
+
}
|
|
8385
|
+
else if (isZ) {
|
|
8386
|
+
// 撤销上一步操作:Ctrl + Z
|
|
8387
|
+
evnt.preventDefault();
|
|
8388
|
+
$xeTable.handleUndoStackEvent(evnt);
|
|
8389
|
+
}
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8359
8392
|
else if (keyboardConfig && isEnableConf(editConfig) && keyboardOpts.isEdit && !isControlKey && (isSpacebar || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 96 && keyCode <= 111) || (keyCode >= 186 && keyCode <= 192) || (keyCode >= 219 && keyCode <= 222))) {
|
|
8360
8393
|
const { editMode, editMethod } = keyboardOpts;
|
|
8361
8394
|
// 启用编辑后,空格键功能将失效
|
|
@@ -8363,27 +8396,30 @@ export default defineVxeComponent({
|
|
|
8363
8396
|
// evnt.preventDefault()
|
|
8364
8397
|
// }
|
|
8365
8398
|
// 如果是按下非功能键之外允许直接编辑
|
|
8366
|
-
if (
|
|
8399
|
+
if (selectColumn && selected.row && isEnableConf(selectColumn.editRender)) {
|
|
8367
8400
|
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
|
|
8368
8401
|
const params = {
|
|
8369
8402
|
row: selected.row,
|
|
8370
8403
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8371
|
-
column:
|
|
8372
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8404
|
+
column: selectColumn,
|
|
8405
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8373
8406
|
$table: $xeTable,
|
|
8374
8407
|
$grid: $xeGrid,
|
|
8375
8408
|
$gantt: $xeGantt
|
|
8376
8409
|
};
|
|
8377
|
-
if (!beforeEditMethod || beforeEditMethod(
|
|
8410
|
+
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
8378
8411
|
if (editMethod) {
|
|
8379
8412
|
editMethod(params);
|
|
8380
8413
|
}
|
|
8381
8414
|
else {
|
|
8415
|
+
let isClearValue = false;
|
|
8382
8416
|
// 追加方式与覆盖式
|
|
8383
8417
|
if (editMode !== 'insert') {
|
|
8384
|
-
|
|
8418
|
+
isClearValue = true;
|
|
8385
8419
|
}
|
|
8386
|
-
$xeTable.handleEdit(
|
|
8420
|
+
$xeTable.handleEdit(params, evnt, {
|
|
8421
|
+
isClear: isClearValue
|
|
8422
|
+
});
|
|
8387
8423
|
}
|
|
8388
8424
|
}
|
|
8389
8425
|
}
|
|
@@ -8736,6 +8772,103 @@ export default defineVxeComponent({
|
|
|
8736
8772
|
}
|
|
8737
8773
|
return nextTick();
|
|
8738
8774
|
};
|
|
8775
|
+
const truncateStackHistory = () => {
|
|
8776
|
+
const { stackHistoryStore } = internalData;
|
|
8777
|
+
const { undoStacks } = stackHistoryStore;
|
|
8778
|
+
const undoRedoHistoryOpts = computeUndoRedoHistoryOpts.value;
|
|
8779
|
+
const { stackSize } = undoRedoHistoryOpts;
|
|
8780
|
+
if (undoStacks.length > XEUtils.toNumber(stackSize)) {
|
|
8781
|
+
undoStacks.shift();
|
|
8782
|
+
}
|
|
8783
|
+
};
|
|
8784
|
+
/**
|
|
8785
|
+
* 生成快照数据
|
|
8786
|
+
*/
|
|
8787
|
+
const getSnapshotStackData = () => {
|
|
8788
|
+
const { editStore } = reactData;
|
|
8789
|
+
const { afterFullData, elemStore } = internalData;
|
|
8790
|
+
const { selected, actived } = editStore;
|
|
8791
|
+
const { row: selectRow, column: selectColumn } = selected;
|
|
8792
|
+
const { row: editRow, column: editColumn } = actived;
|
|
8793
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
8794
|
+
const stackObj = {
|
|
8795
|
+
selectActiveInfo: selectRow && selectColumn
|
|
8796
|
+
? {
|
|
8797
|
+
rowid: getRowid($xeTable, selectRow),
|
|
8798
|
+
colid: selectColumn.id
|
|
8799
|
+
}
|
|
8800
|
+
: undefined,
|
|
8801
|
+
editActiveInfo: editRow && editColumn
|
|
8802
|
+
? {
|
|
8803
|
+
rowid: getRowid($xeTable, editRow),
|
|
8804
|
+
colid: editColumn.id
|
|
8805
|
+
}
|
|
8806
|
+
: undefined,
|
|
8807
|
+
scrollInfo: {
|
|
8808
|
+
top: bodyScrollElem ? bodyScrollElem.scrollTop : 0,
|
|
8809
|
+
left: bodyScrollElem ? bodyScrollElem.scrollLeft : 0
|
|
8810
|
+
},
|
|
8811
|
+
visibleData: XEUtils.clone(afterFullData, true),
|
|
8812
|
+
visibleColumn: []
|
|
8813
|
+
};
|
|
8814
|
+
return $xeTable.getCellAreaPushStackObj ? $xeTable.getCellAreaPushStackObj(stackObj) : stackObj;
|
|
8815
|
+
};
|
|
8816
|
+
/**
|
|
8817
|
+
* 刷新栈视图
|
|
8818
|
+
*/
|
|
8819
|
+
const handleUpdateSnapshotStackData = (stackObj) => {
|
|
8820
|
+
const { editStore } = reactData;
|
|
8821
|
+
const { fullAllDataRowIdData, fullColumnIdData } = internalData;
|
|
8822
|
+
if (!stackObj) {
|
|
8823
|
+
return;
|
|
8824
|
+
}
|
|
8825
|
+
const { visibleData, editActiveInfo, selectActiveInfo, scrollInfo } = stackObj;
|
|
8826
|
+
const afterFullList = visibleData.map(item => {
|
|
8827
|
+
const rowid = getRowid($xeTable, item);
|
|
8828
|
+
const rest = fullAllDataRowIdData[rowid];
|
|
8829
|
+
let row = item;
|
|
8830
|
+
if (rest) {
|
|
8831
|
+
row = rest.row;
|
|
8832
|
+
Object.assign(row, item);
|
|
8833
|
+
}
|
|
8834
|
+
return row;
|
|
8835
|
+
});
|
|
8836
|
+
internalData.afterFullData = afterFullList;
|
|
8837
|
+
if ($xeTable.handleCellAreaSnapshotStackData) {
|
|
8838
|
+
$xeTable.handleCellAreaSnapshotStackData(stackObj);
|
|
8839
|
+
}
|
|
8840
|
+
else {
|
|
8841
|
+
const { selected } = editStore;
|
|
8842
|
+
const mouseOpts = computeMouseOpts.value;
|
|
8843
|
+
let selectRowid = '';
|
|
8844
|
+
let selectColid = '';
|
|
8845
|
+
if (editActiveInfo) {
|
|
8846
|
+
selectRowid = editActiveInfo.rowid;
|
|
8847
|
+
selectColid = editActiveInfo.colid;
|
|
8848
|
+
}
|
|
8849
|
+
else if (selectActiveInfo) {
|
|
8850
|
+
selectRowid = selectActiveInfo.rowid;
|
|
8851
|
+
selectColid = selectActiveInfo.colid;
|
|
8852
|
+
}
|
|
8853
|
+
if (selectRowid && selectColid && mouseOpts.selected) {
|
|
8854
|
+
const editRow = fullAllDataRowIdData[selectRowid] ? fullAllDataRowIdData[selectRowid].row : null;
|
|
8855
|
+
const editColumn = fullColumnIdData[selectColid] ? fullColumnIdData[selectColid].column : null;
|
|
8856
|
+
if (editRow && editColumn) {
|
|
8857
|
+
const params = {
|
|
8858
|
+
row: editRow,
|
|
8859
|
+
column: editColumn
|
|
8860
|
+
};
|
|
8861
|
+
selected.row = editRow;
|
|
8862
|
+
selected.column = editColumn;
|
|
8863
|
+
selected.args = params;
|
|
8864
|
+
nextTick(() => {
|
|
8865
|
+
$xeTable.addCellSelectedClass();
|
|
8866
|
+
$xeTable.scrollTo(scrollInfo);
|
|
8867
|
+
});
|
|
8868
|
+
}
|
|
8869
|
+
}
|
|
8870
|
+
}
|
|
8871
|
+
};
|
|
8739
8872
|
const callSlot = (slotFunc, params) => {
|
|
8740
8873
|
if (slotFunc) {
|
|
8741
8874
|
if ($xeGGWrapper) {
|
|
@@ -10758,6 +10891,7 @@ export default defineVxeComponent({
|
|
|
10758
10891
|
afterFullData.splice(nafIndex, 0, dragRow);
|
|
10759
10892
|
tableFullData.splice(ntfIndex, 0, dragRow);
|
|
10760
10893
|
}
|
|
10894
|
+
$xeTable.handleClearStack();
|
|
10761
10895
|
$xeTable.handleTableData(treeConfig && transform);
|
|
10762
10896
|
$xeTable.cacheRowMap(false);
|
|
10763
10897
|
updateScrollYStatus();
|
|
@@ -11418,6 +11552,7 @@ export default defineVxeComponent({
|
|
|
11418
11552
|
column.renderSortNumber = sortIndex;
|
|
11419
11553
|
}
|
|
11420
11554
|
});
|
|
11555
|
+
$xeTable.handleClearStack();
|
|
11421
11556
|
if (mouseConfig) {
|
|
11422
11557
|
if ($xeTable.clearSelected) {
|
|
11423
11558
|
$xeTable.clearSelected();
|
|
@@ -12413,6 +12548,54 @@ export default defineVxeComponent({
|
|
|
12413
12548
|
handleUpdateAggData() {
|
|
12414
12549
|
return loadTableData(internalData.tableSynchData, false, true);
|
|
12415
12550
|
},
|
|
12551
|
+
handlePushStack() {
|
|
12552
|
+
const keyboardOpts = computeKeyboardOpts.value;
|
|
12553
|
+
if (!keyboardOpts.isUndoRedo) {
|
|
12554
|
+
return;
|
|
12555
|
+
}
|
|
12556
|
+
const { stackHistoryStore } = internalData;
|
|
12557
|
+
const stackObj = getSnapshotStackData();
|
|
12558
|
+
stackHistoryStore.undoStacks.push(stackObj);
|
|
12559
|
+
stackHistoryStore.redoStacks = [];
|
|
12560
|
+
truncateStackHistory();
|
|
12561
|
+
},
|
|
12562
|
+
handleUndoStackEvent(evnt) {
|
|
12563
|
+
const { stackHistoryStore } = internalData;
|
|
12564
|
+
const { undoStacks, redoStacks } = stackHistoryStore;
|
|
12565
|
+
if (undoStacks.length) {
|
|
12566
|
+
const stackObj = getSnapshotStackData();
|
|
12567
|
+
redoStacks.push(stackObj);
|
|
12568
|
+
handleUpdateSnapshotStackData(undoStacks.pop());
|
|
12569
|
+
if (evnt) {
|
|
12570
|
+
dispatchEvent('undo', {}, evnt);
|
|
12571
|
+
}
|
|
12572
|
+
return nextTick(() => {
|
|
12573
|
+
return { status: true };
|
|
12574
|
+
});
|
|
12575
|
+
}
|
|
12576
|
+
return Promise.resolve({ status: false });
|
|
12577
|
+
},
|
|
12578
|
+
handleRedoStackEvent(evnt) {
|
|
12579
|
+
const { stackHistoryStore } = internalData;
|
|
12580
|
+
const { undoStacks, redoStacks } = stackHistoryStore;
|
|
12581
|
+
if (redoStacks.length) {
|
|
12582
|
+
const stackObj = getSnapshotStackData();
|
|
12583
|
+
undoStacks.push(stackObj);
|
|
12584
|
+
handleUpdateSnapshotStackData(redoStacks.pop());
|
|
12585
|
+
if (evnt) {
|
|
12586
|
+
dispatchEvent('redo', {}, evnt);
|
|
12587
|
+
}
|
|
12588
|
+
return nextTick(() => {
|
|
12589
|
+
return { status: true };
|
|
12590
|
+
});
|
|
12591
|
+
}
|
|
12592
|
+
return Promise.resolve({ status: false });
|
|
12593
|
+
},
|
|
12594
|
+
handleClearStack() {
|
|
12595
|
+
const { stackHistoryStore } = internalData;
|
|
12596
|
+
stackHistoryStore.undoStacks = [];
|
|
12597
|
+
stackHistoryStore.redoStacks = [];
|
|
12598
|
+
},
|
|
12416
12599
|
updateZindex() {
|
|
12417
12600
|
if (props.zIndex) {
|
|
12418
12601
|
internalData.tZindex = props.zIndex;
|
|
@@ -13465,7 +13648,7 @@ export default defineVxeComponent({
|
|
|
13465
13648
|
$xeTable.preventEvent(null, 'deactivated', { $table: $xeTable });
|
|
13466
13649
|
});
|
|
13467
13650
|
onMounted(() => {
|
|
13468
|
-
const { exportConfig, importConfig, treeConfig, minHeight } = props;
|
|
13651
|
+
const { editConfig, exportConfig, importConfig, treeConfig, minHeight, keepSource } = props;
|
|
13469
13652
|
const { scrollXStore, scrollYStore } = internalData;
|
|
13470
13653
|
const columnOpts = computeColumnOpts.value;
|
|
13471
13654
|
const columnDragOpts = computeColumnDragOpts.value;
|
|
@@ -13518,8 +13701,15 @@ export default defineVxeComponent({
|
|
|
13518
13701
|
if (!(props.rowId || rowOpts.keyField) && (checkboxOpts.reserve || checkboxOpts.checkRowKeys || radioOpts.reserve || radioOpts.checkRowKey || expandOpts.expandRowKeys || treeOpts.expandRowKeys)) {
|
|
13519
13702
|
warnLog('vxe.error.reqProp', ['row-config.keyField']);
|
|
13520
13703
|
}
|
|
13521
|
-
if (
|
|
13522
|
-
|
|
13704
|
+
if (editConfig) {
|
|
13705
|
+
if (!keepSource) {
|
|
13706
|
+
if (editOpts.showStatus || editOpts.showUpdateStatus || editOpts.showInsertStatus) {
|
|
13707
|
+
warnLog('vxe.error.reqSupportProp', ['edit-config.showStatus | showUpdateStatus | showInsertStatus', 'keep-source']);
|
|
13708
|
+
}
|
|
13709
|
+
// if (keyboardOpts.isUndoRedo) {
|
|
13710
|
+
// warnLog('vxe.error.reqSupportProp', ['keyboard-config.isUndoRedo', 'keep-source'])
|
|
13711
|
+
// }
|
|
13712
|
+
}
|
|
13523
13713
|
}
|
|
13524
13714
|
// if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
|
|
13525
13715
|
// warnLog('vxe.error.reqProp', ['show-overflow'])
|
|
@@ -13589,7 +13779,7 @@ export default defineVxeComponent({
|
|
|
13589
13779
|
if (rowOpts.height && !props.showOverflow) {
|
|
13590
13780
|
warnLog('vxe.error.notProp', ['table.show-overflow']);
|
|
13591
13781
|
}
|
|
13592
|
-
if (!$xeTable.
|
|
13782
|
+
if (!$xeTable.triggerCelllAreaMnEvent) {
|
|
13593
13783
|
if (props.areaConfig) {
|
|
13594
13784
|
warnLog('vxe.error.notProp', ['area-config']);
|
|
13595
13785
|
}
|