vxe-table 4.18.13 → 4.19.0-beta.0
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 +325 -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 +320 -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.1777796358891.ttf} +0 -0
- /package/es/{iconfont.1776926463538.woff → iconfont.1777796358891.woff} +0 -0
- /package/es/{iconfont.1776926463538.woff2 → iconfont.1777796358891.woff2} +0 -0
- /package/lib/{iconfont.1776926463538.ttf → iconfont.1777796358891.ttf} +0 -0
- /package/lib/{iconfont.1776926463538.woff → iconfont.1777796358891.woff} +0 -0
- /package/lib/{iconfont.1776926463538.woff2 → iconfont.1777796358891.woff2} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, ComponentPublicInstance, reactive, ref, 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'
|
|
@@ -407,8 +407,8 @@ export default defineVxeComponent({
|
|
|
407
407
|
return Object.assign({}, getConfig().table.clipConfig, props.clipConfig)
|
|
408
408
|
})
|
|
409
409
|
|
|
410
|
-
const
|
|
411
|
-
return Object.assign({}, getConfig().table.
|
|
410
|
+
const computeUndoRedoHistoryOpts = computed(() => {
|
|
411
|
+
return Object.assign({}, getConfig().table.undoRedoHistoryConfig, props.undoRedoHistoryConfig)
|
|
412
412
|
})
|
|
413
413
|
|
|
414
414
|
const computeFNROpts = computed(() => {
|
|
@@ -877,7 +877,7 @@ export default defineVxeComponent({
|
|
|
877
877
|
computeRowGroupFields,
|
|
878
878
|
computeRowGroupColumns,
|
|
879
879
|
computeAggFuncColumns,
|
|
880
|
-
|
|
880
|
+
computeUndoRedoHistoryOpts,
|
|
881
881
|
|
|
882
882
|
computeFNROpts,
|
|
883
883
|
computeSXOpts,
|
|
@@ -1844,7 +1844,7 @@ export default defineVxeComponent({
|
|
|
1844
1844
|
errLog('vxe.error.errConflicts', ['mouse-config.area', 'column.type=expand'])
|
|
1845
1845
|
}
|
|
1846
1846
|
if (expandOpts.mode !== 'inside' && (treeConfig && !treeOpts.transform)) {
|
|
1847
|
-
errLog('vxe.error.notConflictProp', ['tree-config.transform=false', 'expand-config.mode=
|
|
1847
|
+
errLog('vxe.error.notConflictProp', ['tree-config.transform=false', 'expand-config.mode=inside'])
|
|
1848
1848
|
}
|
|
1849
1849
|
if (props.spanMethod) {
|
|
1850
1850
|
warnLog('vxe.error.notSupportProp', ['column.type=expand', 'span-method', 'span-method=null'])
|
|
@@ -3805,6 +3805,7 @@ export default defineVxeComponent({
|
|
|
3805
3805
|
}
|
|
3806
3806
|
$xeTable.clearMergeCells()
|
|
3807
3807
|
$xeTable.clearMergeFooterItems()
|
|
3808
|
+
$xeTable.handleClearStack()
|
|
3808
3809
|
$xeTable.handleTableData(true)
|
|
3809
3810
|
$xeTable.updateFooter()
|
|
3810
3811
|
$xeTable.handleUpdateBodyMerge()
|
|
@@ -7790,6 +7791,12 @@ export default defineVxeComponent({
|
|
|
7790
7791
|
}
|
|
7791
7792
|
return nextTick()
|
|
7792
7793
|
},
|
|
7794
|
+
undo () {
|
|
7795
|
+
return $xeTable.handleUndoStackEvent(null)
|
|
7796
|
+
},
|
|
7797
|
+
redo () {
|
|
7798
|
+
return $xeTable.handleRedoStackEvent(null)
|
|
7799
|
+
},
|
|
7793
7800
|
getCustomStoreData () {
|
|
7794
7801
|
const { id } = props
|
|
7795
7802
|
const customOpts = computeCustomOpts.value
|
|
@@ -8191,6 +8198,8 @@ export default defineVxeComponent({
|
|
|
8191
8198
|
const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT)
|
|
8192
8199
|
const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
|
|
8193
8200
|
const hasDeleteKey = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE)
|
|
8201
|
+
const isY = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.Y)
|
|
8202
|
+
const isZ = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.Z)
|
|
8194
8203
|
const isF2 = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.F2)
|
|
8195
8204
|
const isContextMenu = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.CONTEXT_MENU)
|
|
8196
8205
|
const isControlKey = hasControlKey(evnt)
|
|
@@ -8200,6 +8209,7 @@ export default defineVxeComponent({
|
|
|
8200
8209
|
const operCtxMenu = isContentMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow)
|
|
8201
8210
|
const isEditStatus = isEnableConf(editConfig) && actived.column && actived.row
|
|
8202
8211
|
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod
|
|
8212
|
+
const selectColumn = selected.column
|
|
8203
8213
|
if (operCtxMenu) {
|
|
8204
8214
|
// 如果配置了右键菜单; 支持方向键操作、回车
|
|
8205
8215
|
evnt.preventDefault()
|
|
@@ -8227,10 +8237,10 @@ export default defineVxeComponent({
|
|
|
8227
8237
|
}
|
|
8228
8238
|
}
|
|
8229
8239
|
}
|
|
8230
|
-
} else if (isSpacebar && keyboardConfig && keyboardOpts.isChecked && selected.row &&
|
|
8240
|
+
} else if (isSpacebar && keyboardConfig && keyboardOpts.isChecked && selected.row && selectColumn && (selectColumn.type === 'checkbox' || selectColumn.type === 'radio')) {
|
|
8231
8241
|
// 空格键支持选中复选框
|
|
8232
8242
|
evnt.preventDefault()
|
|
8233
|
-
if (
|
|
8243
|
+
if (selectColumn.type === 'checkbox') {
|
|
8234
8244
|
$xeTable.handleToggleCheckRowEvent(evnt, selected.args)
|
|
8235
8245
|
} else {
|
|
8236
8246
|
$xeTable.triggerRadioRowEvent(evnt, selected.args)
|
|
@@ -8238,14 +8248,14 @@ export default defineVxeComponent({
|
|
|
8238
8248
|
} else if (isF2 && isEnableConf(editConfig)) {
|
|
8239
8249
|
if (!isEditStatus) {
|
|
8240
8250
|
// 如果按下了 F2 键
|
|
8241
|
-
if (selected.row &&
|
|
8251
|
+
if (selected.row && selectColumn) {
|
|
8242
8252
|
evnt.preventDefault()
|
|
8243
8253
|
$xeTable.handleEdit(selected.args, evnt)
|
|
8244
8254
|
}
|
|
8245
8255
|
}
|
|
8246
8256
|
} else if (isContextMenu) {
|
|
8247
8257
|
// 如果按下上下文键
|
|
8248
|
-
internalData._keyCtx = selected.row &&
|
|
8258
|
+
internalData._keyCtx = selected.row && selectColumn && bodyMenu.length
|
|
8249
8259
|
clearTimeout(internalData.keyCtxTimeout)
|
|
8250
8260
|
internalData.keyCtxTimeout = setTimeout(() => {
|
|
8251
8261
|
internalData._keyCtx = false
|
|
@@ -8268,84 +8278,86 @@ export default defineVxeComponent({
|
|
|
8268
8278
|
// 如果是激活状态,退则出到上一行/下一行
|
|
8269
8279
|
if (selected.row || actived.row) {
|
|
8270
8280
|
const activeRow = selected.row || actived.row
|
|
8271
|
-
const activeColumn =
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
if (
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
} else {
|
|
8280
|
-
const _rowIndex = $xeTable.getVTRowIndex(activeRow)
|
|
8281
|
-
const _columnIndex = $xeTable.getVTColumnIndex(activeColumn)
|
|
8282
|
-
if (keyboardOpts.enterToTab) {
|
|
8283
|
-
const ttrParams = {
|
|
8284
|
-
row: activeRow,
|
|
8285
|
-
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8286
|
-
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8287
|
-
_rowIndex,
|
|
8288
|
-
column: activeColumn,
|
|
8289
|
-
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8290
|
-
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8291
|
-
_columnIndex,
|
|
8292
|
-
$table: $xeTable
|
|
8281
|
+
const activeColumn = selectColumn || actived.column
|
|
8282
|
+
if (activeColumn) {
|
|
8283
|
+
const activeParams = selected.row ? selected.args : actived.args
|
|
8284
|
+
if (hasShiftKey) {
|
|
8285
|
+
if (keyboardOpts.enterToTab) {
|
|
8286
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
8287
|
+
} else {
|
|
8288
|
+
$xeTable.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
|
|
8293
8289
|
}
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8290
|
+
} else {
|
|
8291
|
+
const _rowIndex = $xeTable.getVTRowIndex(activeRow)
|
|
8292
|
+
const _columnIndex = $xeTable.getVTColumnIndex(activeColumn)
|
|
8293
|
+
if (keyboardOpts.enterToTab) {
|
|
8294
|
+
const ttrParams = {
|
|
8295
|
+
row: activeRow,
|
|
8296
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8297
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8298
|
+
_rowIndex,
|
|
8299
|
+
column: activeColumn,
|
|
8300
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8301
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8302
|
+
_columnIndex,
|
|
8303
|
+
$table: $xeTable
|
|
8304
|
+
}
|
|
8305
|
+
if (!beforeTabMethod || beforeTabMethod(ttrParams) !== false) {
|
|
8306
|
+
evnt.preventDefault()
|
|
8307
|
+
// 最后一行按下Tab键,自动追加一行
|
|
8308
|
+
if (isLastTabAppendRow) {
|
|
8309
|
+
const newColumn = visibleColumn[0]
|
|
8310
|
+
if (_rowIndex >= afterFullData.length - 1 && _columnIndex >= visibleColumn.length - 1) {
|
|
8311
|
+
if (actived.row) {
|
|
8312
|
+
$xeTable.handleClearEdit(evnt)
|
|
8313
|
+
}
|
|
8314
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8315
|
+
$xeTable.scrollToRow(newRow, newColumn)
|
|
8316
|
+
$xeTable.handleSelected({ ...activeParams, row: newRow, column: newColumn }, evnt)
|
|
8317
|
+
})
|
|
8318
|
+
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt)
|
|
8319
|
+
return
|
|
8302
8320
|
}
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
$xeTable.
|
|
8308
|
-
return
|
|
8321
|
+
}
|
|
8322
|
+
if (tabMethod) {
|
|
8323
|
+
tabMethod(ttrParams)
|
|
8324
|
+
} else {
|
|
8325
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
8309
8326
|
}
|
|
8310
8327
|
}
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
$xeTable.
|
|
8328
|
+
} else {
|
|
8329
|
+
const etrParams = {
|
|
8330
|
+
row: activeRow,
|
|
8331
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8332
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8333
|
+
_rowIndex,
|
|
8334
|
+
column: activeColumn,
|
|
8335
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8336
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8337
|
+
_columnIndex,
|
|
8338
|
+
$table: $xeTable
|
|
8315
8339
|
}
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
}
|
|
8329
|
-
if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
|
|
8330
|
-
evnt.preventDefault()
|
|
8331
|
-
// 最后一行按下回车键,自动追加一行
|
|
8332
|
-
if (isLastEnterAppendRow) {
|
|
8333
|
-
if (_rowIndex >= afterFullData.length - 1) {
|
|
8334
|
-
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8335
|
-
$xeTable.scrollToRow(newRow, activeColumn)
|
|
8336
|
-
$xeTable.handleSelected({ ...activeParams, row: newRow }, evnt)
|
|
8337
|
-
})
|
|
8338
|
-
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt)
|
|
8339
|
-
return
|
|
8340
|
+
if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
|
|
8341
|
+
evnt.preventDefault()
|
|
8342
|
+
// 最后一行按下回车键,自动追加一行
|
|
8343
|
+
if (isLastEnterAppendRow) {
|
|
8344
|
+
if (_rowIndex >= afterFullData.length - 1) {
|
|
8345
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8346
|
+
$xeTable.scrollToRow(newRow, activeColumn)
|
|
8347
|
+
$xeTable.handleSelected({ ...activeParams, row: newRow }, evnt)
|
|
8348
|
+
})
|
|
8349
|
+
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt)
|
|
8350
|
+
return
|
|
8351
|
+
}
|
|
8340
8352
|
}
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8353
|
+
if (enterMethod) {
|
|
8354
|
+
enterMethod(etrParams)
|
|
8355
|
+
} else {
|
|
8356
|
+
if (actived.row) {
|
|
8357
|
+
$xeTable.handleClearEdit(evnt)
|
|
8358
|
+
}
|
|
8359
|
+
$xeTable.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
8347
8360
|
}
|
|
8348
|
-
$xeTable.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
8349
8361
|
}
|
|
8350
8362
|
}
|
|
8351
8363
|
}
|
|
@@ -8371,7 +8383,7 @@ export default defineVxeComponent({
|
|
|
8371
8383
|
} else if (operArrow && keyboardConfig && keyboardOpts.isArrow) {
|
|
8372
8384
|
if (!isEditStatus) {
|
|
8373
8385
|
// 如果按下了方向键
|
|
8374
|
-
if (mouseOpts.selected && selected.row &&
|
|
8386
|
+
if (mouseOpts.selected && selected.row && selectColumn) {
|
|
8375
8387
|
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
8376
8388
|
} else {
|
|
8377
8389
|
// 当前行按键上下移动
|
|
@@ -8388,57 +8400,59 @@ export default defineVxeComponent({
|
|
|
8388
8400
|
// 如果按下了 Tab 键切换
|
|
8389
8401
|
if (selected.row || actived.row) {
|
|
8390
8402
|
const activeRow = selected.row || actived.row
|
|
8391
|
-
const activeColumn =
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8403
|
+
const activeColumn = selectColumn || actived.column
|
|
8404
|
+
if (activeColumn) {
|
|
8405
|
+
const activeParams = selected.row ? selected.args : actived.args
|
|
8406
|
+
const _rowIndex = $xeTable.getVTRowIndex(activeRow)
|
|
8407
|
+
const _columnIndex = $xeTable.getVTColumnIndex(activeColumn)
|
|
8408
|
+
const ttrParams = {
|
|
8409
|
+
row: activeRow,
|
|
8410
|
+
rowIndex: $xeTable.getRowIndex(activeRow),
|
|
8411
|
+
$rowIndex: $xeTable.getVMRowIndex(activeRow),
|
|
8412
|
+
_rowIndex,
|
|
8413
|
+
column: activeColumn as VxeTableDefines.ColumnInfo,
|
|
8414
|
+
columnIndex: $xeTable.getColumnIndex(activeColumn),
|
|
8415
|
+
$columnIndex: $xeTable.getVMColumnIndex(activeColumn),
|
|
8416
|
+
_columnIndex,
|
|
8417
|
+
$table: $xeTable
|
|
8418
|
+
}
|
|
8419
|
+
if (!beforeTabMethod || beforeTabMethod(ttrParams) !== false) {
|
|
8420
|
+
evnt.preventDefault()
|
|
8421
|
+
// 最后一行按下Tab键,自动追加一行
|
|
8422
|
+
if (isLastTabAppendRow) {
|
|
8423
|
+
const newColumn = visibleColumn[0]
|
|
8424
|
+
if (_rowIndex >= afterFullData.length - 1 && _columnIndex >= visibleColumn.length - 1) {
|
|
8425
|
+
if (actived.row) {
|
|
8426
|
+
$xeTable.handleClearEdit(evnt)
|
|
8427
|
+
}
|
|
8428
|
+
$xeTable.insertAt({}, -1).then(({ row: newRow }) => {
|
|
8429
|
+
$xeTable.scrollToRow(newRow, newColumn)
|
|
8430
|
+
$xeTable.handleSelected({ ...activeParams, row: newRow, column: newColumn }, evnt)
|
|
8431
|
+
})
|
|
8432
|
+
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt)
|
|
8433
|
+
return
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
if (tabMethod) {
|
|
8437
|
+
tabMethod(ttrParams)
|
|
8438
|
+
} else {
|
|
8412
8439
|
if (actived.row) {
|
|
8413
8440
|
$xeTable.handleClearEdit(evnt)
|
|
8414
8441
|
}
|
|
8415
|
-
$xeTable.
|
|
8416
|
-
$xeTable.scrollToRow(newRow, newColumn)
|
|
8417
|
-
$xeTable.handleSelected({ ...activeParams, row: newRow, column: newColumn }, evnt)
|
|
8418
|
-
})
|
|
8419
|
-
$xeTable.dispatchEvent('tab-append-row', ttrParams, evnt)
|
|
8420
|
-
return
|
|
8421
|
-
}
|
|
8422
|
-
}
|
|
8423
|
-
if (tabMethod) {
|
|
8424
|
-
tabMethod(ttrParams)
|
|
8425
|
-
} else {
|
|
8426
|
-
if (actived.row) {
|
|
8427
|
-
$xeTable.handleClearEdit(evnt)
|
|
8442
|
+
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
8428
8443
|
}
|
|
8429
|
-
$xeTable.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
8430
8444
|
}
|
|
8431
8445
|
}
|
|
8432
8446
|
}
|
|
8433
|
-
} else if (keyboardConfig && keyboardOpts.isDel && hasDeleteKey && isEnableConf(editConfig) && (selected.row ||
|
|
8447
|
+
} else if (keyboardConfig && keyboardOpts.isDel && hasDeleteKey && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8434
8448
|
// 如果是删除键
|
|
8435
8449
|
if (!isEditStatus) {
|
|
8436
8450
|
const { delMethod } = keyboardOpts
|
|
8437
8451
|
const params = {
|
|
8438
8452
|
row: selected.row,
|
|
8439
8453
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8440
|
-
column:
|
|
8441
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8454
|
+
column: selectColumn as VxeTableDefines.ColumnInfo,
|
|
8455
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8442
8456
|
$table: $xeTable,
|
|
8443
8457
|
$grid: $xeGrid,
|
|
8444
8458
|
$gantt: $xeGantt
|
|
@@ -8448,23 +8462,27 @@ export default defineVxeComponent({
|
|
|
8448
8462
|
if (delMethod) {
|
|
8449
8463
|
delMethod(params)
|
|
8450
8464
|
} else {
|
|
8451
|
-
|
|
8465
|
+
const selectCellValue = getCellValue(selected.row, selectColumn)
|
|
8466
|
+
if (selectCellValue !== null) {
|
|
8467
|
+
$xeTable.handlePushStack()
|
|
8468
|
+
setCellValue(selected.row, selectColumn, null)
|
|
8469
|
+
}
|
|
8452
8470
|
}
|
|
8453
8471
|
// 如果按下 del 键,更新表尾数据
|
|
8454
8472
|
$xeTable.updateFooter()
|
|
8455
8473
|
dispatchEvent('cell-delete-value', params, evnt)
|
|
8456
8474
|
}
|
|
8457
8475
|
}
|
|
8458
|
-
} else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row ||
|
|
8476
|
+
} else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8459
8477
|
if (!isEditStatus) {
|
|
8460
8478
|
const { backMethod } = keyboardOpts
|
|
8461
8479
|
// 如果是删除键
|
|
8462
|
-
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row ||
|
|
8480
|
+
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row || selectColumn)) {
|
|
8463
8481
|
const params = {
|
|
8464
8482
|
row: selected.row,
|
|
8465
8483
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8466
|
-
column:
|
|
8467
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8484
|
+
column: selectColumn as VxeTableDefines.ColumnInfo,
|
|
8485
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8468
8486
|
$table: $xeTable,
|
|
8469
8487
|
$grid: $xeGrid,
|
|
8470
8488
|
$gantt: $xeGantt
|
|
@@ -8474,8 +8492,9 @@ export default defineVxeComponent({
|
|
|
8474
8492
|
if (backMethod) {
|
|
8475
8493
|
backMethod(params)
|
|
8476
8494
|
} else {
|
|
8477
|
-
|
|
8478
|
-
|
|
8495
|
+
$xeTable.handleEdit(params, evnt, {
|
|
8496
|
+
isClear: true
|
|
8497
|
+
})
|
|
8479
8498
|
}
|
|
8480
8499
|
dispatchEvent('cell-backspace-value', params, evnt)
|
|
8481
8500
|
}
|
|
@@ -8498,6 +8517,18 @@ export default defineVxeComponent({
|
|
|
8498
8517
|
.then(() => $xeTable.scrollToRow(parentRow))
|
|
8499
8518
|
.then(() => $xeTable.triggerCurrentRowEvent(evnt, params))
|
|
8500
8519
|
}
|
|
8520
|
+
} else if (keyboardConfig && keyboardOpts.isUndoRedo && isControlKey && (isZ || isY) && !hasEventInputTarget(evnt.target)) {
|
|
8521
|
+
if (evnt.target) {
|
|
8522
|
+
if (isY || (hasShiftKey && isZ)) {
|
|
8523
|
+
// 恢复被撤销的操作:Ctrl + Y 或 Ctrl + Shift + Z
|
|
8524
|
+
evnt.preventDefault()
|
|
8525
|
+
$xeTable.handleRedoStackEvent(evnt)
|
|
8526
|
+
} else if (isZ) {
|
|
8527
|
+
// 撤销上一步操作:Ctrl + Z
|
|
8528
|
+
evnt.preventDefault()
|
|
8529
|
+
$xeTable.handleUndoStackEvent(evnt)
|
|
8530
|
+
}
|
|
8531
|
+
}
|
|
8501
8532
|
} 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))) {
|
|
8502
8533
|
const { editMode, editMethod } = keyboardOpts
|
|
8503
8534
|
// 启用编辑后,空格键功能将失效
|
|
@@ -8505,26 +8536,29 @@ export default defineVxeComponent({
|
|
|
8505
8536
|
// evnt.preventDefault()
|
|
8506
8537
|
// }
|
|
8507
8538
|
// 如果是按下非功能键之外允许直接编辑
|
|
8508
|
-
if (
|
|
8539
|
+
if (selectColumn && selected.row && isEnableConf(selectColumn.editRender)) {
|
|
8509
8540
|
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod
|
|
8510
8541
|
const params = {
|
|
8511
8542
|
row: selected.row,
|
|
8512
8543
|
rowIndex: $xeTable.getRowIndex(selected.row),
|
|
8513
|
-
column:
|
|
8514
|
-
columnIndex: $xeTable.getColumnIndex(
|
|
8544
|
+
column: selectColumn,
|
|
8545
|
+
columnIndex: $xeTable.getColumnIndex(selectColumn),
|
|
8515
8546
|
$table: $xeTable,
|
|
8516
8547
|
$grid: $xeGrid,
|
|
8517
8548
|
$gantt: $xeGantt
|
|
8518
8549
|
}
|
|
8519
|
-
if (!beforeEditMethod || beforeEditMethod(
|
|
8550
|
+
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
8520
8551
|
if (editMethod) {
|
|
8521
8552
|
editMethod(params)
|
|
8522
8553
|
} else {
|
|
8554
|
+
let isClearValue = false
|
|
8523
8555
|
// 追加方式与覆盖式
|
|
8524
8556
|
if (editMode !== 'insert') {
|
|
8525
|
-
|
|
8557
|
+
isClearValue = true
|
|
8526
8558
|
}
|
|
8527
|
-
$xeTable.handleEdit(
|
|
8559
|
+
$xeTable.handleEdit(params, evnt, {
|
|
8560
|
+
isClear: isClearValue
|
|
8561
|
+
})
|
|
8528
8562
|
}
|
|
8529
8563
|
}
|
|
8530
8564
|
}
|
|
@@ -8891,6 +8925,99 @@ export default defineVxeComponent({
|
|
|
8891
8925
|
return nextTick()
|
|
8892
8926
|
}
|
|
8893
8927
|
|
|
8928
|
+
const truncateStackHistory = () => {
|
|
8929
|
+
const { stackHistoryStore } = internalData
|
|
8930
|
+
const { undoStacks } = stackHistoryStore
|
|
8931
|
+
const undoRedoHistoryOpts = computeUndoRedoHistoryOpts.value
|
|
8932
|
+
const { stackSize } = undoRedoHistoryOpts
|
|
8933
|
+
if (undoStacks.length > XEUtils.toNumber(stackSize)) {
|
|
8934
|
+
undoStacks.shift()
|
|
8935
|
+
}
|
|
8936
|
+
}
|
|
8937
|
+
|
|
8938
|
+
/**
|
|
8939
|
+
* 生成快照数据
|
|
8940
|
+
*/
|
|
8941
|
+
const getSnapshotStackData = () => {
|
|
8942
|
+
const { editStore } = reactData
|
|
8943
|
+
const { afterFullData } = internalData
|
|
8944
|
+
const { selected, actived } = editStore
|
|
8945
|
+
const { row: selectRow, column: selectColumn } = selected
|
|
8946
|
+
const { row: editRow, column: editColumn } = actived
|
|
8947
|
+
const stackObj: VxeTableDefines.HistoryStackObj = {
|
|
8948
|
+
selectActiveInfo: selectRow && selectColumn
|
|
8949
|
+
? {
|
|
8950
|
+
rowid: getRowid($xeTable, selectRow),
|
|
8951
|
+
colid: selectColumn.id
|
|
8952
|
+
}
|
|
8953
|
+
: undefined,
|
|
8954
|
+
editActiveInfo: editRow && editColumn
|
|
8955
|
+
? {
|
|
8956
|
+
rowid: getRowid($xeTable, editRow),
|
|
8957
|
+
colid: editColumn.id
|
|
8958
|
+
}
|
|
8959
|
+
: undefined,
|
|
8960
|
+
visibleData: XEUtils.clone(afterFullData, true),
|
|
8961
|
+
visibleColumn: []
|
|
8962
|
+
}
|
|
8963
|
+
return $xeTable.getCellAreaPushStackObj ? $xeTable.getCellAreaPushStackObj(stackObj) : stackObj
|
|
8964
|
+
}
|
|
8965
|
+
|
|
8966
|
+
/**
|
|
8967
|
+
* 刷新栈视图
|
|
8968
|
+
*/
|
|
8969
|
+
const handleUpdateSnapshotStackData = (stackObj: VxeTableDefines.HistoryStackObj | null | undefined) => {
|
|
8970
|
+
const { editStore } = reactData
|
|
8971
|
+
const { fullAllDataRowIdData, fullColumnIdData } = internalData
|
|
8972
|
+
if (!stackObj) {
|
|
8973
|
+
return
|
|
8974
|
+
}
|
|
8975
|
+
const { visibleData, editActiveInfo, selectActiveInfo } = stackObj
|
|
8976
|
+
const afterFullList = visibleData.map(item => {
|
|
8977
|
+
const rowid = getRowid($xeTable, item)
|
|
8978
|
+
const rest = fullAllDataRowIdData[rowid]
|
|
8979
|
+
let row = item
|
|
8980
|
+
if (rest) {
|
|
8981
|
+
row = rest.row
|
|
8982
|
+
Object.assign(row, item)
|
|
8983
|
+
}
|
|
8984
|
+
return row
|
|
8985
|
+
})
|
|
8986
|
+
|
|
8987
|
+
internalData.afterFullData = afterFullList
|
|
8988
|
+
if ($xeTable.handleCellAreaSnapshotStackData) {
|
|
8989
|
+
$xeTable.handleCellAreaSnapshotStackData(stackObj)
|
|
8990
|
+
} else {
|
|
8991
|
+
const { selected } = editStore
|
|
8992
|
+
const mouseOpts = computeMouseOpts.value
|
|
8993
|
+
let selectRowid = ''
|
|
8994
|
+
let selectColid = ''
|
|
8995
|
+
if (editActiveInfo) {
|
|
8996
|
+
selectRowid = editActiveInfo.rowid
|
|
8997
|
+
selectColid = editActiveInfo.colid
|
|
8998
|
+
} else if (selectActiveInfo) {
|
|
8999
|
+
selectRowid = selectActiveInfo.rowid
|
|
9000
|
+
selectColid = selectActiveInfo.colid
|
|
9001
|
+
}
|
|
9002
|
+
if (selectRowid && selectColid && mouseOpts.selected) {
|
|
9003
|
+
const editRow = fullAllDataRowIdData[selectRowid] ? fullAllDataRowIdData[selectRowid].row : null
|
|
9004
|
+
const editColumn = fullColumnIdData[selectColid] ? fullColumnIdData[selectColid].column : null
|
|
9005
|
+
if (editRow && editColumn) {
|
|
9006
|
+
const params = {
|
|
9007
|
+
row: editRow,
|
|
9008
|
+
column: editColumn
|
|
9009
|
+
}
|
|
9010
|
+
selected.row = editRow
|
|
9011
|
+
selected.column = editColumn
|
|
9012
|
+
selected.args = params
|
|
9013
|
+
nextTick(() => {
|
|
9014
|
+
$xeTable.addCellSelectedClass()
|
|
9015
|
+
})
|
|
9016
|
+
}
|
|
9017
|
+
}
|
|
9018
|
+
}
|
|
9019
|
+
}
|
|
9020
|
+
|
|
8894
9021
|
const callSlot = <T>(slotFunc: ((params: T) => VxeComponentSlotType | VxeComponentSlotType[]) | string | null, params: T): VxeComponentSlotType[] => {
|
|
8895
9022
|
if (slotFunc) {
|
|
8896
9023
|
if ($xeGGWrapper) {
|
|
@@ -10898,6 +11025,7 @@ export default defineVxeComponent({
|
|
|
10898
11025
|
tableFullData.splice(ntfIndex, 0, dragRow)
|
|
10899
11026
|
}
|
|
10900
11027
|
|
|
11028
|
+
$xeTable.handleClearStack()
|
|
10901
11029
|
$xeTable.handleTableData(treeConfig && transform)
|
|
10902
11030
|
$xeTable.cacheRowMap(false)
|
|
10903
11031
|
updateScrollYStatus()
|
|
@@ -11566,6 +11694,7 @@ export default defineVxeComponent({
|
|
|
11566
11694
|
}
|
|
11567
11695
|
})
|
|
11568
11696
|
|
|
11697
|
+
$xeTable.handleClearStack()
|
|
11569
11698
|
if (mouseConfig) {
|
|
11570
11699
|
if ($xeTable.clearSelected) {
|
|
11571
11700
|
$xeTable.clearSelected()
|
|
@@ -12581,6 +12710,54 @@ export default defineVxeComponent({
|
|
|
12581
12710
|
handleUpdateAggData () {
|
|
12582
12711
|
return loadTableData(internalData.tableSynchData, false, true)
|
|
12583
12712
|
},
|
|
12713
|
+
handlePushStack () {
|
|
12714
|
+
const keyboardOpts = computeKeyboardOpts.value
|
|
12715
|
+
if (!keyboardOpts.isUndoRedo) {
|
|
12716
|
+
return
|
|
12717
|
+
}
|
|
12718
|
+
const { stackHistoryStore } = internalData
|
|
12719
|
+
const stackObj = getSnapshotStackData()
|
|
12720
|
+
stackHistoryStore.undoStacks.push(stackObj)
|
|
12721
|
+
stackHistoryStore.redoStacks = []
|
|
12722
|
+
truncateStackHistory()
|
|
12723
|
+
},
|
|
12724
|
+
handleUndoStackEvent (evnt) {
|
|
12725
|
+
const { stackHistoryStore } = internalData
|
|
12726
|
+
const { undoStacks, redoStacks } = stackHistoryStore
|
|
12727
|
+
if (undoStacks.length) {
|
|
12728
|
+
const stackObj = getSnapshotStackData()
|
|
12729
|
+
redoStacks.push(stackObj)
|
|
12730
|
+
handleUpdateSnapshotStackData(undoStacks.pop())
|
|
12731
|
+
if (evnt) {
|
|
12732
|
+
dispatchEvent('undo', {}, evnt)
|
|
12733
|
+
}
|
|
12734
|
+
return nextTick(() => {
|
|
12735
|
+
return { status: true }
|
|
12736
|
+
})
|
|
12737
|
+
}
|
|
12738
|
+
return Promise.resolve({ status: false })
|
|
12739
|
+
},
|
|
12740
|
+
handleRedoStackEvent (evnt) {
|
|
12741
|
+
const { stackHistoryStore } = internalData
|
|
12742
|
+
const { undoStacks, redoStacks } = stackHistoryStore
|
|
12743
|
+
if (redoStacks.length) {
|
|
12744
|
+
const stackObj = getSnapshotStackData()
|
|
12745
|
+
undoStacks.push(stackObj)
|
|
12746
|
+
handleUpdateSnapshotStackData(redoStacks.pop())
|
|
12747
|
+
if (evnt) {
|
|
12748
|
+
dispatchEvent('redo', {}, evnt)
|
|
12749
|
+
}
|
|
12750
|
+
return nextTick(() => {
|
|
12751
|
+
return { status: true }
|
|
12752
|
+
})
|
|
12753
|
+
}
|
|
12754
|
+
return Promise.resolve({ status: false })
|
|
12755
|
+
},
|
|
12756
|
+
handleClearStack () {
|
|
12757
|
+
const { stackHistoryStore } = internalData
|
|
12758
|
+
stackHistoryStore.undoStacks = []
|
|
12759
|
+
stackHistoryStore.redoStacks = []
|
|
12760
|
+
},
|
|
12584
12761
|
updateZindex () {
|
|
12585
12762
|
if (props.zIndex) {
|
|
12586
12763
|
internalData.tZindex = props.zIndex
|
|
@@ -13680,7 +13857,7 @@ export default defineVxeComponent({
|
|
|
13680
13857
|
})
|
|
13681
13858
|
|
|
13682
13859
|
onMounted(() => {
|
|
13683
|
-
const { exportConfig, importConfig, treeConfig, minHeight } = props
|
|
13860
|
+
const { editConfig, exportConfig, importConfig, treeConfig, minHeight, keepSource } = props
|
|
13684
13861
|
const { scrollXStore, scrollYStore } = internalData
|
|
13685
13862
|
const columnOpts = computeColumnOpts.value
|
|
13686
13863
|
const columnDragOpts = computeColumnDragOpts.value
|
|
@@ -13736,8 +13913,15 @@ export default defineVxeComponent({
|
|
|
13736
13913
|
if (!(props.rowId || rowOpts.keyField) && (checkboxOpts.reserve || checkboxOpts.checkRowKeys || radioOpts.reserve || radioOpts.checkRowKey || expandOpts.expandRowKeys || treeOpts.expandRowKeys)) {
|
|
13737
13914
|
warnLog('vxe.error.reqProp', ['row-config.keyField'])
|
|
13738
13915
|
}
|
|
13739
|
-
if (
|
|
13740
|
-
|
|
13916
|
+
if (editConfig) {
|
|
13917
|
+
if (!keepSource) {
|
|
13918
|
+
if (editOpts.showStatus || editOpts.showUpdateStatus || editOpts.showInsertStatus) {
|
|
13919
|
+
warnLog('vxe.error.reqSupportProp', ['edit-config.showStatus | showUpdateStatus | showInsertStatus', 'keep-source'])
|
|
13920
|
+
}
|
|
13921
|
+
// if (keyboardOpts.isUndoRedo) {
|
|
13922
|
+
// warnLog('vxe.error.reqSupportProp', ['keyboard-config.isUndoRedo', 'keep-source'])
|
|
13923
|
+
// }
|
|
13924
|
+
}
|
|
13741
13925
|
}
|
|
13742
13926
|
// if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
|
|
13743
13927
|
// warnLog('vxe.error.reqProp', ['show-overflow'])
|
|
@@ -13809,7 +13993,7 @@ export default defineVxeComponent({
|
|
|
13809
13993
|
if (rowOpts.height && !props.showOverflow) {
|
|
13810
13994
|
warnLog('vxe.error.notProp', ['table.show-overflow'])
|
|
13811
13995
|
}
|
|
13812
|
-
if (!$xeTable.
|
|
13996
|
+
if (!$xeTable.triggerCelllAreaMnEvent) {
|
|
13813
13997
|
if (props.areaConfig) {
|
|
13814
13998
|
warnLog('vxe.error.notProp', ['area-config'])
|
|
13815
13999
|
}
|